mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-16 22:15:06 +00:00
Merged local and global NPC events, deleting old unused event classes.
This commit is contained in:
1 parent
8f16e6b20f
commit
9c29aabea8
11 files changed
+132
-350
No files matched your search
@@ -17,7 +17,6 @@ import noppes.npcs.controllers.IScriptHandler;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.entity.ScriptNpc;
|
||||
import noppes.npcs.scripted.event.ScriptEvent;
|
||||
import noppes.npcs.scripted.ScriptWorld;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
@@ -105,7 +104,7 @@ public class DataScript implements IScriptHandler {
|
||||
return list;
|
||||
}
|
||||
|
||||
public boolean callScript(EnumScriptType type, Object... obs){
|
||||
public boolean callScript(EnumScriptType type, Event event, Object... obs){
|
||||
if(aiNeedsUpdate){
|
||||
npc.updateAI = true;
|
||||
aiNeedsUpdate = false;
|
||||
@@ -116,10 +115,9 @@ public class DataScript implements IScriptHandler {
|
||||
}
|
||||
if(!isEnabled())
|
||||
return false;
|
||||
if(!hasInited && !npc.isRemote()){
|
||||
if(!hasInited && !npc.isRemote() && type != EnumScriptType.INIT){
|
||||
hasInited = true;
|
||||
EventHooks.onNPCInit(this.npc);
|
||||
callScript(EnumScriptType.INIT);
|
||||
}
|
||||
ScriptContainer script = scripts.get(type.ordinal());
|
||||
if(script == null || script.errored || !script.hasCode())
|
||||
@@ -134,16 +132,14 @@ public class DataScript implements IScriptHandler {
|
||||
script.engine.put(obs[i].toString(), ob);
|
||||
}
|
||||
|
||||
return callScript(script);
|
||||
return callScript(script, event);
|
||||
}
|
||||
|
||||
private boolean callScript(ScriptContainer script){
|
||||
private boolean callScript(ScriptContainer script, Event event){
|
||||
ScriptEngine engine = script.engine;
|
||||
engine.put("npc", dummyNpc);
|
||||
engine.put("world", dummyWorld);
|
||||
ScriptEvent result = (ScriptEvent) engine.get("event");
|
||||
if(result == null)
|
||||
engine.put("event", result = new ScriptEvent());
|
||||
engine.put("event", event);
|
||||
engine.put("API", new NpcAPI());
|
||||
engine.put("EntityType", entities);
|
||||
engine.put("RoleType", roles);
|
||||
@@ -158,17 +154,13 @@ public class DataScript implements IScriptHandler {
|
||||
npc.updateAI = true;
|
||||
aiNeedsUpdate = false;
|
||||
}
|
||||
return result.isCancelled();
|
||||
return event.isCanceled();
|
||||
}
|
||||
|
||||
public boolean isEnabled(){
|
||||
return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty();
|
||||
}
|
||||
|
||||
public void callScript(EnumScriptType var1, Event var2, Object... obs) {
|
||||
|
||||
}
|
||||
|
||||
public Map<Long, String> getConsoleText() {
|
||||
Map<Long, String> map = new TreeMap();
|
||||
int tab = 0;
|
||||
@@ -200,7 +192,7 @@ public class DataScript implements IScriptHandler {
|
||||
|
||||
@Override
|
||||
public void callScript(EnumScriptType var1, Event var2) {
|
||||
|
||||
callScript(var1, var2, "$$IGNORED$$", null);
|
||||
}
|
||||
|
||||
public boolean isClient() {
|
||||
|
||||
Reference in new issue
Block a user