From dbf49d53753fa65b2f9bc3fd157e7ac960d039b0 Mon Sep 17 00:00:00 2001 From: Maik E Date: Tue, 9 Jan 2024 00:35:09 +0100 Subject: [PATCH] Added Null Check if ShopOwner Name is unknown. --- .../Acrobot/ChestShop/Signs/ChestShopSign.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/Acrobot/ChestShop/Signs/ChestShopSign.java b/src/main/java/com/Acrobot/ChestShop/Signs/ChestShopSign.java index 54304962d..66da891fe 100644 --- a/src/main/java/com/Acrobot/ChestShop/Signs/ChestShopSign.java +++ b/src/main/java/com/Acrobot/ChestShop/Signs/ChestShopSign.java @@ -23,7 +23,8 @@ public class ChestShopSign { public static final byte PRICE_LINE = 2; - public static final Pattern[] SHOP_SIGN_PATTERN = { Pattern.compile("^?[\\w -.]*$"), Pattern.compile("^[1-9][0-9]{0,4}$"), Pattern.compile("(?i)^[\\d.bs(free) :]+$"), Pattern.compile("^[\\w§? #:-]+$") }; + public static final Pattern[] SHOP_SIGN_PATTERN = { Pattern.compile("^?[\\w -.]*$"), Pattern.compile("^[1-9][0-9]{0,4}$"), + Pattern.compile("(?i)^[\\d.bs(free) :]+$"), Pattern.compile("^[\\w§? #:-]+$") }; private static NamespacedKey METADATA_NAMESPACED_KEY; @@ -110,10 +111,15 @@ private static void updateLegacyChestShop(Sign sign) { private static boolean isLegacyChestShop(Sign sign) { - if (sign.getPersistentDataContainer().has(METADATA_NAMESPACED_KEY, PersistentDataType.STRING)) + if (sign.getPersistentDataContainer().has(METADATA_NAMESPACED_KEY, PersistentDataType.STRING)) { return false; - if (!LegacyChestShopSign.isValid(sign)) + } + if (!LegacyChestShopSign.isValid(sign)) { + return false; + } + if (LegacyChestShopSign.getOwnerUUID(sign) == null) { return false; + } return LegacyChestShopSign.getItemStack(sign) != null; } @@ -164,7 +170,8 @@ public static ChestShopMetaData getChestShopMetaData(Sign sign) { return (ChestShopMetaData) yamlConfiguration.get("metadata"); } catch (Exception e) { - Bukkit.getLogger().log(Level.WARNING, "Exception loading Chestshop Metadata (" + sign.getX() + " " + sign.getY() + " " + sign.getZ() + ").", e); + Bukkit.getLogger().log(Level.WARNING, + "Exception loading Chestshop Metadata (" + sign.getX() + " " + sign.getY() + " " + sign.getZ() + ").", e); return null; } } @@ -182,7 +189,8 @@ public static void saveChestShopMetaData(Sign sign, ChestShopMetaData chestShopM sign.update(); } catch (Exception e) { - Bukkit.getLogger().log(Level.WARNING, "Exception saving Chestshop Metadata (" + sign.getX() + " " + sign.getY() + " " + sign.getZ() + ").", e); + Bukkit.getLogger().log(Level.WARNING, + "Exception saving Chestshop Metadata (" + sign.getX() + " " + sign.getY() + " " + sign.getZ() + ").", e); } }, 1L); }