From 61986c9b51f79b7a4d762563f96babe7427c7498 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 26 Oct 2020 22:56:13 +0100 Subject: [PATCH] Fix server start message not being displayed --- .../discordplugin/mcchat/MCChatUtils.java | 11 ++++++++--- .../discordplugin/mcchat/MinecraftChatModule.java | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/buttondevteam/discordplugin/mcchat/MCChatUtils.java b/src/main/java/buttondevteam/discordplugin/mcchat/MCChatUtils.java index d379437..95b4b61 100644 --- a/src/main/java/buttondevteam/discordplugin/mcchat/MCChatUtils.java +++ b/src/main/java/buttondevteam/discordplugin/mcchat/MCChatUtils.java @@ -69,12 +69,16 @@ public class MCChatUtils { } private static boolean notEnabled() { - return (module == null) || (!module.disabling && (getModule() == null)); //Allow using things while disabling the module + /*System.out.println("module: " + module); + if (module != null) + System.out.println("Disabling: " + module.disabling);*/ + //new Exception().printStackTrace(); + return (module == null || !module.disabling) && getModule() == null; //Allow using things while disabling the module } private static MinecraftChatModule getModule() { - if (module == null) module = ComponentManager.getIfEnabled(MinecraftChatModule.class); - else if (!module.isEnabled()) module = null; //Reset if disabled + if (module == null || !module.isEnabled()) module = ComponentManager.getIfEnabled(MinecraftChatModule.class); + //If disabled, it will try to get it again because another instance may be enabled - useful for /discord restart return module; } @@ -162,6 +166,7 @@ public class MCChatUtils { * @param hookmsg Whether the message is also sent from the hook */ public static Mono forCustomAndAllMCChat(Function, Mono> action, @Nullable ChannelconBroadcast toggle, boolean hookmsg) { + System.out.println("Not enabled: " + notEnabled()); if (notEnabled()) return Mono.empty(); var list = new ArrayList>(); if (!GeneralEventBroadcasterModule.isHooked() || !hookmsg) diff --git a/src/main/java/buttondevteam/discordplugin/mcchat/MinecraftChatModule.java b/src/main/java/buttondevteam/discordplugin/mcchat/MinecraftChatModule.java index 5ebad1b..40b820d 100644 --- a/src/main/java/buttondevteam/discordplugin/mcchat/MinecraftChatModule.java +++ b/src/main/java/buttondevteam/discordplugin/mcchat/MinecraftChatModule.java @@ -163,7 +163,7 @@ public class MinecraftChatModule extends Component { serverWatcher.enableDisable(true); log("Finished hooking into the server"); } catch (Exception e) { - TBMCCoreAPI.SendException("Failed to hack the server (object)!", e, this); + TBMCCoreAPI.SendException("Failed to hack the server (object)! Disable addFakePlayersToBukkit in the config.", e, this); } } @@ -241,6 +241,7 @@ public class MinecraftChatModule extends Component { * It will block to make sure all messages are sent */ private void sendStateMessage(Color color, String message) { + System.out.println("Sending message: " + message); MCChatUtils.forCustomAndAllMCChat(chan -> chan.flatMap(ch -> ch.createEmbed(ecs -> ecs.setColor(color) .setTitle(message))), ChannelconBroadcast.RESTART, false).block(); }