package com.thebrokenrail.gestus.mixin;

import com.thebrokenrail.gestus.emote.EmoteRegistry;
import net.minecraft.resource.ReloadableResourceManager;
import net.minecraft.resource.ServerResourceManager;
import net.minecraft.server.command.CommandManager;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ServerResourceManager.class)
public class MixinServerResourceManager {
    @Shadow @Final private ReloadableResourceManager resourceManager;

    @Inject(at = @At("RETURN"), method = "<init>")
    public void init(CommandManager.RegistrationEnvironment registrationEnvironment, int i, CallbackInfo info) {
        resourceManager.registerListener(EmoteRegistry.ReloadListener.INSTANCE);
    }
}
