All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.llamalad7.mixinextras.service.ServiceInitializationExtension Maven / Gradle / Ivy

package com.llamalad7.mixinextras.service;

import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.MixinEnvironment;
import org.spongepowered.asm.mixin.transformer.ext.IExtension;
import org.spongepowered.asm.mixin.transformer.ext.ITargetClassContext;

class ServiceInitializationExtension implements IExtension {
    private final MixinExtrasService service;
    private boolean initialized;

    public ServiceInitializationExtension(MixinExtrasService service) {
        this.service = service;
    }

    @Override
    public boolean checkActive(MixinEnvironment environment) {
        return true;
    }

    @Override
    public void preApply(ITargetClassContext context) {
        if (!initialized) {
            service.initialize();
            initialized = true;
        }
    }

    @Override
    public void postApply(ITargetClassContext context) {
    }

    @Override
    public void export(MixinEnvironment env, String name, boolean force, ClassNode classNode) {
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy