diff --git a/src/main/java/techreborn/client/gui/GuiIDSU.java b/src/main/java/techreborn/client/gui/GuiIDSU.java index 95d197ef1..f39a61d4c 100644 --- a/src/main/java/techreborn/client/gui/GuiIDSU.java +++ b/src/main/java/techreborn/client/gui/GuiIDSU.java @@ -8,6 +8,7 @@ import net.minecraft.world.World; import techreborn.client.container.ContainerIDSU; import techreborn.cofhLib.gui.GuiBase; import techreborn.cofhLib.gui.element.ElementListBox; +import techreborn.cofhLib.gui.element.ElementTextField; import techreborn.cofhLib.gui.element.ElementTextFieldLimited; import techreborn.cofhLib.gui.element.listbox.ListBoxElementText; import techreborn.packets.PacketHandler; @@ -15,6 +16,7 @@ import techreborn.packets.PacketIdsu; import techreborn.tiles.idsu.ClientSideIDSUManager; import techreborn.tiles.idsu.IDSUManager; import techreborn.tiles.idsu.TileIDSU; +import techreborn.util.LogHelper; public class GuiIDSU extends GuiBase { @@ -26,6 +28,7 @@ public class GuiIDSU extends GuiBase { ElementListBox listBox; ElementTextFieldLimited idFeild; + ElementTextField nameFeild; public GuiIDSU(EntityPlayer player, @@ -83,6 +86,9 @@ public class GuiIDSU extends GuiBase { addElement(idFeild); + nameFeild = new ElementTextField(this, 10, 100, 50, 10); + + addElement(nameFeild); } @@ -90,7 +96,28 @@ public class GuiIDSU extends GuiBase { @Override protected void actionPerformed(GuiButton button) { super.actionPerformed(button); - PacketHandler.sendPacketToServer(new PacketIdsu(button.id, idsu, Integer.parseInt(idFeild.getText()), "TestName")); + if(isInteger(idFeild.getText())){ + PacketHandler.sendPacketToServer(new PacketIdsu(button.id, idsu, Integer.parseInt(idFeild.getText()), nameFeild.getText())); + } else { + LogHelper.info("There was an issue in the gui!, Please report this to the TechReborn Devs"); + } + + } + + public static boolean isInteger(String s) { + return isInteger(s,10); + } + + public static boolean isInteger(String s, int radix) { + if(s.isEmpty()) return false; + for(int i = 0; i < s.length(); i++) { + if(i == 0 && s.charAt(i) == '-') { + if(s.length() == 1) return false; + else continue; + } + if(Character.digit(s.charAt(i),radix) < 0) return false; + } + return true; } } \ No newline at end of file diff --git a/src/main/java/techreborn/packets/PacketIdsu.java b/src/main/java/techreborn/packets/PacketIdsu.java index 63b8e5b05..1da7ea014 100644 --- a/src/main/java/techreborn/packets/PacketIdsu.java +++ b/src/main/java/techreborn/packets/PacketIdsu.java @@ -26,9 +26,6 @@ public class PacketIdsu extends SimplePacket { this.buttonID = buttonID; this.channel = channel; this.newName = newName; - if(this.newName.equals("")){ - this.newName = "BLANK!!!"; - } } @Override diff --git a/src/main/java/techreborn/tiles/idsu/TileIDSU.java b/src/main/java/techreborn/tiles/idsu/TileIDSU.java index 7aabb28a3..e0431838e 100644 --- a/src/main/java/techreborn/tiles/idsu/TileIDSU.java +++ b/src/main/java/techreborn/tiles/idsu/TileIDSU.java @@ -11,10 +11,8 @@ public class TileIDSU extends TileMachineBase { public void handleGuiInputFromClient(int buttonID, int channel, EntityPlayer player, String name) { if(buttonID == 4){ channelID = channel; - IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, channel);//Do this to init the save data :) - if(name != "BLANK!!!"){ - IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, channel).name = name; - } + IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, channel).name = name; + IDSUManager.INSTANCE.getWorldDataFormWorld(worldObj).save(); if(worldObj.isRemote){ PacketHandler.sendPacketToPlayer(IDSUManager.INSTANCE.getPacket(worldObj, player), player); }