From 6b38e6db9e43d3b6807c7a8968e880f00a37b61b Mon Sep 17 00:00:00 2001 From: Sotr Date: Mon, 20 Jan 2020 20:50:20 +0700 Subject: [PATCH] Clean up Former-commit-id: 5d45fd86018ece1ac104c332aa7e11e395dc1708 --- .../Watcher/DisplayAutoDespawnWatcher.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/Watcher/DisplayAutoDespawnWatcher.java b/src/main/java/org/maxgamer/quickshop/Watcher/DisplayAutoDespawnWatcher.java index 90e57356b..4d796b3ed 100644 --- a/src/main/java/org/maxgamer/quickshop/Watcher/DisplayAutoDespawnWatcher.java +++ b/src/main/java/org/maxgamer/quickshop/Watcher/DisplayAutoDespawnWatcher.java @@ -23,6 +23,8 @@ import lombok.AllArgsConstructor; import org.bukkit.Bukkit; import org.bukkit.scheduler.BukkitRunnable; import org.maxgamer.quickshop.QuickShop; +import org.maxgamer.quickshop.Shop.DisplayItem; +import org.maxgamer.quickshop.Shop.Shop; import org.maxgamer.quickshop.Util.Util; @AllArgsConstructor @@ -48,16 +50,22 @@ public class DisplayAutoDespawnWatcher extends BukkitRunnable { shop.checkDisplay(); } } else if (shop.getDisplay().isSpawned()) { - if (shop.getDisplay().isPendingRemoval()) { - // Actually remove the pending display - Util.debugLog("Removing the shop " + shop + " the display, cause nobody can see it"); - shop.getDisplay().remove(); - } else { - // Delayed to next cycle - Util.debugLog("Pending to remove the shop " + shop + " the display, cause nobody can see it"); - shop.getDisplay().pendingRemoval(); - } + removeDisplayItemDelayed(shop); } }); } + + public boolean removeDisplayItemDelayed(Shop shop) { + if (shop.getDisplay().isPendingRemoval()) { + // Actually remove the pending display + Util.debugLog("Removing the shop " + shop + " the display, cause nobody can see it"); + shop.getDisplay().remove(); + return true; + } else { + // Delayed to next calling + Util.debugLog("Pending to remove the shop " + shop + " the display, cause nobody can see it"); + shop.getDisplay().pendingRemoval(); + return false; + } + } }