mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-26 02:57:56 +01:00
Catch exceptions thrown in repeating tasks to avoid subsequent executions from being cancelled
This commit is contained in:
parent
cbeaaca7af
commit
6dba778e60
@ -38,7 +38,15 @@ public abstract class RepeatingTask {
|
||||
|
||||
protected RepeatingTask(long time, TimeUnit unit, String nameFormat) {
|
||||
this.executor = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder().setNameFormat(nameFormat).build());
|
||||
this.executor.scheduleAtFixedRate(this::tick, time, time, unit);
|
||||
this.executor.scheduleAtFixedRate(this::run, time, time, unit);
|
||||
}
|
||||
|
||||
private void run() {
|
||||
try {
|
||||
tick();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void tick();
|
||||
|
Loading…
Reference in New Issue
Block a user