diff options
-rw-r--r-- | src/main/java/de/torui/coflsky/WSCommandHandler.java | 6 | ||||
-rw-r--r-- | src/main/java/de/torui/coflsky/websocket/WSClientWrapper.java | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/main/java/de/torui/coflsky/WSCommandHandler.java b/src/main/java/de/torui/coflsky/WSCommandHandler.java index 4dbb500..bbc3021 100644 --- a/src/main/java/de/torui/coflsky/WSCommandHandler.java +++ b/src/main/java/de/torui/coflsky/WSCommandHandler.java @@ -80,7 +80,6 @@ public class WSCommandHandler { } else { style = new ChatStyle() .setChatClickEvent(new ClickEvent(Action.RUN_COMMAND, "/cofl callback " + wcmd.OnClick)); - lastOnClickEvent = "/cofl callback " + wcmd.OnClick; } comp.setChatStyle(style); } @@ -116,7 +115,12 @@ public class WSCommandHandler { IChatComponent comp = CommandToChatComponent(wcmd); if (comp != null) + { + if(wcmd.OnClick != null) + lastOnClickEvent = "/cofl callback " + wcmd.OnClick; Minecraft.getMinecraft().thePlayer.addChatMessage(comp); + } + } } diff --git a/src/main/java/de/torui/coflsky/websocket/WSClientWrapper.java b/src/main/java/de/torui/coflsky/websocket/WSClientWrapper.java index 30ec739..30e5bc8 100644 --- a/src/main/java/de/torui/coflsky/websocket/WSClientWrapper.java +++ b/src/main/java/de/torui/coflsky/websocket/WSClientWrapper.java @@ -133,7 +133,12 @@ public class WSClientWrapper { } public synchronized void SendMessage(Command cmd){ - this.socket.SendCommand(cmd); + if(this.isRunning) { + this.socket.SendCommand(cmd); + } else { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("tried sending a callback to coflnet but failed. the connection must be closed.")); + } + } public void SendMessage(StringCommand sc) { |