Skip to content

Commit c73f60b

Browse files
committed
Always unregister events before interrupting
1 parent 7ef17ca commit c73f60b

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/main/java/net/clementraynaud/skoice/system/ListenerManager.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public void update(User user) {
9191
} else if (oldStatus == BotStatus.READY && newStatus != BotStatus.READY) {
9292
this.unregisterMinecraftListeners();
9393
if (newStatus != BotStatus.NOT_CONNECTED) {
94-
this.unregisterBotListeners();
9594
new InterruptSystemTask(this.plugin).run();
9695
}
9796
}
@@ -139,7 +138,7 @@ public void registerBotListeners() {
139138
);
140139
}
141140

142-
private void unregisterBotListeners() {
141+
public void unregisterBotListeners() {
143142
this.plugin.getBot().getJDA().removeEventListener(
144143
this.guildVoiceGuildMuteListener,
145144
this.guildVoiceUpdateListener,

src/main/java/net/clementraynaud/skoice/tasks/InterruptSystemTask.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ public InterruptSystemTask(Skoice plugin) {
4343
public void run() {
4444
ThreadUtil.ensureNotMainThread(true);
4545

46+
this.plugin.getListenerManager().unregisterBotListeners();
4647
this.plugin.getUpdateNetworksTask().interrupt();
4748

4849
Guild guild = this.plugin.getBot().getGuild();
49-
5050
if (guild != null
5151
&& guild.getSelfMember().hasPermission(Permission.ADMINISTRATOR)
5252
&& (guild.getRequiredMFALevel() != Guild.MFALevel.TWO_FACTOR_AUTH

0 commit comments

Comments
 (0)