From bac5a24b37f96e1e7f493e46c0b42a5b7df69f65 Mon Sep 17 00:00:00 2001 From: Eric Date: Sun, 28 Apr 2019 20:51:43 +0200 Subject: [PATCH] Add IS_BANNER_PATTERN for hologram format --- .../java/de/epiceric/shopchest/config/HologramFormat.java | 4 ++-- src/main/java/de/epiceric/shopchest/shop/Shop.java | 1 + src/main/java/de/epiceric/shopchest/utils/ItemUtils.java | 4 ++++ src/main/resources/hologram-format.yml | 4 ++-- 4 files changed, 9 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 10da9e4..8b7077d 100644 --- a/src/main/java/de/epiceric/shopchest/config/HologramFormat.java +++ b/src/main/java/de/epiceric/shopchest/config/HologramFormat.java @@ -18,8 +18,8 @@ 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, DURABILITY + SELL_PRICE, HAS_POTION_EFFECT, IS_MUSIC_DISC, IS_POTION_EXTENDED, IS_BANNER_PATTERN, + IS_WRITTEN_BOOK, ADMIN_SHOP, NORMAL_SHOP, IN_STOCK, MAX_STACK, CHEST_SPACE, DURABILITY } // no "-" sign since no variable can be negative diff --git a/src/main/java/de/epiceric/shopchest/shop/Shop.java b/src/main/java/de/epiceric/shopchest/shop/Shop.java index 2c863ba..0a81b91 100644 --- a/src/main/java/de/epiceric/shopchest/shop/Shop.java +++ b/src/main/java/de/epiceric/shopchest/shop/Shop.java @@ -270,6 +270,7 @@ public class Shop { requirements.put(HologramFormat.Requirement.IS_MUSIC_DISC, itemStack.getType().isRecord()); requirements.put(HologramFormat.Requirement.IS_POTION_EXTENDED, ItemUtils.isExtendedPotion(itemStack)); requirements.put(HologramFormat.Requirement.IS_WRITTEN_BOOK, itemStack.getType() == Material.WRITTEN_BOOK); + requirements.put(HologramFormat.Requirement.IS_BANNER_PATTERN, ItemUtils.isBannerPattern(itemStack)); requirements.put(HologramFormat.Requirement.ADMIN_SHOP, getShopType() == ShopType.ADMIN); requirements.put(HologramFormat.Requirement.NORMAL_SHOP, getShopType() == ShopType.NORMAL); requirements.put(HologramFormat.Requirement.IN_STOCK, Utils.getAmount(inventory, itemStack)); diff --git a/src/main/java/de/epiceric/shopchest/utils/ItemUtils.java b/src/main/java/de/epiceric/shopchest/utils/ItemUtils.java index 4e747f9..3a7a0c7 100644 --- a/src/main/java/de/epiceric/shopchest/utils/ItemUtils.java +++ b/src/main/java/de/epiceric/shopchest/utils/ItemUtils.java @@ -45,6 +45,10 @@ public class ItemUtils { return false; } + public static boolean isBannerPattern(ItemStack itemStack) { + return itemStack.getType().name().endsWith("BANNER_PATTERN"); + } + /** * Get the {@link ItemStack} from a String * @param item Serialized ItemStack e.g. {@code "STONE"} or {@code "STONE:1"} diff --git a/src/main/resources/hologram-format.yml b/src/main/resources/hologram-format.yml index 802b4ec..c241500 100644 --- a/src/main/resources/hologram-format.yml +++ b/src/main/resources/hologram-format.yml @@ -5,8 +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, DURABILITY +# IS_WRITTEN_BOOK, IS_BANNER_PATTERN, 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),