From e45c77e7bae2bc6250b31d1d8e01bab75d7966ed Mon Sep 17 00:00:00 2001 From: Florian Rinke Date: Fri, 5 Nov 2021 21:23:36 +0100 Subject: Handle Fail more graceful --- src/main/java/de/torui/coflsky/CoflSkyCommand.java | 4 ++-- .../java/de/torui/coflsky/network/WSClientWrapper.java | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/de/torui/coflsky/CoflSkyCommand.java b/src/main/java/de/torui/coflsky/CoflSkyCommand.java index e48d131..6f182af 100644 --- a/src/main/java/de/torui/coflsky/CoflSkyCommand.java +++ b/src/main/java/de/torui/coflsky/CoflSkyCommand.java @@ -106,8 +106,8 @@ public class CoflSkyCommand extends CommandBase { Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Stopping Connection to CoflNet")); CoflSessionManager.DeleteAllCoflSessions(); Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Deleting CoflNet sessions...")); - CoflSky.Wrapper.startConnection(); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Started the Connection to CoflNet")); + if(CoflSky.Wrapper.startConnection()) + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Started the Connection to CoflNet")); } public String StatusMessage() { diff --git a/src/main/java/de/torui/coflsky/network/WSClientWrapper.java b/src/main/java/de/torui/coflsky/network/WSClientWrapper.java index f30d0f9..21f494f 100644 --- a/src/main/java/de/torui/coflsky/network/WSClientWrapper.java +++ b/src/main/java/de/torui/coflsky/network/WSClientWrapper.java @@ -13,7 +13,11 @@ import de.torui.coflsky.core.Command; import de.torui.coflsky.core.StringCommand; import de.torui.coflsky.minecraft_integration.PlayerDataProvider; import net.minecraft.client.Minecraft; +import net.minecraft.event.ClickEvent; +import net.minecraft.event.ClickEvent.Action; import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatStyle; +import net.minecraft.util.EnumChatFormatting; import de.torui.coflsky.minecraft_integration.CoflSessionManager; @@ -63,7 +67,17 @@ public class WSClientWrapper { } } - throw new Error("Could not connect to any websocket remote!"); + Minecraft.getMinecraft().thePlayer.addChatMessage( + new ChatComponentText("Cofl could not establish a connection to any server!"+ + "\nIf you think this is a bug. Please report it on our Discord and include the logs!") + .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)) + /*.appendSibling(new ChatComponentText("logs") + .setChatStyle(new ChatStyle() + .setChatClickEvent(new ClickEvent(Action.OPEN_URL, ""))))*/); + + return false; + //throw new Error("Could not connect to any websocket remote!"); + } -- cgit From 7c1eb7049159f0011f138c02788b2b630f5480a1 Mon Sep 17 00:00:00 2001 From: Florian Rinke Date: Fri, 5 Nov 2021 23:18:01 +0100 Subject: added link --- src/main/java/de/torui/coflsky/network/WSClientWrapper.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/de/torui/coflsky/network/WSClientWrapper.java b/src/main/java/de/torui/coflsky/network/WSClientWrapper.java index 21f494f..f1ca25b 100644 --- a/src/main/java/de/torui/coflsky/network/WSClientWrapper.java +++ b/src/main/java/de/torui/coflsky/network/WSClientWrapper.java @@ -69,11 +69,13 @@ public class WSClientWrapper { Minecraft.getMinecraft().thePlayer.addChatMessage( new ChatComponentText("Cofl could not establish a connection to any server!"+ - "\nIf you think this is a bug. Please report it on our Discord and include the logs!") + "\nIf you think this is a bug. Please report it on our Discord and include the ") .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)) - /*.appendSibling(new ChatComponentText("logs") + .appendSibling(new ChatComponentText("logs!") .setChatStyle(new ChatStyle() - .setChatClickEvent(new ClickEvent(Action.OPEN_URL, ""))))*/); + .setUnderlined(true) + .setColor(EnumChatFormatting.BLUE) + .setChatClickEvent(new ClickEvent(Action.OPEN_URL, "https://www.youtube.com/watch?v=9Kb29wEcMcs"))))); return false; //throw new Error("Could not connect to any websocket remote!"); -- cgit