Fix server start message not being displayed

This commit is contained in:
Norbi Peti 2020-10-26 22:56:13 +01:00
parent 4d234cf832
commit 61986c9b51
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
2 changed files with 10 additions and 4 deletions

View file

@ -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<MessageChannel>, Mono<?>> action, @Nullable ChannelconBroadcast toggle, boolean hookmsg) {
System.out.println("Not enabled: " + notEnabled());
if (notEnabled()) return Mono.empty();
var list = new ArrayList<Publisher<?>>();
if (!GeneralEventBroadcasterModule.isHooked() || !hookmsg)

View file

@ -163,7 +163,7 @@ public class MinecraftChatModule extends Component<DiscordPlugin> {
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<DiscordPlugin> {
* 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();
}