From 1ae4ee379ba49d2915c62047b0590d351bc5c5d5 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 27 Jun 2017 22:00:37 +0200 Subject: [PATCH] Added durability requirement and placeholder for hologram format --- .../java/de/epiceric/shopchest/config/HologramFormat.java | 2 +- src/main/java/de/epiceric/shopchest/config/Placeholder.java | 3 ++- src/main/java/de/epiceric/shopchest/shop/Shop.java | 2 ++ src/main/resources/hologram-format.yml | 5 +++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/config/HologramFormat.java b/src/main/java/de/epiceric/shopchest/config/HologramFormat.java index 4ceb100..cf63ee6 100644 --- a/src/main/java/de/epiceric/shopchest/config/HologramFormat.java +++ b/src/main/java/de/epiceric/shopchest/config/HologramFormat.java @@ -18,7 +18,7 @@ public class HologramFormat { public enum Requirement { VENDOR, AMOUNT, ITEM_TYPE, ITEM_NAME, HAS_ENCHANTMENT, BUY_PRICE, SELL_PRICE, HAS_POTION_EFFECT, IS_MUSIC_DISC, IS_POTION_EXTENDED, IS_WRITTEN_BOOK, ADMIN_SHOP, - NORMAL_SHOP, IN_STOCK, MAX_STACK, CHEST_SPACE + NORMAL_SHOP, IN_STOCK, MAX_STACK, CHEST_SPACE, DURABILITY } private ShopChest plugin; diff --git a/src/main/java/de/epiceric/shopchest/config/Placeholder.java b/src/main/java/de/epiceric/shopchest/config/Placeholder.java index caa7f25..3a39fe8 100644 --- a/src/main/java/de/epiceric/shopchest/config/Placeholder.java +++ b/src/main/java/de/epiceric/shopchest/config/Placeholder.java @@ -25,7 +25,8 @@ public enum Placeholder { STOCK("%STOCK%"), CHEST_SPACE("%CHEST-SPACE%"), MAX_STACK("%MAX-STACK%"), - COMMAND("%COMMAND%"); + COMMAND("%COMMAND%"), + DURABILITY("%DURABILITY%"); private String name; diff --git a/src/main/java/de/epiceric/shopchest/shop/Shop.java b/src/main/java/de/epiceric/shopchest/shop/Shop.java index 5fb41ab..e98e071 100644 --- a/src/main/java/de/epiceric/shopchest/shop/Shop.java +++ b/src/main/java/de/epiceric/shopchest/shop/Shop.java @@ -198,6 +198,7 @@ public class Shop { requirements.put(HologramFormat.Requirement.IN_STOCK, Utils.getAmount(getInventoryHolder().getInventory(), getProduct())); requirements.put(HologramFormat.Requirement.MAX_STACK, getProduct().getMaxStackSize()); requirements.put(HologramFormat.Requirement.CHEST_SPACE, Utils.getFreeSpaceForItem(getInventoryHolder().getInventory(), getProduct())); + requirements.put(HologramFormat.Requirement.DURABILITY, getProduct().getDurability()); Map placeholders = new HashMap<>(); placeholders.put(Placeholder.VENDOR, getVendor().getName()); @@ -212,6 +213,7 @@ public class Shop { placeholders.put(Placeholder.STOCK, Utils.getAmount(getInventoryHolder().getInventory(), getProduct())); placeholders.put(Placeholder.MAX_STACK, getProduct().getMaxStackSize()); placeholders.put(Placeholder.CHEST_SPACE, Utils.getFreeSpaceForItem(getInventoryHolder().getInventory(), getProduct())); + placeholders.put(Placeholder.DURABILITY, getProduct().getDurability()); int lineCount = plugin.getHologramFormat().getLineCount(); diff --git a/src/main/resources/hologram-format.yml b/src/main/resources/hologram-format.yml index 0fdf2a7..54dc3c0 100644 --- a/src/main/resources/hologram-format.yml +++ b/src/main/resources/hologram-format.yml @@ -5,7 +5,8 @@ # Valid requirements are: # VENDOR, AMOUNT, ITEM_TYPE, ITEM_NAME, HAS_ENCHANTMENT, BUY_PRICE, # SELL_PRICE, HAS_POTION_EFFECT, IS_MUSIC_DISC, IS_POTION_EXTENDED, -# IS_WRITTEN_BOOK, ADMIN_SHOP, NORMAL_SHOP, IN_STOCK, MAX_STACK, CHEST_SPACE +# IS_WRITTEN_BOOK, ADMIN_SHOP, NORMAL_SHOP, IN_STOCK, MAX_STACK, +# CHEST_SPACE, DURABILITY # # You can also use the requirements for conditions. # ITEM_TYPE will return the type of the item (-> item_names.txt), @@ -24,7 +25,7 @@ # Valid placeholders are: # %VENDOR%, %AMOUNT%, %ITEM-NAME%, %ENCHANTMENT%, %BUY-PRICE%, # %SELL-PRICE%, %POTION-EFFECT%, %MUSIC-TITLE%, %GENERATION%, -# %STOCK%, %MAX-STACK%, %CHEST-SPACE% +# %STOCK%, %MAX-STACK%, %CHEST-SPACE%, %DURABILITY% # # In the format, placeholders can also be used for scripts. # Examples: