Fix server start message not being displayed
This commit is contained in:
parent
4d234cf832
commit
61986c9b51
2 changed files with 10 additions and 4 deletions
|
@ -69,12 +69,16 @@ public class MCChatUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean notEnabled() {
|
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() {
|
private static MinecraftChatModule getModule() {
|
||||||
if (module == null) module = ComponentManager.getIfEnabled(MinecraftChatModule.class);
|
if (module == null || !module.isEnabled()) module = ComponentManager.getIfEnabled(MinecraftChatModule.class);
|
||||||
else if (!module.isEnabled()) module = null; //Reset if disabled
|
//If disabled, it will try to get it again because another instance may be enabled - useful for /discord restart
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +166,7 @@ public class MCChatUtils {
|
||||||
* @param hookmsg Whether the message is also sent from the hook
|
* @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) {
|
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();
|
if (notEnabled()) return Mono.empty();
|
||||||
var list = new ArrayList<Publisher<?>>();
|
var list = new ArrayList<Publisher<?>>();
|
||||||
if (!GeneralEventBroadcasterModule.isHooked() || !hookmsg)
|
if (!GeneralEventBroadcasterModule.isHooked() || !hookmsg)
|
||||||
|
|
|
@ -163,7 +163,7 @@ public class MinecraftChatModule extends Component<DiscordPlugin> {
|
||||||
serverWatcher.enableDisable(true);
|
serverWatcher.enableDisable(true);
|
||||||
log("Finished hooking into the server");
|
log("Finished hooking into the server");
|
||||||
} catch (Exception e) {
|
} 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
|
* It will block to make sure all messages are sent
|
||||||
*/
|
*/
|
||||||
private void sendStateMessage(Color color, String message) {
|
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)
|
MCChatUtils.forCustomAndAllMCChat(chan -> chan.flatMap(ch -> ch.createEmbed(ecs -> ecs.setColor(color)
|
||||||
.setTitle(message))), ChannelconBroadcast.RESTART, false).block();
|
.setTitle(message))), ChannelconBroadcast.RESTART, false).block();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue