mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-16 15:24:46 +00:00
Fixed script console not appearing with the new global script tab saving method.
This commit is contained in:
1 parent
79e13dfade
commit
de6375c4cb
10 files changed
+58
-47
No files matched your search
@@ -210,6 +210,7 @@ public class PacketHandlerServer{
|
||||
compound.setBoolean("ScriptEnabled", data.getEnabled());
|
||||
compound.setString("ScriptLanguage", data.getLanguage());
|
||||
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
|
||||
compound.setTag("ScriptConsole", NBTTags.NBTLongStringMap(data.getConsoleText()));
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
List<ScriptContainer> containers = data.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
@@ -238,6 +239,7 @@ public class PacketHandlerServer{
|
||||
}
|
||||
}
|
||||
data.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||
data.setConsoleText(NBTTags.GetLongStringMap(compound.getTagList("ScriptConsole", 10)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package noppes.npcs.client.gui.script;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
@@ -20,6 +21,7 @@ public class GuiScriptAllNPCs extends GuiScriptInterface {
|
||||
if (!compound.hasKey("Tab")) {
|
||||
script.setLanguage(compound.getString("ScriptLanguage"));
|
||||
script.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||
script.setConsoleText(NBTTags.GetLongStringMap(compound.getTagList("ScriptConsole", 10)));
|
||||
super.setGuiData(compound);
|
||||
} else {
|
||||
int tab = compound.getInteger("Tab");
|
||||
@@ -45,6 +47,7 @@ public class GuiScriptAllNPCs extends GuiScriptInterface {
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
||||
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
||||
Client.sendData(EnumPacketServer.ScriptNPCSave, -1, scriptData);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
package noppes.npcs.client.gui.script;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
@@ -25,6 +26,7 @@ public class GuiScriptForge extends GuiScriptInterface {
|
||||
if (!compound.hasKey("Tab")) {
|
||||
script.setLanguage(compound.getString("ScriptLanguage"));
|
||||
script.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||
script.setConsoleText(NBTTags.GetLongStringMap(compound.getTagList("ScriptConsole", 10)));
|
||||
super.setGuiData(compound);
|
||||
} else {
|
||||
int tab = compound.getInteger("Tab");
|
||||
@@ -50,6 +52,7 @@ public class GuiScriptForge extends GuiScriptInterface {
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
||||
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
||||
Client.sendData(EnumPacketServer.ScriptForgeSave, -1, scriptData);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ package noppes.npcs.client.gui.script;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
@@ -27,6 +28,7 @@ public class GuiScriptPlayers extends GuiScriptInterface {
|
||||
if (!compound.hasKey("Tab")) {
|
||||
script.setLanguage(compound.getString("ScriptLanguage"));
|
||||
script.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||
script.setConsoleText(NBTTags.GetLongStringMap(compound.getTagList("ScriptConsole", 10)));
|
||||
super.setGuiData(compound);
|
||||
} else {
|
||||
int tab = compound.getInteger("Tab");
|
||||
@@ -52,6 +54,7 @@ public class GuiScriptPlayers extends GuiScriptInterface {
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
||||
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
||||
Client.sendData(EnumPacketServer.ScriptPlayerSave, -1, scriptData);
|
||||
}
|
||||
}
|
||||
@@ -173,6 +173,8 @@ public class DataScript implements IScriptHandler {
|
||||
return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty() && ConfigScript.ScriptingEnabled;
|
||||
}
|
||||
|
||||
public void setConsoleText(Map<Long, String> map) {}
|
||||
|
||||
public Map<Long, String> getConsoleText() {
|
||||
Map<Long, String> map = new TreeMap();
|
||||
int tab = 0;
|
||||
|
||||
@@ -22,12 +22,14 @@ public class ForgeDataScript implements IScriptHandler {
|
||||
private String scriptLanguage = "ECMAScript";
|
||||
public long lastInited = -1L;
|
||||
private boolean enabled = false;
|
||||
private Map<Long, String> console = new TreeMap();
|
||||
|
||||
public ForgeDataScript() {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.scripts = new ArrayList();
|
||||
this.console = new TreeMap();
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
@@ -45,6 +47,7 @@ public class ForgeDataScript implements IScriptHandler {
|
||||
}
|
||||
}
|
||||
this.enabled = compound.getBoolean("ScriptEnabled");
|
||||
this.console = NBTTags.GetLongStringMap(compound.getTagList("ScriptConsole", 10));
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
@@ -54,6 +57,7 @@ public class ForgeDataScript implements IScriptHandler {
|
||||
}
|
||||
compound.setString("ScriptLanguage", this.scriptLanguage);
|
||||
compound.setBoolean("ScriptEnabled", this.enabled);
|
||||
compound.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.console));
|
||||
return compound;
|
||||
}
|
||||
|
||||
@@ -71,8 +75,16 @@ public class ForgeDataScript implements IScriptHandler {
|
||||
}
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (ScriptContainer script : this.scripts) {
|
||||
script.run(type, event);
|
||||
|
||||
for (Entry<Long, String> longStringEntry : script.console.entrySet()) {
|
||||
if (!ScriptController.Instance.forgeScripts.console.containsKey(longStringEntry.getKey())) {
|
||||
ScriptController.Instance.forgeScripts.console.put(longStringEntry.getKey(), " tab " + (i + 1) + ":\n" + longStringEntry.getValue());
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,32 +121,14 @@ public class ForgeDataScript implements IScriptHandler {
|
||||
return "ForgeScript";
|
||||
}
|
||||
|
||||
public Map<Long, String> getConsoleText() {
|
||||
TreeMap map = new TreeMap();
|
||||
int tab = 0;
|
||||
Iterator var3 = this.getScripts().iterator();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
ScriptContainer script = (ScriptContainer)var3.next();
|
||||
++tab;
|
||||
Iterator var5 = script.console.entrySet().iterator();
|
||||
|
||||
while(var5.hasNext()) {
|
||||
Entry entry = (Entry)var5.next();
|
||||
map.put(entry.getKey(), " tab " + tab + ":\n" + (String)entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
public void setConsoleText(Map<Long, String> map) {
|
||||
this.console = map;
|
||||
}
|
||||
|
||||
public Map<Long, String> getConsoleText() {
|
||||
return this.console;
|
||||
}
|
||||
public void clearConsole() {
|
||||
Iterator var1 = this.getScripts().iterator();
|
||||
|
||||
while(var1.hasNext()) {
|
||||
ScriptContainer script = (ScriptContainer)var1.next();
|
||||
script.console.clear();
|
||||
}
|
||||
|
||||
this.console.clear();
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,8 @@ public interface IScriptHandler {
|
||||
|
||||
String noticeString();
|
||||
|
||||
void setConsoleText(Map<Long, String> map);
|
||||
|
||||
Map<Long, String> getConsoleText();
|
||||
|
||||
void clearConsole();
|
||||
|
||||
@@ -69,8 +69,16 @@ public class NPCDataScript implements IScriptHandler {
|
||||
this.lastInited = ScriptController.Instance.lastLoaded;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (ScriptContainer script : this.scripts) {
|
||||
script.run(type, event);
|
||||
|
||||
for (Map.Entry<Long, String> longStringEntry : script.console.entrySet()) {
|
||||
if (!ScriptController.Instance.npcScripts.console.containsKey(longStringEntry.getKey())) {
|
||||
ScriptController.Instance.npcScripts.console.put(longStringEntry.getKey(), " tab " + (i + 1) + ":\n" + longStringEntry.getValue());
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,35 +119,18 @@ public class NPCDataScript implements IScriptHandler {
|
||||
return this.npcAPI;
|
||||
}
|
||||
|
||||
public void setConsoleText(Map<Long, String> map) {
|
||||
this.console = map;
|
||||
}
|
||||
|
||||
public Map<Long, String> getConsoleText() {
|
||||
TreeMap map = new TreeMap();
|
||||
int tab = 0;
|
||||
Iterator var3 = this.getScripts().iterator();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
ScriptContainer script = (ScriptContainer)var3.next();
|
||||
++tab;
|
||||
Iterator var5 = script.console.entrySet().iterator();
|
||||
|
||||
while(var5.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry)var5.next();
|
||||
map.put(entry.getKey(), " tab " + tab + ":\n" + (String)entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
return this.console;
|
||||
}
|
||||
|
||||
public void clearConsole() {
|
||||
Iterator var1 = this.getScripts().iterator();
|
||||
|
||||
while(var1.hasNext()) {
|
||||
ScriptContainer script = (ScriptContainer)var1.next();
|
||||
script.console.clear();
|
||||
}
|
||||
|
||||
this.console.clear();
|
||||
}
|
||||
|
||||
public static final class ToStringHelper {
|
||||
private final String className;
|
||||
private final NPCDataScript.ToStringHelper.ValueHolder holderHead;
|
||||
|
||||
@@ -148,12 +148,19 @@ public class PlayerDataScript implements IScriptHandler {
|
||||
}
|
||||
return this.playerAPI;
|
||||
}
|
||||
|
||||
public void setConsoleText(Map<Long, String> map) {
|
||||
this.console = map;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -151,6 +151,10 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
|
||||
return "ScriptedItem";
|
||||
}
|
||||
|
||||
public void setConsoleText(Map<Long, String> map) {
|
||||
this.console = map;
|
||||
}
|
||||
|
||||
public Map<Long, String> getConsoleText() {
|
||||
return this.console;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user