Fix ConsoleInjector not getting reinjecting on reload (#5149)

This commit is contained in:
Josh Roy 2022-11-11 18:28:55 -05:00 committed by GitHub
parent 22a0d53cf2
commit 6e931b2b3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -392,7 +392,7 @@ public class JDADiscordService implements DiscordService, IEssentialsModule {
shutdownConsoleRelay(false);
consoleWebhook = DiscordUtil.getWebhookClient(webhookId, webhookToken, jda.getHttpClient());
if (injector == null) {
if (injector == null || injector.isRemoved()) {
injector = new ConsoleInjector(this);
injector.start();
}

View File

@ -27,6 +27,7 @@ public class ConsoleInjector extends AbstractAppender {
private final JDADiscordService jda;
private final BlockingQueue<String> messageQueue = new LinkedBlockingQueue<>();
private final int taskId;
private boolean removed = false;
public ConsoleInjector(JDADiscordService jda) {
super("EssentialsX-ConsoleInjector", null, null, false);
@ -93,5 +94,10 @@ public class ConsoleInjector extends AbstractAppender {
((Logger) LogManager.getRootLogger()).removeAppender(this);
Bukkit.getScheduler().cancelTask(taskId);
messageQueue.clear();
removed = true;
}
public boolean isRemoved() {
return removed;
}
}