mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 18:49:39 +00:00
Compress Script Hooks and Context System
This commit is contained in:
1 parent
e2ca76e626
commit
19b01e2099
17 files changed
+595
-770
No files matched your search
@@ -3,22 +3,24 @@ 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.constants.ScriptContext;
|
||||
import noppes.npcs.scripted.event.player.PlayerEvent;
|
||||
|
||||
/**
|
||||
* Script handler for CustomEffect scripts.
|
||||
* Manages a single script container for effect hooks (onEffectAdd, onEffectTick, onEffectRemove).
|
||||
*/
|
||||
public class EffectScript extends SingleScriptHandler implements IScriptHandlerPacket {
|
||||
|
||||
|
||||
/** The effect ID for packet communication. -1 if not bound to an effect. */
|
||||
private int effectId = -1;
|
||||
|
||||
|
||||
/**
|
||||
* Create an unbound EffectScript (for server-side use).
|
||||
*/
|
||||
public EffectScript() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an EffectScript bound to a specific effect (for GUI use).
|
||||
* @param effectId The ID of the CustomEffect
|
||||
@@ -26,22 +28,27 @@ public class EffectScript extends SingleScriptHandler implements IScriptHandlerP
|
||||
public EffectScript(int effectId) {
|
||||
this.effectId = effectId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getHookContext() {
|
||||
return IScriptHookHandler.CONTEXT_EFFECT;
|
||||
public ScriptContext getContext() {
|
||||
return ScriptContext.EFFECT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String noticeString() {
|
||||
return effectId >= 0 ? "CustomEffect[" + effectId + "]" : "CustomEffect";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void requestData() {
|
||||
if (effectId >= 0)
|
||||
if (effectId >= 0)
|
||||
EffectScriptPacket.Get(effectId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendSavePacket(int index, int totalCount, NBTTagCompound nbt) {
|
||||
if (effectId >= 0)
|
||||
if (effectId >= 0)
|
||||
EffectScriptPacket.Save(effectId, index, totalCount, nbt);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user