mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-28 04:25:38 +00:00
HUGE IScriptHandlerPacket merge.
All ScriptHandlers that send packets now directly define their data through the ScriptHandler class itself, NOT through their own GuiScript extended class.
This commit is contained in:
1 parent
3f8373d76f
commit
50e9f1b3e5
18 files changed
+323
-443
No files matched your search
@@ -1,65 +1,13 @@
|
||||
package noppes.npcs.client.gui.script;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.script.EventScriptPacket;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.api.handler.IScriptHookHandler;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
import noppes.npcs.controllers.ScriptHookController;
|
||||
import noppes.npcs.controllers.data.IScriptHandlerPacket;
|
||||
import noppes.npcs.controllers.data.DataScript;
|
||||
import noppes.npcs.controllers.data.IScriptUnit;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiNPCEventScripts extends GuiScriptInterface {
|
||||
private final DataScript script;
|
||||
|
||||
public GuiNPCEventScripts(EntityNPCInterface npc) {
|
||||
this.hookList = new ArrayList<>(ScriptHookController.Instance.getAllHooks(IScriptHookHandler.CONTEXT_NPC));
|
||||
this.script = new DataScript(npc);
|
||||
this.handler = this.script;
|
||||
EventScriptPacket.Get();
|
||||
}
|
||||
|
||||
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"));
|
||||
super.setGuiData(compound);
|
||||
} else {
|
||||
int tab = compound.getInteger("Tab");
|
||||
NBTTagCompound scriptCompound = compound.getCompoundTag("Script");
|
||||
IScriptUnit container = IScriptUnit.createFromNBT(scriptCompound, 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();
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (loaded) {
|
||||
super.save();
|
||||
List<IScriptUnit> containers = this.script.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
IScriptUnit 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);
|
||||
}
|
||||
this.handler = new DataScript(npc);
|
||||
if (this.handler instanceof IScriptHandlerPacket)
|
||||
((IScriptHandlerPacket) this.handler).requestData();
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package noppes.npcs.client.gui.script;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.script.GlobalNPCScriptPacket;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.api.handler.IScriptHookHandler;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
import noppes.npcs.controllers.ScriptHookController;
|
||||
import noppes.npcs.controllers.data.GlobalNPCDataScript;
|
||||
import noppes.npcs.controllers.data.IScriptUnit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiScriptAllNPCs extends GuiScriptInterface {
|
||||
private final GlobalNPCDataScript script = new GlobalNPCDataScript(null);
|
||||
|
||||
public GuiScriptAllNPCs() {
|
||||
this.hookList = new ArrayList<>(ScriptHookController.Instance.getAllHooks(IScriptHookHandler.CONTEXT_NPC));
|
||||
this.handler = this.script;
|
||||
GlobalNPCScriptPacket.Get();
|
||||
}
|
||||
|
||||
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"));
|
||||
super.setGuiData(compound);
|
||||
} else {
|
||||
int tab = compound.getInteger("Tab");
|
||||
NBTTagCompound scriptCompound = compound.getCompoundTag("Script");
|
||||
IScriptUnit container = IScriptUnit.createFromNBT(scriptCompound, 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();
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (loaded) {
|
||||
super.save();
|
||||
List<IScriptUnit> containers = this.script.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
IScriptUnit 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package noppes.npcs.client.gui.script;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.script.BlockScriptPacket;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.api.handler.IScriptHookHandler;
|
||||
import noppes.npcs.blocks.tiles.TileScripted;
|
||||
import noppes.npcs.constants.ScriptContext;
|
||||
import noppes.npcs.controllers.ScriptHookController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GuiScriptBlock extends GuiScriptInterface {
|
||||
private final TileScripted tileScripted;
|
||||
|
||||
public GuiScriptBlock(int x, int y, int z) {
|
||||
this.hookList = new ArrayList<>(ScriptHookController.Instance.getAllHooks(IScriptHookHandler.CONTEXT_BLOCK));
|
||||
|
||||
this.handler = this.tileScripted = (TileScripted) player.worldObj.getTileEntity(x, y, z);
|
||||
BlockScriptPacket.Get(tileScripted.xCoord, tileScripted.yCoord, tileScripted.zCoord);
|
||||
}
|
||||
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
this.tileScripted.setNBT(compound);
|
||||
super.setGuiData(compound);
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ScriptContext getScriptContext() {
|
||||
return ScriptContext.BLOCK;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (loaded) {
|
||||
super.save();
|
||||
BlockScriptPacket.Save(tileScripted.xCoord, tileScripted.yCoord, tileScripted.zCoord, this.tileScripted.getNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
package noppes.npcs.client.gui.script;
|
||||
|
||||
import com.google.common.reflect.ClassPath;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent;
|
||||
import kamkeel.npcs.network.packets.request.script.ForgeScriptPacket;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.event.world.ChunkDataEvent;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import net.minecraftforge.event.world.ChunkWatchEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.api.handler.IScriptHookHandler;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
import noppes.npcs.controllers.ScriptHookController;
|
||||
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||
import noppes.npcs.controllers.data.IScriptUnit;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiScriptForge extends GuiScriptInterface {
|
||||
private final ForgeDataScript script = new ForgeDataScript();
|
||||
|
||||
public GuiScriptForge() {
|
||||
// Add built-in "init" hook from controller
|
||||
hookList.addAll(ScriptHookController.Instance.getBuiltInHooks(IScriptHookHandler.CONTEXT_FORGE));
|
||||
|
||||
// Dynamically discover Forge event hooks
|
||||
ArrayList<ClassPath.ClassInfo> list = new ArrayList();
|
||||
try {
|
||||
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("cpw.mods.fml.common.gameevent"));
|
||||
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event"));
|
||||
list.removeAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event.terraingen"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (ClassPath.ClassInfo e1 : list) {
|
||||
ClassPath.ClassInfo classLoader = e1;
|
||||
Class infoClass = classLoader.load();
|
||||
ArrayList c = new ArrayList(Arrays.asList(infoClass.getDeclaredClasses()));
|
||||
if (c.isEmpty()) {
|
||||
c.add(infoClass);
|
||||
}
|
||||
Iterator var10 = c.iterator();
|
||||
while (var10.hasNext()) {
|
||||
Class c1 = (Class) var10.next();
|
||||
if (!EntityEvent.EntityConstructing.class.isAssignableFrom(c1) && !WorldEvent.PotentialSpawns.class.isAssignableFrom(c1) && !TickEvent.RenderTickEvent.class.isAssignableFrom(c1) && !TickEvent.ClientTickEvent.class.isAssignableFrom(c1) && !FMLNetworkEvent.ClientCustomPacketEvent.class.isAssignableFrom(c1) && !ItemTooltipEvent.class.isAssignableFrom(c1) && Event.class.isAssignableFrom(c1) && !Modifier.isAbstract(c1.getModifiers()) && Modifier.isPublic(c1.getModifiers()) && !ChunkEvent.class.isAssignableFrom(c1) && !ChunkWatchEvent.class.isAssignableFrom(c1) && !ChunkDataEvent.class.isAssignableFrom(c1)) {
|
||||
String eventName = c1.getName();
|
||||
int i = eventName.lastIndexOf(".");
|
||||
eventName = StringUtils.uncapitalize(eventName.substring(i + 1).replace("$", ""));
|
||||
|
||||
hookList.add(eventName);
|
||||
}
|
||||
}
|
||||
}
|
||||
hookList.add("onCNPCNaturalSpawn");
|
||||
|
||||
// Add any addon-registered hooks for the forge context
|
||||
for (String addonHook : ScriptHookController.Instance.getAddonHooks(IScriptHookHandler.CONTEXT_FORGE)) {
|
||||
if (!hookList.contains(addonHook)) {
|
||||
hookList.add(addonHook);
|
||||
}
|
||||
}
|
||||
|
||||
this.handler = this.script;
|
||||
ForgeScriptPacket.Get();
|
||||
}
|
||||
|
||||
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"));
|
||||
super.setGuiData(compound);
|
||||
} else {
|
||||
int tab = compound.getInteger("Tab");
|
||||
NBTTagCompound scriptCompound = compound.getCompoundTag("Script");
|
||||
IScriptUnit container = IScriptUnit.createFromNBT(scriptCompound, 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();
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (loaded) {
|
||||
super.save();
|
||||
List<IScriptUnit> containers = this.script.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
IScriptUnit 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,9 @@ import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.IGuiData;
|
||||
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||
import noppes.npcs.controllers.data.GlobalNPCDataScript;
|
||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -65,13 +68,13 @@ public class GuiScriptGlobal extends GuiNPCInterface implements IGuiData {
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
if (guibutton.id == 0) {
|
||||
this.displayGuiScreen(new GuiScriptPlayers());
|
||||
GuiScriptInterface.open(this, new PlayerDataScript(null));
|
||||
}
|
||||
if (guibutton.id == 1) {
|
||||
this.displayGuiScreen(new GuiScriptForge());
|
||||
GuiScriptInterface.open(this, new ForgeDataScript());
|
||||
}
|
||||
if (guibutton.id == 2) {
|
||||
this.displayGuiScreen(new GuiScriptAllNPCs());
|
||||
GuiScriptInterface.open(this, new GlobalNPCDataScript(null));
|
||||
}
|
||||
if (guibutton.id > 2) {
|
||||
try {
|
||||
|
||||
@@ -88,10 +88,10 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a GuiScriptInterface for a single script without a handler.
|
||||
* Wraps the script in a SingleScriptHandler automatically.
|
||||
* Create a GuiScriptInterface for a handler without displaying it.
|
||||
* Useful when a caller needs to return a GuiScreen (e.g. ClientProxy).
|
||||
*/
|
||||
public static GuiScriptInterface open(GuiScreen parent, IScriptHandler handler) {
|
||||
public static GuiScriptInterface create(GuiScreen parent, IScriptHandler handler) {
|
||||
GuiScriptInterface gui = new GuiScriptInterface();
|
||||
gui.handler = handler;
|
||||
gui.parent = parent;
|
||||
@@ -103,6 +103,15 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
||||
if (handler instanceof IScriptHandlerPacket)
|
||||
((IScriptHandlerPacket) handler).requestData();
|
||||
|
||||
return gui;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a GuiScriptInterface for a handler.
|
||||
* Wraps the script in a SingleScriptHandler automatically.
|
||||
*/
|
||||
public static GuiScriptInterface open(GuiScreen parent, IScriptHandler handler) {
|
||||
GuiScriptInterface gui = create(parent, handler);
|
||||
Minecraft.getMinecraft().displayGuiScreen(gui);
|
||||
return gui;
|
||||
}
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
package noppes.npcs.client.gui.script;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.script.item.ItemScriptErrorPacket;
|
||||
import kamkeel.npcs.network.packets.request.script.item.ItemScriptPacket;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.api.handler.IScriptHookHandler;
|
||||
import noppes.npcs.constants.ScriptContext;
|
||||
import noppes.npcs.controllers.ScriptHookController;
|
||||
import noppes.npcs.scripted.item.ScriptCustomItem;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class GuiScriptItem extends GuiScriptInterface {
|
||||
private ScriptCustomItem item;
|
||||
public static Map<Long, String> consoleText = new HashMap<>();
|
||||
|
||||
public GuiScriptItem() {
|
||||
this.hookList = new ArrayList<>(ScriptHookController.Instance.getAllHooks(IScriptHookHandler.CONTEXT_ITEM));
|
||||
|
||||
this.handler = this.item = new ScriptCustomItem(new ItemStack(CustomItems.scripted_item));
|
||||
ItemScriptErrorPacket.Get();
|
||||
ItemScriptPacket.Get();
|
||||
}
|
||||
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
if (compound.hasKey("ItemScriptConsole")) {
|
||||
consoleText = NBTTags.GetLongStringMap(compound.getTagList("ItemScriptConsole", 10));
|
||||
initGui();
|
||||
} else {
|
||||
this.item.setMCNbt(compound);
|
||||
this.item.loadScriptData();
|
||||
super.setGuiData(compound);
|
||||
loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ScriptContext getScriptContext() {
|
||||
return ScriptContext.ITEM;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (loaded) {
|
||||
super.save();
|
||||
ItemScriptPacket.Save(this.item.getMCNbt());
|
||||
}
|
||||
}
|
||||
|
||||
protected String getConsoleText() {
|
||||
Map<Long, String> map = consoleText;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Iterator var3 = map.entrySet().iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
Map.Entry<Long, String> entry = (Map.Entry) var3.next();
|
||||
builder.insert(0, new Date((Long) entry.getKey()) + (String) entry.getValue() + "\n");
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public void confirmClicked(boolean flag, int i) {
|
||||
if (i == 102) {
|
||||
if (activeTab <= 0) {
|
||||
consoleText = new HashMap<>();
|
||||
ItemScriptErrorPacket.Clear();
|
||||
}
|
||||
}
|
||||
super.confirmClicked(flag, i);
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package noppes.npcs.client.gui.script;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.script.PlayerScriptPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.api.handler.IScriptHookHandler;
|
||||
import noppes.npcs.constants.ScriptContext;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
import noppes.npcs.controllers.ScriptHookController;
|
||||
import noppes.npcs.controllers.data.IScriptUnit;
|
||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiScriptPlayers extends GuiScriptInterface {
|
||||
private PlayerDataScript script = new PlayerDataScript((EntityPlayer) null);
|
||||
|
||||
public GuiScriptPlayers() {
|
||||
this.hookList = new ArrayList<>(ScriptHookController.Instance.getAllHooks(IScriptHookHandler.CONTEXT_PLAYER));
|
||||
|
||||
this.handler = this.script;
|
||||
PlayerScriptPacket.Get();
|
||||
}
|
||||
|
||||
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"));
|
||||
super.setGuiData(compound);
|
||||
} else {
|
||||
int tab = compound.getInteger("Tab");
|
||||
NBTTagCompound scriptCompound = compound.getCompoundTag("Script");
|
||||
IScriptUnit container = IScriptUnit.createFromNBT(scriptCompound, 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();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ScriptContext getScriptContext() {
|
||||
return ScriptContext.PLAYER;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (loaded) {
|
||||
super.save();
|
||||
List<IScriptUnit> containers = this.script.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
IScriptUnit 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user