diff --git a/src/main/java/com/io/yutian/colorblindwar/ColorblindWar.java b/src/main/java/com/io/yutian/colorblindwar/ColorblindWar.java index 8f5b340..3a9c5d6 100644 --- a/src/main/java/com/io/yutian/colorblindwar/ColorblindWar.java +++ b/src/main/java/com/io/yutian/colorblindwar/ColorblindWar.java @@ -33,6 +33,7 @@ public final class ColorblindWar extends JavaPlugin { if (game.isStarted()) { game.stop(false); } + GiftEffectManager.stopQueue(); } @Override diff --git a/src/main/java/com/io/yutian/colorblindwar/manager/GiftEffectManager.java b/src/main/java/com/io/yutian/colorblindwar/manager/GiftEffectManager.java index 26b0ad3..2ae493f 100644 --- a/src/main/java/com/io/yutian/colorblindwar/manager/GiftEffectManager.java +++ b/src/main/java/com/io/yutian/colorblindwar/manager/GiftEffectManager.java @@ -7,6 +7,7 @@ import com.io.yutian.colorblindwar.util.RandomUtil; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitTask; import java.util.*; import java.util.function.Function; @@ -24,6 +25,15 @@ public class GiftEffectManager { giftQueues.put(effectId, giftQueue); } + public static void stopQueue() { + giftQueues.values().forEach(giftQueue -> { + BukkitTask task = giftQueue.getTask(); + if (task != null && !task.isCancelled()) { + task.cancel(); + } + }); + } + public static GiftQueue getGiftQueue(String effectId) { return giftQueues.get(effectId); }