Added durability requirement and placeholder for hologram format

This commit is contained in:
Eric 2017-06-27 22:00:37 +02:00
parent 8533c017e7
commit 1ae4ee379b
4 changed files with 8 additions and 4 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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<Placeholder, Object> 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();

View File

@ -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: