diff --git a/pom.xml b/pom.xml index 8ce2ec26e..355bea2df 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.maxgamer QuickShop - 3.1.3.13 + 3.1.3.14 diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java index 9319b4a2d..d67a0301e 100644 --- a/src/main/java/org/maxgamer/quickshop/QuickShop.java +++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java @@ -1382,6 +1382,11 @@ public class QuickShop extends JavaPlugin { getConfig().set("config-version", 81); selectedVersion = 81; } + if(selectedVersion == 81){ + getConfig().set("matcher.item.banner",true); + getConfig().set("config-version", 82); + selectedVersion = 82; + } saveConfig(); reloadConfig(); File file = new File(getDataFolder(), "example.config.yml"); diff --git a/src/main/java/org/maxgamer/quickshop/Util/ItemMatcher.java b/src/main/java/org/maxgamer/quickshop/Util/ItemMatcher.java index 82c178b44..0f883fd34 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/ItemMatcher.java +++ b/src/main/java/org/maxgamer/quickshop/Util/ItemMatcher.java @@ -28,6 +28,7 @@ import org.bukkit.attribute.Attribute; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.EnchantmentStorageMeta; @@ -112,6 +113,8 @@ public class ItemMatcher { } class ItemMetaMatcher { + + private boolean banner; private boolean repaircost; private boolean attributes; private boolean custommodeldata; @@ -134,6 +137,7 @@ class ItemMetaMatcher { this.itemflags = itemMatcherConfig.getBoolean("itemflags"); this.custommodeldata = itemMatcherConfig.getBoolean("custommodeldata"); this.book = itemMatcherConfig.getBoolean("book"); + this.banner = itemMatcherConfig.getBoolean("banner"); } private boolean attributeModifiersMatches(ItemMeta meta1, ItemMeta meta2) { @@ -364,6 +368,9 @@ class ItemMetaMatcher { if(!bookMatches(meta1,meta2)){ return false; } + if(!bannerMatches(meta1,meta2)){ + return false; + } try { if (!customModelDataMatches(meta1, meta2)) { return false; @@ -456,6 +463,24 @@ class ItemMetaMatcher { } return true; } + private boolean bannerMatches(ItemMeta meta1, ItemMeta meta2) { + if (!this.banner) { + return true; + } + Util.debugLog("Checking banner"); + if((meta1 instanceof BannerMeta) != (meta2 instanceof BannerMeta)){ + return false; + } + if(!(meta1 instanceof BannerMeta)){ + return true; + } + BannerMeta bannerMeta1 = (BannerMeta)meta1; + BannerMeta bannerMeta2 = (BannerMeta)meta2; + if(bannerMeta1.numberOfPatterns() != bannerMeta2.numberOfPatterns()){ + return false; + } + return Util.listMatches(bannerMeta1.getPatterns(), bannerMeta2.getPatterns()); + } private boolean rootMatches(ItemMeta meta1, ItemMeta meta2) { return (meta1.hashCode() == meta2.hashCode()); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c7f47cf60..48a8477dd 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,7 +1,7 @@ #This is example config, don't direct modify this file, all changes will revert when you reload the plugin. #Do not touch if you not clear know about this -config-version: 82 +config-version: 83 #Select the language you want to use, (e.g de), use only supported language codes from the list below. #If you use a not exist/not support language, plugin will move to use en_US to keep everything working. @@ -345,6 +345,8 @@ matcher: custommodeldata: true #Plugin should check the item bookmetas? books: true + #Plugin should check the banner meta? + banner: true cachingpool: # Did you want use caching pool? # Only use it when you see some method eat too many long time, because may cause actions more slowly if you server too small.