Added console output and correct script halting to scripted player events. Renamed PlayerScriptContainer to EventScriptContainer.

This commit is contained in:
luisc committed 2021-10-17 16:11:29 -05:00
1 parent a9bce4a3e3
commit c5ed7497c8
9 files changed
+149 -130

No files matched your search

@@ -7,30 +7,20 @@ package noppes.npcs;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.TreeMap;
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import cpw.mods.fml.common.eventhandler.Event;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.IScriptHandler;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.scripted.constants.*;
public class PlayerScriptContainer {
public static PlayerScriptContainer Current;
public class EventScriptContainer {
public static EventScriptContainer Current;
public String type = "init";
public String fullscript = "";
public String script = "";
@@ -44,7 +34,7 @@ public class PlayerScriptContainer {
private CompiledScript compScript = null;
private boolean init = false;
public PlayerScriptContainer(IScriptHandler handler) {
public EventScriptContainer(IScriptHandler handler) {
this.handler = handler;
}
@@ -111,18 +101,17 @@ public class PlayerScriptContainer {
}
public void appandConsole(String message) {
if(message != null && !message.isEmpty()) {
if (message != null && !message.isEmpty()) {
long time = System.currentTimeMillis();
if(this.console.containsKey(Long.valueOf(time))) {
message = (String)this.console.get(Long.valueOf(time)) + "\n" + message;
if (this.console.containsKey(time)) {
message = (String)this.console.get(time) + "\n" + message;
}
this.console.put(Long.valueOf(time), message);
this.console.put(time, message);
while(this.console.size() > 40) {
this.console.remove(this.console.firstKey());
}
}
}
+4 -4
View File
@@ -408,12 +408,12 @@ public class NBTTags {
}
}
public static List<PlayerScriptContainer> GetScript(NBTTagList list, IScriptHandler handler) {
public static List<EventScriptContainer> GetScript(NBTTagList list, IScriptHandler handler) {
ArrayList scripts = new ArrayList();
for(int i = 0; i < list.tagCount(); ++i) {
NBTTagCompound compoundd = list.getCompoundTagAt(i);
PlayerScriptContainer script = new PlayerScriptContainer(handler);
EventScriptContainer script = new EventScriptContainer(handler);
script.readFromNBT(compoundd);
scripts.add(script);
}
@@ -421,12 +421,12 @@ public class NBTTags {
return scripts;
}
public static NBTTagList NBTScript(List<PlayerScriptContainer> scripts) {
public static NBTTagList NBTScript(List<EventScriptContainer> scripts) {
NBTTagList list = new NBTTagList();
Iterator var2 = scripts.iterator();
while(var2.hasNext()) {
PlayerScriptContainer script = (PlayerScriptContainer)var2.next();
EventScriptContainer script = (EventScriptContainer)var2.next();
NBTTagCompound compound = new NBTTagCompound();
script.writeToNBT(compound);
list.appendTag(compound);
@@ -62,6 +62,8 @@ import noppes.npcs.controllers.SpawnController;
import noppes.npcs.controllers.SpawnData;
import noppes.npcs.controllers.TransportController;
import noppes.npcs.controllers.TransportLocation;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobSpawner;
@@ -108,6 +110,8 @@ public class PacketHandlerServer{
featherPackets(type, buffer, player);
else if(type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
playerScriptPackets(type, buffer, player);
else if(type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)
forgeScriptPackets(type, buffer, player);
else if(item.getItem() == CustomItems.scripter)
scriptPackets(type, buffer, player, npc);
else if(item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock))
@@ -133,7 +137,8 @@ public class PacketHandlerServer{
private void playerScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
NBTTagCompound compound;
if(type == EnumPacketServer.ScriptPlayerGet) {
compound = ScriptController.Instance.playerScripts.writeToNBT(new NBTTagCompound());
PlayerDataScript data = ScriptController.Instance.playerScripts;
compound = data.writeToNBT(new NBTTagCompound());
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} else if(type == EnumPacketServer.ScriptPlayerSave) {
@@ -141,6 +146,18 @@ public class PacketHandlerServer{
}
}
private void forgeScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
NBTTagCompound compound;
if (type == EnumPacketServer.ScriptForgeGet) {
ForgeDataScript data = ScriptController.Instance.forgeScripts;
compound = data.writeToNBT(new NBTTagCompound());
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound});
} else if (type == EnumPacketServer.ScriptForgeSave) {
ScriptController.Instance.setForgeScripts(Server.readNBT(buffer));
}
}
private void featherPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
if(type == EnumPacketServer.DimensionsGet){
HashMap<String,Integer> map = new HashMap<String,Integer>();
@@ -322,10 +322,6 @@ public class ScriptPlayerEventHandler {
classes = classLoader.getName();
} while(classes.startsWith("net.minecraftforge.event.terraingen"));
if(classes.startsWith("cpw.mods.fml.common.gameevent")){
;
}
Class infoClass = classLoader.load();
ArrayList c = new ArrayList(Arrays.asList(infoClass.getDeclaredClasses()));
if(c.isEmpty()) {
@@ -18,19 +18,19 @@ import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.PlayerScriptContainer;
import noppes.npcs.EventScriptContainer;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.swing.GuiJTextArea;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.IScriptHandler;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.PlayerDataScript;
public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallback, IGuiData, ITextChangeListener, ICustomScrollListener, IJTextAreaListener {
private int activeTab = 0;
public PlayerDataScript handler;
public IScriptHandler handler;
public Map<String, List<String>> languages = new HashMap();
private int scriptLimit = 1;
@@ -57,36 +57,41 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
this.addTopButton(top = new GuiMenuTopButton(0, this.guiLeft + 4, this.guiTop - 17, "gui.settings"));
List<String> hookList = new ArrayList<String>();
hookList.add("playerscript.disabled");
hookList.add("playerscript.init");
hookList.add("playerscript.tick");
hookList.add("playerscript.interact");
hookList.add("playerscript.damaged");
hookList.add("playerscript.killed");
hookList.add("playerscript.kills");
hookList.add("playerscript.chat");
hookList.add("playerscript.drop");
hookList.add("playerscript.containerOpen");
hookList.add("playerscript.login");
hookList.add("playerscript.logout");
hookList.add("playerscript.chat");
hookList.add("playerscript.damagedentity");
hookList.add("playerscript.keyPressed");
hookList.add("playerscript.mouseClicked");
hookList.add("playerscript.pickUp");
hookList.add("playerscript.rangedLaunched");
hookList.add("playerscript.pickupXP");
hookList.add("playerscript.timer");
hookList.add("playerscript.startItem");
hookList.add("playerscript.usingItem");
hookList.add("playerscript.stopItem");
hookList.add("playerscript.finishItem");
hookList.add("playerscript.fall");
hookList.add("playerscript.playSound");
hookList.add("playerscript.lightning");
hookList.add("playerscript.break");
hookList.add("playerscript.changedDim");
hookList.add("playerscript.respawn");
if(handler instanceof PlayerDataScript) {
hookList.add("playerscript.disabled");
hookList.add("playerscript.init");
hookList.add("playerscript.tick");
hookList.add("playerscript.interact");
hookList.add("playerscript.damaged");
hookList.add("playerscript.killed");
hookList.add("playerscript.kills");
hookList.add("playerscript.chat");
hookList.add("playerscript.drop");
hookList.add("playerscript.containerOpen");
hookList.add("playerscript.login");
hookList.add("playerscript.logout");
hookList.add("playerscript.chat");
hookList.add("playerscript.damagedentity");
hookList.add("playerscript.keyPressed");
hookList.add("playerscript.mouseClicked");
hookList.add("playerscript.pickUp");
hookList.add("playerscript.rangedLaunched");
hookList.add("playerscript.pickupXP");
hookList.add("playerscript.timer");
hookList.add("playerscript.startItem");
hookList.add("playerscript.usingItem");
hookList.add("playerscript.stopItem");
hookList.add("playerscript.finishItem");
hookList.add("playerscript.fall");
hookList.add("playerscript.playSound");
hookList.add("playerscript.lightning");
hookList.add("playerscript.break");
hookList.add("playerscript.changedDim");
hookList.add("playerscript.respawn");
}
else if(handler instanceof ForgeDataScript){
hookList.add("forgescript.forgeInit");
}
int topXoffset = 0;
int topYoffset = 0;
@@ -121,7 +126,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
hooks.selected = getScriptHook(this.handler.getScripts().get(this.activeTab - 1),hookList);
addScroll(hooks);
PlayerScriptContainer var7 = (PlayerScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
EventScriptContainer var7 = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
GuiNpcTextArea left = new GuiNpcTextArea(2, this, this.guiLeft + 72 + yoffset, this.guiTop + yoffset, this.xSize - 180 - yoffset, (int)((double)this.ySize * 0.96D) - yoffset * 2, var7 == null?"":var7.script);
this.addTextField(left);
int left1 = this.guiLeft + this.xSize - 104;
@@ -170,9 +175,9 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
this.handler.getScripts().get(this.activeTab - 1).setType(scroll.getSelected().replace("playerscript.",""));
}
private int getScriptHook(PlayerScriptContainer playerScriptContainer, List<String> list) {
private int getScriptHook(EventScriptContainer eventScriptContainer, List<String> list) {
for(String s : list) {
if (s.replace("playerscript.", "").equals(playerScriptContainer.type)) {
if (s.replace("playerscript.", "").equals(eventScriptContainer.type)) {
return list.indexOf(s);
}
}
@@ -180,13 +185,13 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
}
private String getConsoleText() {
Map map = this.handler.getConsoleText();
Map<Long, String> map = this.handler.getConsoleText();
StringBuilder builder = new StringBuilder();
Iterator var3 = map.entrySet().iterator();
while(var3.hasNext()) {
Entry entry = (Entry)var3.next();
builder.insert(0, new Date(((Long)entry.getKey()).longValue()) + (String)entry.getValue() + "\n");
Entry<Long, String> entry = (Entry)var3.next();
builder.insert(0, new Date((Long)entry.getKey()) + (String)entry.getValue() + "\n");
}
return builder.toString();
@@ -241,7 +246,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
}
if(guibutton.id == scriptLimit) {
this.handler.getScripts().add(new PlayerScriptContainer(this.handler));
this.handler.getScripts().add(new EventScriptContainer(this.handler));
this.activeTab = this.handler.getScripts().size();
this.initGui();
}
@@ -270,10 +275,10 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
(this.getTextField(2)).setText(NoppesStringUtils.getClipboardContents());
}
PlayerScriptContainer container;
EventScriptContainer container;
if(guibutton.id == 102) {
if(this.activeTab > 0) {
container = (PlayerScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
container.script = "";
} else {
this.handler.clearConsole();
@@ -287,7 +292,6 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
}
if(guibutton.id == 104) {
//ScriptController.Instance.playerScripts.enabled = (((GuiNpcButton)guibutton).getValue() == 1);
this.handler.setEnabled((((GuiNpcButton)guibutton).getValue() == 1));
}
@@ -301,16 +305,16 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
}
if(guibutton.id == 107) {
container = (PlayerScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if(container == null) {
this.handler.getScripts().add(container = new PlayerScriptContainer(this.handler));
this.handler.getScripts().add(container = new EventScriptContainer(this.handler));
}
this.setSubGui(new EventGuiScriptList((List)this.languages.get(this.handler.getLanguage()), container));
}
if(guibutton.id == 108) {
container = (PlayerScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if(container != null) {
this.setScript();
this.AWTWindow = new GuiJTextArea(container.script).setListener(this);
@@ -321,15 +325,17 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
private void setScript() {
if(this.activeTab > 0) {
PlayerScriptContainer container = (PlayerScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
EventScriptContainer container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if(container == null) {
this.handler.getScripts().add(container = new PlayerScriptContainer(this.handler));
this.handler.getScripts().add(container = new EventScriptContainer(this.handler));
}
String text = (this.getTextField(2)).getText();
text = text.replace("\r\n", "\n");
text = text.replace("\r", "\n");
container.script = text;
ScriptController.Instance.playerScripts.errored.clear();
}
}
@@ -359,7 +365,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
}
public void textUpdate(String text) {
PlayerScriptContainer container = (PlayerScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
EventScriptContainer container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if(container != null) {
container.script = text;
}
@@ -368,7 +374,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
@Override
public void saveText(String text) {
PlayerScriptContainer container = handler.getScripts().get(activeTab);
EventScriptContainer container = handler.getScripts().get(activeTab);
if(container != null)
container.script = text;
initGui();
@@ -16,7 +16,6 @@ public class GuiScriptPlayers extends GuiScriptInterface {
public GuiScriptPlayers() {
this.handler = this.script;
//Client.sendData(EnumPacketServer.ScriptPlayerGet, new Object[0]);
Client.sendData(EnumPacketServer.ScriptPlayerGet);
}
@@ -27,7 +26,6 @@ public class GuiScriptPlayers extends GuiScriptInterface {
public void save() {
super.save();
//Client.sendData(EnumPacketServer.ScriptPlayerSave, new Object[]{this.script.writeToNBT(new NBTTagCompound())});
Client.sendData(EnumPacketServer.ScriptPlayerSave, script.writeToNBT(new NBTTagCompound()));
}
}
@@ -8,7 +8,7 @@ package noppes.npcs.controllers;
import java.util.List;
import java.util.Map;
import cpw.mods.fml.common.eventhandler.Event;
import noppes.npcs.PlayerScriptContainer;
import noppes.npcs.EventScriptContainer;
import noppes.npcs.constants.EnumScriptType;
public interface IScriptHandler {
@@ -24,7 +24,7 @@ public interface IScriptHandler {
void setLanguage(String var1);
List<PlayerScriptContainer> getScripts();
List<EventScriptContainer> getScripts();
String noticeString();
@@ -17,7 +17,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.EventHooks;
import noppes.npcs.PlayerScriptContainer;
import noppes.npcs.EventScriptContainer;
import noppes.npcs.NBTTags;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.IScriptHandler;
@@ -26,10 +26,9 @@ import noppes.npcs.controllers.ScriptController;
import javax.script.ScriptEngine;
public class ForgeDataScript implements IScriptHandler {
private List<PlayerScriptContainer> scripts = new ArrayList();
private List<EventScriptContainer> scripts = new ArrayList();
private String scriptLanguage = "ECMAScript";
public long lastInited = -1L;
public boolean hadInteract = true;
private boolean enabled = false;
public ForgeDataScript() {
@@ -58,7 +57,7 @@ public class ForgeDataScript implements IScriptHandler {
Minecraft.getMinecraft().func_152344_a(() -> {
if (ScriptController.Instance.lastLoaded > this.lastInited) {
this.lastInited = ScriptController.Instance.lastLoaded;
if (!type.equals("init")) {
if (!type.equals(EnumScriptType.FORGE_INIT)) {
EventHooks.onForgeInit(this);
}
}
@@ -66,7 +65,7 @@ public class ForgeDataScript implements IScriptHandler {
Iterator var3 = this.scripts.iterator();
while (var3.hasNext()) {
PlayerScriptContainer script = (PlayerScriptContainer) var3.next();
EventScriptContainer script = (EventScriptContainer) var3.next();
if(script.type != type.function)
continue;
@@ -102,7 +101,7 @@ public class ForgeDataScript implements IScriptHandler {
Iterator var3 = this.scripts.iterator();
while (var3.hasNext()) {
PlayerScriptContainer script = (PlayerScriptContainer) var3.next();
EventScriptContainer script = (EventScriptContainer) var3.next();
//script.run(EnumScriptType.valueOf(type), event);
script.setEngine(scriptLanguage);
@@ -140,7 +139,7 @@ public class ForgeDataScript implements IScriptHandler {
this.scriptLanguage = lang;
}
public List<PlayerScriptContainer> getScripts() {
public List<EventScriptContainer> getScripts() {
return this.scripts;
}
@@ -154,7 +153,7 @@ public class ForgeDataScript implements IScriptHandler {
Iterator var3 = this.getScripts().iterator();
while(var3.hasNext()) {
PlayerScriptContainer script = (PlayerScriptContainer)var3.next();
EventScriptContainer script = (EventScriptContainer)var3.next();
++tab;
Iterator var5 = script.console.entrySet().iterator();
@@ -171,7 +170,7 @@ public class ForgeDataScript implements IScriptHandler {
Iterator var1 = this.getScripts().iterator();
while(var1.hasNext()) {
PlayerScriptContainer script = (PlayerScriptContainer)var1.next();
EventScriptContainer script = (EventScriptContainer)var1.next();
script.console.clear();
}
@@ -18,7 +18,7 @@ import net.minecraft.util.math.BlockPos;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.world.WorldServer;
import noppes.npcs.EventHooks;
import noppes.npcs.PlayerScriptContainer;
import noppes.npcs.EventScriptContainer;
import noppes.npcs.NBTTags;
import noppes.npcs.scripted.ScriptPlayer;
import noppes.npcs.constants.EnumScriptType;
@@ -34,7 +34,7 @@ import javax.annotation.CheckForNull;
import javax.script.ScriptEngine;
public class PlayerDataScript implements IScriptHandler {
public List<PlayerScriptContainer> scripts = new ArrayList();
public List<EventScriptContainer> scripts = new ArrayList();
public String scriptLanguage = "ECMAScript";
private EntityPlayer player;
private ScriptPlayer playerAPI;
@@ -42,8 +42,8 @@ public class PlayerDataScript implements IScriptHandler {
public long lastInited = -1L;
public boolean hadInteract = true;
public boolean enabled = false;
private static Map<Long, String> console = new TreeMap();
private static List<Integer> errored = new ArrayList();
private Map<Long, String> console = new TreeMap();
public List<Integer> errored = new ArrayList();
public ScriptPlayer dummyPlayer;
public ScriptWorld dummyWorld;
@@ -62,8 +62,8 @@ public class PlayerDataScript implements IScriptHandler {
}
public void clear() {
console = new TreeMap();
errored = new ArrayList();
this.console = new TreeMap();
this.errored = new ArrayList();
this.scripts = new ArrayList();
}
@@ -71,30 +71,30 @@ public class PlayerDataScript implements IScriptHandler {
this.scripts = NBTTags.GetScript(compound.getTagList("Scripts", 10), this);
this.scriptLanguage = compound.getString("ScriptLanguage");
this.enabled = compound.getBoolean("ScriptEnabled");
console = NBTTags.GetLongStringMap(compound.getTagList("ScriptConsole", 10));
this.console = NBTTags.GetLongStringMap(compound.getTagList("ScriptConsole", 10));
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setTag("Scripts", NBTTags.NBTScript(this.scripts));
compound.setString("ScriptLanguage", this.scriptLanguage);
compound.setBoolean("ScriptEnabled", this.enabled);
compound.setTag("ScriptConsole", NBTTags.NBTLongStringMap(console));
compound.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.console));
return compound;
}
public void callScript(EnumScriptType type, Event event, Object... obs) {
if(this.isEnabled()) {
PlayerScriptContainer script;
EventScriptContainer script;
if(ScriptController.Instance.lastLoaded > this.lastInited || ScriptController.Instance.lastPlayerUpdate > this.lastPlayerUpdate) {
this.lastInited = ScriptController.Instance.lastLoaded;
errored.clear();
//ScriptController.Instance.playerScripts.errored.clear();
if(this.player != null) {
this.scripts.clear();
Iterator i = ScriptController.Instance.playerScripts.scripts.iterator();
while(i.hasNext()) {
script = (PlayerScriptContainer)i.next();
PlayerScriptContainer s = new PlayerScriptContainer(this);
script = (EventScriptContainer)i.next();
EventScriptContainer s = new EventScriptContainer(this);
s.readFromNBT(script.writeToNBT(new NBTTagCompound()));
this.scripts.add(s);
@@ -108,12 +108,12 @@ public class PlayerDataScript implements IScriptHandler {
}
for(int var7 = 0; var7 < this.scripts.size(); ++var7) {
script = (PlayerScriptContainer)this.scripts.get(var7);
script = (EventScriptContainer)this.scripts.get(var7);
if(!script.type.equals(type.function))
continue;
if(!errored.contains(Integer.valueOf(var7))) {
if(!ScriptController.Instance.playerScripts.errored.contains(Integer.valueOf(var7))) {
if(script == null || script.errored || !script.hasCode())
return;
script.setEngine(scriptLanguage);
@@ -136,9 +136,23 @@ public class PlayerDataScript implements IScriptHandler {
engine.put("RoleType", roles);
engine.put("JobType", jobs);
script.run(engine);
if (script.errored) {
ScriptController.Instance.playerScripts.errored.add(var7);
}
Iterator var8 = script.console.entrySet().iterator();
while(var8.hasNext()) {
Entry<Long, String> entry = (Entry)var8.next();
if (!ScriptController.Instance.playerScripts.console.containsKey(entry.getKey())) {
ScriptController.Instance.playerScripts.console.put(entry.getKey(), " tab " + (var7 + 1) + ":\n" + (String)entry.getValue());
}
}
script.console.clear();
}
}
}
}
@@ -167,10 +181,34 @@ public class PlayerDataScript implements IScriptHandler {
this.scriptLanguage = lang;
}
public List<PlayerScriptContainer> getScripts() {
public List<EventScriptContainer> getScripts() {
return this.scripts;
}
public String noticeString() {
if(this.player == null) {
return "Global script";
} else {
BlockPos pos = new BlockPos(this.player);
return PlayerDataScript.toStringHelper(this.player).add("x", pos.getX()).add("y", pos.getY()).add("z", pos.getZ()).toString();
}
}
public ScriptPlayer getPlayer() {
if(this.playerAPI == null) {
this.playerAPI = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(this.player);
}
return this.playerAPI;
}
public Map<Long, String> getConsoleText() {
return this.console;
}
public void clearConsole() {
this.console.clear();
}
public static final class ToStringHelper {
private final String className;
private final PlayerDataScript.ToStringHelper.ValueHolder holderHead;
@@ -367,28 +405,4 @@ public class PlayerDataScript implements IScriptHandler {
public static PlayerDataScript.ToStringHelper toStringHelper(Object self) {
return new PlayerDataScript.ToStringHelper(self.getClass().getSimpleName());
}
public String noticeString() {
if(this.player == null) {
return "Global script";
} else {
BlockPos pos = new BlockPos(this.player);
return PlayerDataScript.toStringHelper(this.player).add("x", pos.getX()).add("y", pos.getY()).add("z", pos.getZ()).toString();
}
}
public ScriptPlayer getPlayer() {
if(this.playerAPI == null) {
this.playerAPI = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(this.player);
}
return this.playerAPI;
}
public Map<Long, String> getConsoleText() {
return console;
}
public void clearConsole() {
console.clear();
}
}