From 483ffaec2b9284b6fa1e27e123e1d9bfb624714f Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Mon, 28 Feb 2022 15:35:58 +0100 Subject: [PATCH] Makes sure signs are no longer tracked if they no longer exist --- .../knarcraft/paidsigns/manager/TrackedSignManager.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/net/knarcraft/paidsigns/manager/TrackedSignManager.java b/src/main/java/net/knarcraft/paidsigns/manager/TrackedSignManager.java index 930ebc6..ba6df88 100644 --- a/src/main/java/net/knarcraft/paidsigns/manager/TrackedSignManager.java +++ b/src/main/java/net/knarcraft/paidsigns/manager/TrackedSignManager.java @@ -5,6 +5,7 @@ import net.knarcraft.paidsigns.container.TrackedSign; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.OfflinePlayer; +import org.bukkit.block.Sign; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; @@ -107,6 +108,13 @@ public final class TrackedSignManager { throw new InvalidConfigurationException("Invalid sign coordinates"); } + //Prevent destroyed signs from being tracked indefinitely + if (!(signLocation.getBlock().getState() instanceof Sign)) { + PaidSigns.getInstance().getLogger().log(Level.WARNING, "The sign at " + signLocation + " no longer " + + "exists. Removing from sign tracker."); + return; + } + double cost = signSection.getDouble(key + ".cost"); UUID playerId = UUID.fromString(Objects.requireNonNull(signSection.getString(key + ".playerId")));