From 58314408e0dd817cb605aef5df217098f26b042b Mon Sep 17 00:00:00 2001 From: Brianna Date: Sat, 21 Dec 2019 15:27:38 -0500 Subject: [PATCH] Make sure the inventory is open before running the task. --- src/main/java/com/songoda/epicfurnaces/gui/GUIOverview.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/epicfurnaces/gui/GUIOverview.java b/src/main/java/com/songoda/epicfurnaces/gui/GUIOverview.java index bfc6d4d..bec02ca 100644 --- a/src/main/java/com/songoda/epicfurnaces/gui/GUIOverview.java +++ b/src/main/java/com/songoda/epicfurnaces/gui/GUIOverview.java @@ -189,7 +189,10 @@ public class GUIOverview extends Gui { } private void runTask() { - task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::constructGUI, 5L, 5L); + task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> { + if (inventory.getViewers().size() != 0) + this.constructGUI(); + }, 5L, 5L); } List getFurnaceDescription(Furnace furnace, Level level, Level nextLevel) {