forked from ChomeNS/chomens-bot-java
some console fixes (more ohio) + wait until executorservice shut down
This commit is contained in:
parent
8b61ed93aa
commit
06a1ce9ef2
3 changed files with 16 additions and 12 deletions
|
@ -125,6 +125,17 @@ public class Main {
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}, 0, 1, TimeUnit.MINUTES);
|
}, 0, 1, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||||
|
try {
|
||||||
|
final boolean success = executorService.awaitTermination(3, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
if (!success) System.exit(1);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initializeBots() {
|
public static void initializeBots() {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package land.chipmunk.chayapak.chomens_bot.plugins;
|
package land.chipmunk.chayapak.chomens_bot.plugins;
|
||||||
|
|
||||||
import com.github.steveice10.packetlib.event.session.ConnectedEvent;
|
|
||||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||||
import land.chipmunk.chayapak.chomens_bot.Configuration;
|
import land.chipmunk.chayapak.chomens_bot.Configuration;
|
||||||
import land.chipmunk.chayapak.chomens_bot.Main;
|
import land.chipmunk.chayapak.chomens_bot.Main;
|
||||||
|
@ -24,8 +23,6 @@ public class ConsolePlugin implements Completer {
|
||||||
|
|
||||||
public String prefix;
|
public String prefix;
|
||||||
|
|
||||||
public Component formatPrefix;
|
|
||||||
|
|
||||||
private static final List<Listener> listeners = new ArrayList<>();
|
private static final List<Listener> listeners = new ArrayList<>();
|
||||||
|
|
||||||
public ConsolePlugin (List<Bot> allBots, Configuration discordConfig, JDA jda) {
|
public ConsolePlugin (List<Bot> allBots, Configuration discordConfig, JDA jda) {
|
||||||
|
@ -42,13 +39,6 @@ public class ConsolePlugin implements Completer {
|
||||||
|
|
||||||
bot.console = this;
|
bot.console = this;
|
||||||
|
|
||||||
bot.addListener(new Bot.Listener() {
|
|
||||||
@Override
|
|
||||||
public void connected(ConnectedEvent event) {
|
|
||||||
bot.console.formatPrefix = Component.text(bot.username + " Console").color(NamedTextColor.GRAY);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
bot.logger = new LoggerPlugin(bot);
|
bot.logger = new LoggerPlugin(bot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +104,7 @@ public class ConsolePlugin implements Completer {
|
||||||
bot.chat.tellraw(
|
bot.chat.tellraw(
|
||||||
Component.translatable(
|
Component.translatable(
|
||||||
"[%s] %s › %s",
|
"[%s] %s › %s",
|
||||||
formatPrefix,
|
Component.text(bot.username + " Console").color(NamedTextColor.GRAY),
|
||||||
Component.text(bot.config.ownerName).color(ColorUtilities.getColorByString(bot.config.colorPalette.ownerName)),
|
Component.text(bot.config.ownerName).color(ColorUtilities.getColorByString(bot.config.colorPalette.ownerName)),
|
||||||
Component.text(line).color(NamedTextColor.GRAY)
|
Component.text(line).color(NamedTextColor.GRAY)
|
||||||
).color(NamedTextColor.DARK_GRAY)
|
).color(NamedTextColor.DARK_GRAY)
|
||||||
|
|
|
@ -67,7 +67,10 @@ public class FormatCheckerPlugin extends ChatPlugin.Listener {
|
||||||
|
|
||||||
final Component prefix = format.args().get(0);
|
final Component prefix = format.args().get(0);
|
||||||
|
|
||||||
if (prefix.equals(bot.console.formatPrefix) || (bot.discord != null && prefix.equals(bot.discord.messagePrefix))) return false;
|
if (
|
||||||
|
((prefix instanceof TextComponent text) && text.content().equals(bot.username + " Console")) || // ohio
|
||||||
|
(bot.discord != null && prefix.equals(bot.discord.messagePrefix))
|
||||||
|
) return false;
|
||||||
|
|
||||||
if (!(prefix instanceof TranslatableComponent translatablePrefix)) return true;
|
if (!(prefix instanceof TranslatableComponent translatablePrefix)) return true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue