mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 01:05:12 +00:00
Fixed item toss event not being cancellable. Setting a script container's engine doesn't happen on every script call now, reducing lag.
This commit is contained in:
1 parent
2ec6e5b753
commit
a0adf0d7bd
9 files changed
+28
-4
No files matched your search
@@ -241,6 +241,9 @@ public class PacketHandlerServer{
|
||||
}
|
||||
}
|
||||
data.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||
for (ScriptContainer container : data.getScripts()) {
|
||||
container.setEngine(data.getLanguage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ScriptItemEventHandler {
|
||||
try {
|
||||
if (event.entityItem.getEntityItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
|
||||
IItemCustom isw = ItemScripted.GetWrapper(event.entityItem.getEntityItem());
|
||||
EventHooks.onScriptItemTossed(isw, event.player, event.entityItem);
|
||||
event.setCanceled(EventHooks.onScriptItemTossed(isw, event.player, event.entityItem));
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ public class ScriptPlayerEventHandler {
|
||||
if(event.player.worldObj instanceof WorldServer) {
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
|
||||
EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem);
|
||||
event.setCanceled(EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,6 @@ public class ScriptContainer {
|
||||
if(errored || !hasCode() || unknownFunctions.contains(type) || !ConfigScript.ScriptingEnabled)
|
||||
return;
|
||||
|
||||
this.setEngine(handler.getLanguage());
|
||||
if(engine == null)
|
||||
return;
|
||||
if(ScriptController.Instance.lastLoaded > this.lastCreated){
|
||||
|
||||
@@ -72,11 +72,19 @@ public class DataScript implements IScriptHandler {
|
||||
this.scriptLanguage = "ECMAScript";
|
||||
}
|
||||
}
|
||||
|
||||
for (ScriptContainer container : this.scripts.values()) {
|
||||
container.setEngine(this.getLanguage());
|
||||
}
|
||||
|
||||
enabled = compound.getBoolean("ScriptEnabled");
|
||||
}
|
||||
|
||||
public void readEventsFromNBT(NBTTagCompound compound) {
|
||||
eventScripts = NBTTags.GetScript(compound,this);
|
||||
for (ScriptContainer container : this.eventScripts) {
|
||||
container.setEngine(this.getLanguage());
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
@@ -149,7 +157,6 @@ public class DataScript implements IScriptHandler {
|
||||
ScriptContainer script = scripts.get(type);
|
||||
if(script == null || script.errored || !script.hasCode())
|
||||
return false;
|
||||
script.setEngine(scriptLanguage);
|
||||
if(script.engine == null)
|
||||
return false;
|
||||
for(int i = 0; i + 1 < obs.length; i += 2){
|
||||
|
||||
@@ -46,6 +46,10 @@ public class ForgeDataScript implements IScriptHandler {
|
||||
}
|
||||
}
|
||||
this.enabled = compound.getBoolean("ScriptEnabled");
|
||||
|
||||
for (ScriptContainer container : this.scripts) {
|
||||
container.setEngine(this.getLanguage());
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
|
||||
@@ -49,6 +49,10 @@ public class GlobalNPCDataScript implements IScriptHandler {
|
||||
}
|
||||
}
|
||||
this.enabled = compound.getBoolean("ScriptEnabled");
|
||||
|
||||
for (ScriptContainer container : this.scripts) {
|
||||
container.setEngine(this.getLanguage());
|
||||
}
|
||||
}
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setInteger("TotalScripts",this.scripts.size());
|
||||
|
||||
@@ -55,6 +55,10 @@ public class PlayerDataScript implements IScriptHandler {
|
||||
}
|
||||
}
|
||||
this.enabled = compound.getBoolean("ScriptEnabled");
|
||||
|
||||
for (ScriptContainer container : this.scripts) {
|
||||
container.setEngine(this.getLanguage());
|
||||
}
|
||||
}
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setInteger("TotalScripts",this.scripts.size());
|
||||
|
||||
@@ -427,6 +427,9 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
|
||||
NBTTagCompound c = this.item.getTagCompound();
|
||||
if (c != null) {
|
||||
this.setScriptNBT(c.getCompoundTag("ScriptedData"));
|
||||
for (ScriptContainer container : this.scripts) {
|
||||
container.setEngine(this.getLanguage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user