mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 07:35:11 +00:00
Add a Pre-Load Boolean to Scripts to they don't save Empty
This commit is contained in:
1 parent
d119a7524e
commit
236b901e61
11 files changed
+129
-71
No files matched your search
@@ -230,6 +230,10 @@ public class PacketUtil {
|
||||
tabCompound.setInteger("TotalScripts", containers.size());
|
||||
GuiDataPacket.sendGuiData(player, tabCompound);
|
||||
}
|
||||
|
||||
NBTTagCompound loadComplete = new NBTTagCompound();
|
||||
loadComplete.setInteger("LoadComplete", 1);
|
||||
GuiDataPacket.sendGuiData(player, loadComplete);
|
||||
}
|
||||
|
||||
public static void saveScripts(IScriptHandler data, ByteBuf buffer) throws IOException {
|
||||
|
||||
@@ -27,6 +27,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
||||
public Map<String, List<String>> languages = new HashMap<String, List<String>>();
|
||||
|
||||
private static int activeConsole = 0;
|
||||
boolean loaded = false;
|
||||
|
||||
public GuiScript(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
@@ -258,12 +259,15 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
||||
}
|
||||
this.languages = languages;
|
||||
initGui();
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
setScript();
|
||||
NPCScriptPacket.Save(script.writeToNBT(new NBTTagCompound()));
|
||||
if(loaded){
|
||||
setScript();
|
||||
NPCScriptPacket.Save(script.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,6 +39,11 @@ public class GuiNPCEventScripts extends GuiScriptInterface {
|
||||
}
|
||||
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
if(compound.hasKey("LoadComplete")){
|
||||
loaded = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!compound.hasKey("Tab")) {
|
||||
script.setLanguage(compound.getString("ScriptLanguage"));
|
||||
script.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||
@@ -58,16 +63,18 @@ public class GuiNPCEventScripts extends GuiScriptInterface {
|
||||
}
|
||||
|
||||
public void save() {
|
||||
super.save();
|
||||
List<ScriptContainer> containers = this.script.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
ScriptContainer container = containers.get(i);
|
||||
EventScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||
if(loaded) {
|
||||
super.save();
|
||||
List<ScriptContainer> containers = this.script.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
ScriptContainer container = containers.get(i);
|
||||
EventScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
||||
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
||||
EventScriptPacket.Save(-1, containers.size(), scriptData);
|
||||
}
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
||||
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
||||
EventScriptPacket.Save(-1, containers.size(), scriptData);
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,11 @@ public class GuiScriptAllNPCs extends GuiScriptInterface {
|
||||
}
|
||||
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
if(compound.hasKey("LoadComplete")){
|
||||
loaded = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!compound.hasKey("Tab")) {
|
||||
script.setLanguage(compound.getString("ScriptLanguage"));
|
||||
script.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||
@@ -54,16 +59,18 @@ public class GuiScriptAllNPCs extends GuiScriptInterface {
|
||||
}
|
||||
|
||||
public void save() {
|
||||
super.save();
|
||||
List<ScriptContainer> containers = this.script.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
ScriptContainer container = containers.get(i);
|
||||
GlobalNPCScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||
if(loaded){
|
||||
super.save();
|
||||
List<ScriptContainer> containers = this.script.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
ScriptContainer container = containers.get(i);
|
||||
GlobalNPCScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
||||
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
||||
GlobalNPCScriptPacket.Save(-1, containers.size(), scriptData);
|
||||
}
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
||||
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
||||
GlobalNPCScriptPacket.Save(-1, containers.size(), scriptData);
|
||||
}
|
||||
}
|
||||
@@ -30,10 +30,13 @@ public class GuiScriptBlock extends GuiScriptInterface {
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
this.tileScripted.setNBT(compound);
|
||||
super.setGuiData(compound);
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
super.save();
|
||||
BlockScriptPacket.Save(tileScripted.xCoord, tileScripted.yCoord, tileScripted.zCoord, this.tileScripted.getNBT(new NBTTagCompound()));
|
||||
if(loaded) {
|
||||
super.save();
|
||||
BlockScriptPacket.Save(tileScripted.xCoord, tileScripted.yCoord, tileScripted.zCoord, this.tileScripted.getNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback
|
||||
public final GuiNPCManageEffects parent;
|
||||
public final CustomEffect effect;
|
||||
private final EffectScript scriptHandler;
|
||||
|
||||
boolean loaded = false;
|
||||
|
||||
public GuiScriptEffect(GuiNPCManageEffects parent, CustomEffect effect) {
|
||||
this.drawDefaultBackground = true;
|
||||
@@ -315,6 +315,11 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback
|
||||
}
|
||||
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
if(compound.hasKey("LoadComplete")){
|
||||
loaded = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!compound.hasKey("Tab")) {
|
||||
this.scriptHandler.setLanguage(compound.getString("ScriptLanguage"));
|
||||
this.scriptHandler.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||
@@ -326,7 +331,6 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback
|
||||
this.scriptHandler.container = container;
|
||||
this.initGui();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void copiedSetGuiData(NBTTagCompound compound) {
|
||||
@@ -350,19 +354,21 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback
|
||||
}
|
||||
|
||||
public void save() {
|
||||
this.setScript();
|
||||
if(loaded) {
|
||||
this.setScript();
|
||||
|
||||
List<ScriptContainer> containers = this.scriptHandler.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
ScriptContainer container = containers.get(i);
|
||||
EffectScriptPacket.Save(effect.id, i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||
List<ScriptContainer> containers = this.scriptHandler.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
ScriptContainer container = containers.get(i);
|
||||
EffectScriptPacket.Save(effect.id, i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
scriptData.setString("ScriptLanguage", this.scriptHandler.getLanguage());
|
||||
scriptData.setBoolean("ScriptEnabled", this.scriptHandler.getEnabled());
|
||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.scriptHandler.getConsoleText()));
|
||||
|
||||
EffectScriptPacket.Save(effect.id, -1, containers.size(), scriptData);
|
||||
}
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
scriptData.setString("ScriptLanguage", this.scriptHandler.getLanguage());
|
||||
scriptData.setBoolean("ScriptEnabled", this.scriptHandler.getEnabled());
|
||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.scriptHandler.getConsoleText()));
|
||||
|
||||
EffectScriptPacket.Save(effect.id, -1, containers.size(), scriptData);
|
||||
}
|
||||
|
||||
public void textUpdate(String text) {
|
||||
|
||||
@@ -65,6 +65,11 @@ public class GuiScriptForge extends GuiScriptInterface {
|
||||
}
|
||||
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
if(compound.hasKey("LoadComplete")){
|
||||
loaded = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!compound.hasKey("Tab")) {
|
||||
script.setLanguage(compound.getString("ScriptLanguage"));
|
||||
script.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||
@@ -84,16 +89,18 @@ public class GuiScriptForge extends GuiScriptInterface {
|
||||
}
|
||||
|
||||
public void save() {
|
||||
super.save();
|
||||
List<ScriptContainer> containers = this.script.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
ScriptContainer container = containers.get(i);
|
||||
ForgeScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||
if(loaded) {
|
||||
super.save();
|
||||
List<ScriptContainer> containers = this.script.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
ScriptContainer container = containers.get(i);
|
||||
ForgeScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
||||
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
||||
ForgeScriptPacket.Save(-1, containers.size(), scriptData);
|
||||
}
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
||||
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
||||
ForgeScriptPacket.Save(-1, containers.size(), scriptData);
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
||||
public Map<String, List<String>> languages = new HashMap();
|
||||
private int scriptLimit = 1;
|
||||
public List<String> hookList = new ArrayList<String>();
|
||||
protected boolean loaded = false;
|
||||
|
||||
public GuiScriptInterface() {
|
||||
this.drawDefaultBackground = true;
|
||||
@@ -338,7 +339,8 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
||||
}
|
||||
|
||||
public void save() {
|
||||
this.setScript();
|
||||
if(loaded)
|
||||
this.setScript();
|
||||
}
|
||||
|
||||
public void textUpdate(String text) {
|
||||
|
||||
@@ -44,12 +44,15 @@ public class GuiScriptItem extends GuiScriptInterface {
|
||||
this.item.setMCNbt(compound);
|
||||
this.item.loadScriptData();
|
||||
super.setGuiData(compound);
|
||||
loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
super.save();
|
||||
ItemScriptPacket.Save(this.item.getMCNbt());
|
||||
if(loaded) {
|
||||
super.save();
|
||||
ItemScriptPacket.Save(this.item.getMCNbt());
|
||||
}
|
||||
}
|
||||
|
||||
protected String getConsoleText() {
|
||||
|
||||
@@ -30,6 +30,7 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall
|
||||
public final GuiNPCManageLinked parent;
|
||||
public final LinkedItem linkedItem;
|
||||
private final LinkedItemScript scriptHandler;
|
||||
boolean loaded = false;
|
||||
|
||||
public GuiScriptLinkedItem(GuiNPCManageLinked parent, LinkedItem linkedItem) {
|
||||
this.drawDefaultBackground = true;
|
||||
@@ -326,6 +327,11 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall
|
||||
}
|
||||
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
if(compound.hasKey("LoadComplete")){
|
||||
loaded = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!compound.hasKey("Tab")) {
|
||||
this.scriptHandler.setLanguage(compound.getString("ScriptLanguage"));
|
||||
this.scriptHandler.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||
@@ -361,19 +367,21 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall
|
||||
}
|
||||
|
||||
public void save() {
|
||||
this.setScript();
|
||||
if(loaded) {
|
||||
this.setScript();
|
||||
|
||||
List<ScriptContainer> containers = this.scriptHandler.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
ScriptContainer container = containers.get(i);
|
||||
LinkedItemScriptPacket.Save(linkedItem.id, i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||
List<ScriptContainer> containers = this.scriptHandler.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
ScriptContainer container = containers.get(i);
|
||||
LinkedItemScriptPacket.Save(linkedItem.id, i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
scriptData.setString("ScriptLanguage", this.scriptHandler.getLanguage());
|
||||
scriptData.setBoolean("ScriptEnabled", this.scriptHandler.getEnabled());
|
||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.scriptHandler.getConsoleText()));
|
||||
|
||||
LinkedItemScriptPacket.Save(linkedItem.id, -1, containers.size(), scriptData);
|
||||
}
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
scriptData.setString("ScriptLanguage", this.scriptHandler.getLanguage());
|
||||
scriptData.setBoolean("ScriptEnabled", this.scriptHandler.getEnabled());
|
||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.scriptHandler.getConsoleText()));
|
||||
|
||||
LinkedItemScriptPacket.Save(linkedItem.id, -1, containers.size(), scriptData);
|
||||
}
|
||||
|
||||
public void textUpdate(String text) {
|
||||
|
||||
@@ -90,6 +90,11 @@ public class GuiScriptPlayers extends GuiScriptInterface {
|
||||
}
|
||||
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
if(compound.hasKey("LoadComplete")){
|
||||
loaded = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!compound.hasKey("Tab")) {
|
||||
script.setLanguage(compound.getString("ScriptLanguage"));
|
||||
script.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||
@@ -109,16 +114,18 @@ public class GuiScriptPlayers extends GuiScriptInterface {
|
||||
}
|
||||
|
||||
public void save() {
|
||||
super.save();
|
||||
List<ScriptContainer> containers = this.script.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
ScriptContainer container = containers.get(i);
|
||||
PlayerScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||
if(loaded) {
|
||||
super.save();
|
||||
List<ScriptContainer> containers = this.script.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
ScriptContainer container = containers.get(i);
|
||||
PlayerScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
||||
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
||||
PlayerScriptPacket.Save(-1, containers.size(), scriptData);
|
||||
}
|
||||
NBTTagCompound scriptData = new NBTTagCompound();
|
||||
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
||||
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
||||
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
||||
PlayerScriptPacket.Save(-1, containers.size(), scriptData);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user