mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 01:49:49 -05:00
Add banner matcher
Former-commit-id: ab4a57a9e4677da6af5c923ddb941f05459f4b23
This commit is contained in:
1 parent
6cf975199f
commit
148c6615cb
4 files changed
+34
-2
No files matched your search
@@ -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");
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user