2021-09-30 21:44:30 -05:00
|
|
|
//
|
|
|
|
|
// Source code recreated from a .class file by IntelliJ IDEA
|
|
|
|
|
// (powered by FernFlower decompiler)
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
package noppes.npcs.client.gui.script;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2023-02-19 15:20:51 -06:00
|
|
|
import noppes.npcs.NBTTags;
|
2021-09-30 21:44:30 -05:00
|
|
|
import noppes.npcs.client.Client;
|
|
|
|
|
import noppes.npcs.constants.EnumPacketServer;
|
2023-02-19 13:38:43 -06:00
|
|
|
import noppes.npcs.controllers.ScriptContainer;
|
2021-10-18 06:33:39 -05:00
|
|
|
import noppes.npcs.controllers.ScriptController;
|
2021-10-11 06:49:30 -05:00
|
|
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
2021-09-30 21:44:30 -05:00
|
|
|
|
2023-02-19 13:38:43 -06:00
|
|
|
import java.util.List;
|
|
|
|
|
|
2021-09-30 21:44:30 -05:00
|
|
|
public class GuiScriptPlayers extends GuiScriptInterface {
|
2021-10-11 06:49:30 -05:00
|
|
|
private PlayerDataScript script = new PlayerDataScript((EntityPlayer)null);
|
2021-09-30 21:44:30 -05:00
|
|
|
|
|
|
|
|
public GuiScriptPlayers() {
|
|
|
|
|
this.handler = this.script;
|
2023-02-19 13:38:43 -06:00
|
|
|
Client.sendData(EnumPacketServer.ScriptPlayerGet);
|
2021-09-30 21:44:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setGuiData(NBTTagCompound compound) {
|
2023-02-19 13:38:43 -06:00
|
|
|
if (!compound.hasKey("Tab")) {
|
|
|
|
|
script.setLanguage(compound.getString("ScriptLanguage"));
|
|
|
|
|
script.setEnabled(compound.getBoolean("ScriptEnabled"));
|
2023-02-19 15:20:51 -06:00
|
|
|
script.setConsoleText(NBTTags.GetLongStringMap(compound.getTagList("ScriptConsole", 10)));
|
2023-02-19 13:38:43 -06:00
|
|
|
super.setGuiData(compound);
|
|
|
|
|
} else {
|
|
|
|
|
int tab = compound.getInteger("Tab");
|
|
|
|
|
ScriptContainer container = new ScriptContainer(script);
|
|
|
|
|
container.readFromNBT(compound.getCompoundTag("Script"));
|
|
|
|
|
if (script.getScripts().isEmpty()) {
|
|
|
|
|
for (int i = 0; i < compound.getInteger("TotalScripts"); i++) {
|
|
|
|
|
script.getScripts().add(new ScriptContainer(script));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
script.getScripts().set(tab,container);
|
|
|
|
|
initGui();
|
|
|
|
|
}
|
2021-09-30 21:44:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void save() {
|
|
|
|
|
super.save();
|
2023-02-19 13:38:43 -06:00
|
|
|
List<ScriptContainer> containers = this.script.getScripts();
|
|
|
|
|
for (int i = 0; i < containers.size(); i++) {
|
|
|
|
|
ScriptContainer container = containers.get(i);
|
|
|
|
|
Client.sendData(EnumPacketServer.ScriptPlayerSave, i, container.writeToNBT(new NBTTagCompound()));
|
|
|
|
|
}
|
|
|
|
|
NBTTagCompound scriptData = new NBTTagCompound();
|
|
|
|
|
scriptData.setString("ScriptLanguage", this.script.getLanguage());
|
|
|
|
|
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
|
2023-02-19 15:20:51 -06:00
|
|
|
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
|
2023-02-19 13:38:43 -06:00
|
|
|
Client.sendData(EnumPacketServer.ScriptPlayerSave, -1, scriptData);
|
2021-10-18 06:33:39 -05:00
|
|
|
}
|
2021-09-30 21:44:30 -05:00
|
|
|
}
|