Migrated all EffectScript.ScriptType hooks to EnumScriptType

This commit is contained in:
bigguy345 committed 2026-01-22 20:48:17 +02:00
1 parent 50e9f1b3e5
commit d835d2acb0
5 files changed
+17 -31

No files matched your search

@@ -7,6 +7,7 @@ import noppes.npcs.EventHooks;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.handler.data.ICustomEffect;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.CustomEffectController;
import noppes.npcs.scripted.event.player.PlayerEvent;
@@ -193,7 +194,7 @@ public class CustomEffect implements ICustomEffect {
return;
}
script.callScript(EffectScript.ScriptType.OnEffectAdd, event);
script.callScript(EnumScriptType.ON_EFFECT_ADD, event);
}
EventHooks.onEffectAdded(iPlayer, playerEffect);
@@ -213,7 +214,7 @@ public class CustomEffect implements ICustomEffect {
return;
}
script.callScript(EffectScript.ScriptType.OnEffectTick, event);
script.callScript(EnumScriptType.ON_EFFECT_TICK, event);
}
EventHooks.onEffectTick(iPlayer, playerEffect);
@@ -234,7 +235,7 @@ public class CustomEffect implements ICustomEffect {
return;
}
script.callScript(EffectScript.ScriptType.OnEffectRemove, event);
script.callScript(EnumScriptType.ON_EFFECT_REMOVE, event);
}
EventHooks.onEffectRemove(iPlayer, playerEffect, type);
@@ -3,7 +3,6 @@ package noppes.npcs.controllers.data;
import kamkeel.npcs.network.packets.request.script.EffectScriptPacket;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.handler.IScriptHookHandler;
import noppes.npcs.scripted.event.player.PlayerEvent;
/**
* Script handler for CustomEffect scripts.
@@ -33,12 +32,6 @@ public class EffectScript extends SingleScriptHandler implements IScriptHandlerP
return IScriptHookHandler.CONTEXT_EFFECT;
}
/**
* Convenience method to call a script with a typed event.
*/
public void callScript(ScriptType type, PlayerEvent.EffectEvent event) {
callScript(type.function, event);
}
@Override
public void requestData() {
@@ -52,15 +45,4 @@ public class EffectScript extends SingleScriptHandler implements IScriptHandlerP
EffectScriptPacket.Save(effectId, index, totalCount, nbt);
}
public enum ScriptType {
OnEffectAdd("onEffectAdd"),
OnEffectTick("onEffectTick"),
OnEffectRemove("onEffectRemove");
public final String function;
ScriptType(String functionName) {
this.function = functionName;
}
}
}