From fac8abdf6c0822cecd467586c3bea263f959532e Mon Sep 17 00:00:00 2001 From: YuTian <2953516620@qq.com> Date: Tue, 6 Aug 2024 10:26:41 +0800 Subject: [PATCH] 1.1 --- .../com/io/yutian/colorblindwar/ColorblindWar.java | 1 + .../colorblindwar/manager/GiftEffectManager.java | 10 ++++++++++ 2 files changed, 11 insertions(+) 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); }