mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 05:15:11 +00:00
Rename to Effect Script
This commit is contained in:
1 parent
b434600cbe
commit
8d2ffdc5e3
5 files changed
+23
-24
No files matched your search
@@ -16,7 +16,7 @@ import noppes.npcs.config.ConfigDebug;
|
||||
import noppes.npcs.config.ConfigScript;
|
||||
import noppes.npcs.controllers.CustomEffectController;
|
||||
import noppes.npcs.controllers.data.CustomEffect;
|
||||
import noppes.npcs.controllers.data.EffectScriptHandler;
|
||||
import noppes.npcs.controllers.data.EffectScript;
|
||||
import noppes.npcs.controllers.data.IScriptHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -81,7 +81,7 @@ public final class EffectScriptPacket extends AbstractPacket {
|
||||
if(effect == null)
|
||||
return;
|
||||
|
||||
EffectScriptHandler data = effect.getOrCreateScriptHandler();
|
||||
EffectScript data = effect.getOrCreateScriptHandler();
|
||||
if(requestedAction == Action.GET){
|
||||
PacketUtil.getScripts((IScriptHandler) data, (EntityPlayerMP) player);
|
||||
} else {
|
||||
|
||||
@@ -16,7 +16,7 @@ import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.data.CustomEffect;
|
||||
import noppes.npcs.controllers.data.EffectScriptHandler;
|
||||
import noppes.npcs.controllers.data.EffectScript;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback
|
||||
|
||||
public final GuiNPCManageEffects parent;
|
||||
public final CustomEffect effect;
|
||||
private final EffectScriptHandler scriptHandler;
|
||||
private final EffectScript scriptHandler;
|
||||
|
||||
|
||||
public GuiScriptEffect(GuiNPCManageEffects parent, CustomEffect effect) {
|
||||
@@ -41,9 +41,9 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback
|
||||
|
||||
this.parent = parent;
|
||||
this.effect = effect;
|
||||
this.scriptHandler = new EffectScriptHandler();
|
||||
this.scriptHandler = new EffectScript();
|
||||
|
||||
for (EffectScriptHandler.ScriptType type : EffectScriptHandler.ScriptType.values()) {
|
||||
for (EffectScript.ScriptType type : EffectScript.ScriptType.values()) {
|
||||
this.hookList.add(type.function);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package noppes.npcs.controllers;
|
||||
|
||||
import kamkeel.npcs.controllers.SyncController;
|
||||
import kamkeel.npcs.network.enums.EnumSyncType;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -15,7 +14,7 @@ import noppes.npcs.api.handler.ICustomEffectHandler;
|
||||
import noppes.npcs.api.handler.data.ICustomEffect;
|
||||
import noppes.npcs.controllers.data.CustomEffect;
|
||||
import noppes.npcs.controllers.data.EffectKey;
|
||||
import noppes.npcs.controllers.data.EffectScriptHandler;
|
||||
import noppes.npcs.controllers.data.EffectScript;
|
||||
import noppes.npcs.controllers.data.PlayerEffect;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
@@ -37,7 +36,7 @@ public class CustomEffectController implements ICustomEffectHandler {
|
||||
public HashMap<Integer, CustomEffect> customEffectsSync = new HashMap<>();
|
||||
public HashMap<Integer, CustomEffect> customEffects = new HashMap<>();
|
||||
|
||||
public HashMap<Integer, EffectScriptHandler> customEffectScriptHandlers = new HashMap<>();
|
||||
public HashMap<Integer, EffectScript> customEffectScriptHandlers = new HashMap<>();
|
||||
private HashMap<Integer, String> bootOrder;
|
||||
|
||||
private int lastUsedID = 0;
|
||||
|
||||
@@ -184,12 +184,12 @@ public class CustomEffect implements ICustomEffect {
|
||||
|
||||
PlayerEvent.EffectEvent.Added event = new PlayerEvent.EffectEvent.Added(iPlayer, playerEffect);
|
||||
if (onAddedConsumer != null) onAddedConsumer.accept(event);
|
||||
EffectScriptHandler script = getScriptHandler();
|
||||
EffectScript script = getScriptHandler();
|
||||
if (script == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
script.callScript(EffectScriptHandler.ScriptType.OnAdd, event);
|
||||
script.callScript(EffectScript.ScriptType.OnAdd, event);
|
||||
}
|
||||
|
||||
public void onTick(EntityPlayer player, PlayerEffect playerEffect) {
|
||||
@@ -200,12 +200,12 @@ public class CustomEffect implements ICustomEffect {
|
||||
onTickConsumer.accept(event);
|
||||
}
|
||||
|
||||
EffectScriptHandler script = getScriptHandler();
|
||||
EffectScript script = getScriptHandler();
|
||||
if (script == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
script.callScript(EffectScriptHandler.ScriptType.OnTick, event);
|
||||
script.callScript(EffectScript.ScriptType.OnTick, event);
|
||||
}
|
||||
|
||||
public void onRemoved(EntityPlayer player, PlayerEffect playerEffect, PlayerEvent.EffectEvent.ExpirationType type) {
|
||||
@@ -217,12 +217,12 @@ public class CustomEffect implements ICustomEffect {
|
||||
onRemovedConsumer.accept(event);
|
||||
}
|
||||
|
||||
EffectScriptHandler script = getScriptHandler();
|
||||
EffectScript script = getScriptHandler();
|
||||
if (script == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
script.callScript(EffectScriptHandler.ScriptType.OnRemove, event);
|
||||
script.callScript(EffectScript.ScriptType.OnRemove, event);
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(boolean saveScripts) {
|
||||
@@ -242,7 +242,7 @@ public class CustomEffect implements ICustomEffect {
|
||||
// if (saveScripts && scriptContainer != null) {
|
||||
if (saveScripts) {
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
EffectScriptHandler handler = getScriptHandler();
|
||||
EffectScript handler = getScriptHandler();
|
||||
if (handler != null)
|
||||
handler.writeToNBT(scriptData);
|
||||
compound.setTag("ScriptData", scriptData);
|
||||
@@ -282,7 +282,7 @@ public class CustomEffect implements ICustomEffect {
|
||||
lossOnDeath = compound.getBoolean("lossOnDeath");
|
||||
|
||||
if (compound.hasKey("ScriptData", Constants.NBT.TAG_COMPOUND)) {
|
||||
EffectScriptHandler handler = new EffectScriptHandler();
|
||||
EffectScript handler = new EffectScript();
|
||||
handler.readFromNBT(compound.getCompoundTag("ScriptData"));
|
||||
setScriptHandler(handler);
|
||||
}
|
||||
@@ -296,17 +296,17 @@ public class CustomEffect implements ICustomEffect {
|
||||
return newEffect;
|
||||
}
|
||||
|
||||
public EffectScriptHandler getScriptHandler() {
|
||||
public EffectScript getScriptHandler() {
|
||||
return CustomEffectController.getInstance().customEffectScriptHandlers.get(this.id);
|
||||
}
|
||||
public void setScriptHandler(EffectScriptHandler handler) {
|
||||
public void setScriptHandler(EffectScript handler) {
|
||||
CustomEffectController.getInstance().customEffectScriptHandlers.put(this.id, handler);
|
||||
}
|
||||
|
||||
public EffectScriptHandler getOrCreateScriptHandler() {
|
||||
EffectScriptHandler data = getScriptHandler();
|
||||
public EffectScript getOrCreateScriptHandler() {
|
||||
EffectScript data = getScriptHandler();
|
||||
if (data == null)
|
||||
setScriptHandler(data =new EffectScriptHandler());
|
||||
setScriptHandler(data =new EffectScript());
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ import javax.script.ScriptEngine;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class EffectScriptHandler implements IScriptHandler {
|
||||
public class EffectScript implements IScriptHandler {
|
||||
public ScriptContainer container;
|
||||
public String scriptLanguage = "ECMAScript";
|
||||
public boolean enabled = false;
|
||||
@@ -31,7 +31,7 @@ public class EffectScriptHandler implements IScriptHandler {
|
||||
return compound;
|
||||
}
|
||||
|
||||
public EffectScriptHandler readFromNBT(NBTTagCompound compound) {
|
||||
public EffectScript readFromNBT(NBTTagCompound compound) {
|
||||
scriptLanguage = compound.getString("ScriptLanguage");
|
||||
enabled = compound.getBoolean("ScriptEnabled");
|
||||
|
||||
Reference in new issue
Block a user