Skip to content

Commit 3dd9875

Browse files
committed
All SongPlayer threads are interrupted when disabling the plugin. #80
1 parent 29fdeee commit 3dd9875

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/main/java/com/xxmicloxx/NoteBlockAPI/NoteBlockAPI.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
import org.bukkit.plugin.Plugin;
1212
import org.bukkit.plugin.RegisteredListener;
1313
import org.bukkit.plugin.java.JavaPlugin;
14+
import org.bukkit.scheduler.BukkitTask;
15+
import org.bukkit.scheduler.BukkitWorker;
1416

1517
import java.io.IOException;
1618
import java.lang.reflect.Method;
1719
import java.lang.reflect.Type;
18-
import java.util.ArrayList;
19-
import java.util.HashMap;
20-
import java.util.Map;
21-
import java.util.UUID;
20+
import java.util.*;
2221
import java.util.concurrent.ConcurrentHashMap;
2322

2423
/**
@@ -206,6 +205,12 @@ public void run() {
206205
public void onDisable() {
207206
disabling = true;
208207
Bukkit.getScheduler().cancelTasks(this);
208+
List<BukkitWorker> workers = Bukkit.getScheduler().getActiveWorkers();
209+
for (BukkitWorker worker : workers){
210+
if (!worker.getOwner().equals(this))
211+
continue;
212+
worker.getThread().interrupt();
213+
}
209214
NoteBlockPlayerMain.plugin.onDisable();
210215
}
211216

0 commit comments

Comments
 (0)