fix: tick plugin breaking when there's an exception
This commit is contained in:
parent
e4970cc56b
commit
efd837db36
2 changed files with 19 additions and 3 deletions
|
@ -86,7 +86,9 @@ public class DiscordPlugin {
|
|||
bot.tick.addListener(new TickPlugin.Listener() {
|
||||
@Override
|
||||
public void onAlwaysTick () {
|
||||
onDiscordTick(channelId);
|
||||
try {
|
||||
onDiscordTick(channelId);
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -18,11 +18,25 @@ public class TickPlugin {
|
|||
}
|
||||
|
||||
private void tick () {
|
||||
for (Listener listener : listeners) listener.onAlwaysTick();
|
||||
for (Listener listener : listeners) {
|
||||
try {
|
||||
listener.onAlwaysTick();
|
||||
} catch (Exception e) {
|
||||
bot.logger.error("Caught exception in an always tick listener!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (!bot.loggedIn) return;
|
||||
|
||||
for (Listener listener : listeners) listener.onTick();
|
||||
for (Listener listener : listeners) {
|
||||
try {
|
||||
listener.onTick();
|
||||
} catch (Exception e) {
|
||||
bot.logger.error("Caught exception in a tick listener!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addListener (Listener listener) {
|
||||
|
|
Loading…
Reference in a new issue