Skip to content

Commit

Permalink
Added Null Check if ShopOwner Name is unknown.
Browse files Browse the repository at this point in the history
  • Loading branch information
Feli499 committed Jan 8, 2024
1 parent f8f87f0 commit dbf49d5
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/main/java/com/Acrobot/ChestShop/Signs/ChestShopSign.java
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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);
}
Expand Down

0 comments on commit dbf49d5

Please sign in to comment.