9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-22 08:29:28 +00:00

shut down scheduler on disable

This commit is contained in:
XiaoMoMi
2024-12-21 19:39:30 +08:00
parent 26b593950d
commit 6f0e61ae48
2 changed files with 2 additions and 19 deletions

View File

@@ -81,28 +81,12 @@ public abstract class AbstractJavaScheduler<T> implements SchedulerAdapter<T> {
@Override @Override
public void shutdownScheduler() { public void shutdownScheduler() {
this.scheduler.shutdown(); this.scheduler.shutdownNow();
try {
if (!this.scheduler.awaitTermination(1, TimeUnit.MINUTES)) {
this.plugin.getPluginLogger().severe("Timed out waiting for the CustomNameplates scheduler to terminate");
reportRunningTasks(thread -> thread.getName().equals("nameplates-scheduler"));
}
} catch (InterruptedException e) {
e.printStackTrace();
}
} }
@Override @Override
public void shutdownExecutor() { public void shutdownExecutor() {
this.worker.shutdown(); this.worker.shutdownNow();
try {
if (!this.worker.awaitTermination(1, TimeUnit.MINUTES)) {
this.plugin.getPluginLogger().severe("Timed out waiting for the CustomNameplates worker thread pool to terminate");
reportRunningTasks(thread -> thread.getName().startsWith("nameplates-worker-"));
}
} catch (InterruptedException e) {
e.printStackTrace();
}
} }
private void reportRunningTasks(Predicate<Thread> predicate) { private void reportRunningTasks(Predicate<Thread> predicate) {

View File

@@ -310,7 +310,6 @@ public class BukkitCustomNameplates extends CustomNameplates implements Listener
this.scheduledMainTask = getScheduler().asyncRepeating(mainTask, 50, 50, TimeUnit.MILLISECONDS); this.scheduledMainTask = getScheduler().asyncRepeating(mainTask, 50, 50, TimeUnit.MILLISECONDS);
} }
@Override @Override
public InputStream getResourceStream(String filePath) { public InputStream getResourceStream(String filePath) {
return getBootstrap().getResource(filePath.replace("\\", "/")); return getBootstrap().getResource(filePath.replace("\\", "/"));