diff --git a/com/Acrobot/Breeze/Utils/MaterialUtil.java b/com/Acrobot/Breeze/Utils/MaterialUtil.java index b6284dc..6f0a7bc 100644 --- a/com/Acrobot/Breeze/Utils/MaterialUtil.java +++ b/com/Acrobot/Breeze/Utils/MaterialUtil.java @@ -241,7 +241,7 @@ public class MaterialUtil { * @return Enchantments found */ public static Map getEnchantments(String base32) { - if (base32 == null || base32.isEmpty()) { + if (base32 == null || base32.isEmpty() || !NumberUtil.isLong(base32)) { return new HashMap(); } diff --git a/com/Acrobot/Breeze/Utils/NumberUtil.java b/com/Acrobot/Breeze/Utils/NumberUtil.java index 48630f9..8953436 100644 --- a/com/Acrobot/Breeze/Utils/NumberUtil.java +++ b/com/Acrobot/Breeze/Utils/NumberUtil.java @@ -64,6 +64,21 @@ public class NumberUtil { } } + /** + * Checks if the string is a long + * + * @param string string to check + * @return Is the string long? + */ + public static boolean isLong(String string) { + try { + Long.parseLong(string); + return true; + } catch (NumberFormatException e) { + return false; + } + } + /** * Rounds the number up to two decimal points (Can be inaccurate due to using decimal-points) * diff --git a/com/Acrobot/ChestShop/Listeners/PreTransaction/AmountAndPriceChecker.java b/com/Acrobot/ChestShop/Listeners/PreTransaction/AmountAndPriceChecker.java index 0e78b12..14f654f 100644 --- a/com/Acrobot/ChestShop/Listeners/PreTransaction/AmountAndPriceChecker.java +++ b/com/Acrobot/ChestShop/Listeners/PreTransaction/AmountAndPriceChecker.java @@ -1,6 +1,9 @@ package com.Acrobot.ChestShop.Listeners.PreTransaction; import com.Acrobot.Breeze.Utils.InventoryUtil; +import com.Acrobot.ChestShop.Config.Config; +import com.Acrobot.ChestShop.Config.Property; +import com.Acrobot.ChestShop.Containers.AdminInventory; import com.Acrobot.ChestShop.Economy.Economy; import com.Acrobot.ChestShop.Events.PreTransactionEvent; import org.bukkit.event.EventHandler; @@ -44,7 +47,7 @@ public class AmountAndPriceChecker implements Listener { ItemStack[] stock = event.getStock(); Inventory clientInventory = event.getClientInventory(); - if (!Economy.hasEnough(event.getOwner().getName(), event.getPrice())) { + if (isOwnerEconomicalyActive(event) && !Economy.hasEnough(event.getOwner().getName(), event.getPrice())) { event.setCancelled(SHOP_DOES_NOT_HAVE_ENOUGH_MONEY); return; } @@ -54,6 +57,18 @@ public class AmountAndPriceChecker implements Listener { } } + public static String getServerAccountName() { + return Config.getString(Property.SERVER_ECONOMY_ACCOUNT); + } + + public static boolean isServerShop(Inventory inventory) { + return inventory instanceof AdminInventory; + } + + public static boolean isOwnerEconomicalyActive(PreTransactionEvent event) { + return !isServerShop(event.getOwnerInventory()) || !getServerAccountName().isEmpty(); + } + private static boolean hasItems(Inventory inventory, ItemStack[] items) { for (ItemStack item : items) { if (InventoryUtil.getAmount(item, inventory) < item.getAmount()) {