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")));