mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 01:27:27 +00:00
Fix for the global script GUI menu.
This commit is contained in:
1 parent
aa9a9499aa
commit
89ac9f5225
4 files changed
+55
-5
No files matched your search
@@ -126,6 +126,8 @@ public class PacketHandlerServer{
|
||||
forgeScriptPackets(type, buffer, player);
|
||||
else if (type == EnumPacketServer.ScriptItemDataGet || type == EnumPacketServer.ScriptItemDataSave)
|
||||
itemScriptPackets(type, buffer, player);
|
||||
else if (type == EnumPacketServer.ScriptGlobalGuiDataGet || type == EnumPacketServer.ScriptGlobalGuiDataSave)
|
||||
getScriptsEnabled(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))
|
||||
@@ -141,6 +143,24 @@ public class PacketHandlerServer{
|
||||
NoppesUtilServer.isGUIOpen(buffer, player);
|
||||
}
|
||||
|
||||
private void getScriptsEnabled(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
if (type == EnumPacketServer.ScriptGlobalGuiDataGet) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("ScriptsEnabled", CustomNpcs.GlobalPlayerScripts);
|
||||
compound.setBoolean("PlayerScriptsEnabled", CustomNpcs.GlobalPlayerScripts);
|
||||
compound.setBoolean("GlobalNPCScriptsEnabled", CustomNpcs.GlobalNPCScripts);
|
||||
compound.setBoolean("ForgeScriptsEnabled", CustomNpcs.GlobalForgeScripts);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
else if (type == EnumPacketServer.ScriptGlobalGuiDataSave) {
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
CustomNpcs.GlobalPlayerScripts = compound.getBoolean("ScriptsEnabled");
|
||||
CustomNpcs.GlobalPlayerScripts = compound.getBoolean("PlayerScriptsEnabled");
|
||||
CustomNpcs.GlobalNPCScripts = compound.getBoolean("GlobalNPCScriptsEnabled");
|
||||
CustomNpcs.GlobalForgeScripts = compound.getBoolean("ForgeScriptsEnabled");
|
||||
}
|
||||
}
|
||||
|
||||
private void scriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws Exception {
|
||||
if(type == EnumPacketServer.ScriptDataSave){
|
||||
npc.script.readFromNBT(Server.readNBT(buffer));
|
||||
|
||||
@@ -6,13 +6,16 @@
|
||||
package noppes.npcs.client.gui.script;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.IGuiData;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiScriptGlobal extends GuiNPCInterface {
|
||||
public class GuiScriptGlobal extends GuiNPCInterface implements IGuiData {
|
||||
private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/smallbg.png");
|
||||
|
||||
public GuiScriptGlobal() {
|
||||
@@ -24,16 +27,20 @@ public class GuiScriptGlobal extends GuiNPCInterface {
|
||||
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
Client.sendData(EnumPacketServer.ScriptGlobalGuiDataGet, new Object[0]);
|
||||
}
|
||||
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
GuiNpcButton playerButton = new GuiNpcButton(0, this.guiLeft + 38, this.guiTop + 20, 100, 20, "Players");
|
||||
playerButton.setEnabled(CustomNpcs.GlobalPlayerScripts && CustomNpcs.ScriptingEnabled);
|
||||
playerButton.setEnabled(compound.getBoolean("PlayerScriptsEnabled") && compound.getBoolean("ScriptsEnabled"));
|
||||
this.addButton(playerButton);
|
||||
|
||||
GuiNpcButton forgeButton = new GuiNpcButton(1, this.guiLeft + 38, this.guiTop + 50, 100, 20, "Forge");
|
||||
forgeButton.setEnabled(CustomNpcs.GlobalForgeScripts && CustomNpcs.ScriptingEnabled);
|
||||
forgeButton.setEnabled(compound.getBoolean("ForgeScriptsEnabled") && compound.getBoolean("ScriptsEnabled"));
|
||||
this.addButton(forgeButton);
|
||||
|
||||
GuiNpcButton npcButton = new GuiNpcButton(2, this.guiLeft + 38, this.guiTop + 80, 100, 20, "All NPCs");
|
||||
npcButton.setEnabled(CustomNpcs.GlobalNPCScripts && CustomNpcs.ScriptingEnabled);
|
||||
npcButton.setEnabled(compound.getBoolean("GlobalNPCScriptsEnabled") && compound.getBoolean("ScriptsEnabled"));
|
||||
this.addButton(npcButton);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@ public enum EnumPacketServer {
|
||||
|
||||
ClonePreSave(CustomNpcsPermissions.NPC_CLONE), CloneSave(CustomNpcsPermissions.NPC_CLONE), CloneRemove(CustomNpcsPermissions.NPC_CLONE), CloneList,
|
||||
|
||||
ScriptGlobalGuiDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||
ScriptGlobalGuiDataGet(false),
|
||||
|
||||
ScriptPlayerSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||
ScriptPlayerGet(false),
|
||||
|
||||
|
||||
@@ -320,6 +320,26 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
return new ScriptGui(id, width, height, pauseGame);
|
||||
}
|
||||
|
||||
public boolean arePlayerScriptsEnabled() {
|
||||
return CustomNpcs.GlobalPlayerScripts;
|
||||
}
|
||||
public boolean areForgeScriptsEnabled() {
|
||||
return CustomNpcs.GlobalForgeScripts;
|
||||
}
|
||||
public boolean areGlobalNPCScriptsEnabled() {
|
||||
return CustomNpcs.GlobalNPCScripts;
|
||||
}
|
||||
|
||||
public void enablePlayerScripts(boolean enable) {
|
||||
CustomNpcs.GlobalPlayerScripts = enable;
|
||||
}
|
||||
public void enableForgeScripts(boolean enable) {
|
||||
CustomNpcs.GlobalForgeScripts = enable;
|
||||
}
|
||||
public void enableGlobalNPCScripts(boolean enable) {
|
||||
CustomNpcs.GlobalNPCScripts = enable;
|
||||
}
|
||||
|
||||
public ICustomOverlay createCustomOverlay(int id) {
|
||||
return new ScriptOverlay(id);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user