mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 16:55:12 +00:00
ScriptWorld:
-Added functions from patch
This commit is contained in:
1 parent
f6b9f2c973
commit
dd7714350d
7 files changed
+12
-36
No files matched your search
@@ -241,9 +241,6 @@ public class PacketHandlerServer{
|
||||
}
|
||||
}
|
||||
data.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||
for (ScriptContainer container : data.getScripts()) {
|
||||
container.setEngine(data.getLanguage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,8 +150,10 @@ 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){
|
||||
this.lastCreated = ScriptController.Instance.lastLoaded;
|
||||
evaluated = false;
|
||||
@@ -232,14 +234,13 @@ public class ScriptContainer {
|
||||
}
|
||||
|
||||
public void setEngine(String scriptLanguage) {
|
||||
if(currentScriptLanguage != null && currentScriptLanguage.equals(scriptLanguage))
|
||||
return;
|
||||
if (ConfigScript.ScriptingECMA6 && scriptLanguage.equals("ECMAScript")) {
|
||||
System.setProperty("nashorn.args", "--language=es6");
|
||||
if (!Objects.equals(scriptLanguage, this.currentScriptLanguage)) {
|
||||
this.currentScriptLanguage = scriptLanguage;
|
||||
if (ConfigScript.ScriptingECMA6 && scriptLanguage.equals("ECMAScript")) {
|
||||
System.setProperty("nashorn.args", "--language=es6");
|
||||
}
|
||||
this.engine = ScriptController.Instance.getEngineByName(scriptLanguage.toLowerCase());
|
||||
this.evaluated = false;
|
||||
}
|
||||
this.engine = ScriptController.Instance.getEngineByName(scriptLanguage.toLowerCase());
|
||||
|
||||
currentScriptLanguage = scriptLanguage;
|
||||
evaluated = false;
|
||||
}
|
||||
}
|
||||
@@ -73,18 +73,11 @@ public class DataScript implements IScriptHandler {
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -157,8 +150,11 @@ public class DataScript implements IScriptHandler {
|
||||
ScriptContainer script = scripts.get(type);
|
||||
if(script == null || script.errored || !script.hasCode())
|
||||
return false;
|
||||
|
||||
script.setEngine(this.getLanguage());
|
||||
if(script.engine == null)
|
||||
return false;
|
||||
|
||||
for(int i = 0; i + 1 < obs.length; i += 2){
|
||||
Object ob = obs[i + 1];
|
||||
if(ob instanceof Entity)
|
||||
|
||||
@@ -46,10 +46,6 @@ 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,10 +49,6 @@ 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,10 +55,6 @@ 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());
|
||||
|
||||
@@ -413,18 +413,12 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
|
||||
}
|
||||
|
||||
c.setTag("ScriptedData", this.getScriptNBT(new NBTTagCompound()));
|
||||
for (ScriptContainer container : this.scripts) {
|
||||
container.setEngine(this.getLanguage());
|
||||
}
|
||||
}
|
||||
|
||||
public void loadScriptData() {
|
||||
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