diff --git a/core/src/main/java/de/erethon/dungeonsxl/command/StatusCommand.java b/core/src/main/java/de/erethon/dungeonsxl/command/StatusCommand.java index 250f5719..25aaf48a 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/command/StatusCommand.java +++ b/core/src/main/java/de/erethon/dungeonsxl/command/StatusCommand.java @@ -38,7 +38,7 @@ public class StatusCommand extends DCommand { public static final String TRUE = ChatColor.GREEN + "\u2714"; public static final String FALSE = ChatColor.DARK_RED + "\u2718"; - public static final String LATEST_IXL = "0.6.4"; + public static final String LATEST_IXL = "0.6.5"; public StatusCommand(DungeonsXL plugin) { super(plugin); @@ -118,7 +118,7 @@ public class StatusCommand extends DCommand { String custommobsVersionCorrect = getSymbol(custommobsVersion.startsWith("4.")); String insanemobsVersionCorrect = getSymbol(insanemobsVersion.startsWith("3.")); String mythicmobsVersionCorrect = getSymbol(mythicmobsVersion.startsWith("4.")); - String holographicdisplaysVersionCorrect = getSymbol(holographicdisplaysVersion.startsWith("2.3")); + String holographicdisplaysVersionCorrect = getSymbol(holographicdisplaysVersion.startsWith("2.4")); MessageUtil.sendMessage(sender, ChatColor.GRAY + "Dependency info:"); MessageUtil.sendMessage(sender, "= Vault: " + vaultVersion + " " + vaultVersionCorrect); diff --git a/core/src/main/java/de/erethon/dungeonsxl/requirement/ForbiddenItemsRequirement.java b/core/src/main/java/de/erethon/dungeonsxl/requirement/ForbiddenItemsRequirement.java index b4112e97..f4eb1196 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/requirement/ForbiddenItemsRequirement.java +++ b/core/src/main/java/de/erethon/dungeonsxl/requirement/ForbiddenItemsRequirement.java @@ -21,8 +21,10 @@ import de.erethon.caliburn.item.ExItem; import de.erethon.dungeonsxl.api.DungeonsAPI; import de.erethon.dungeonsxl.api.Requirement; import de.erethon.dungeonsxl.config.DMessage; +import java.util.HashMap; import java.util.HashSet; -import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.BaseComponent; @@ -38,7 +40,7 @@ public class ForbiddenItemsRequirement implements Requirement { private CaliburnAPI caliburn; - private List forbiddenItems; + private Map forbiddenItems = new HashMap<>(); public ForbiddenItemsRequirement(DungeonsAPI api) { caliburn = api.getCaliburn(); @@ -46,16 +48,26 @@ public class ForbiddenItemsRequirement implements Requirement { /* Getters and setters */ /** - * @return the forbidden items + * @return the forbidden items (key) and if the check is deep (value) */ - public List getForbiddenItems() { + public Map getForbiddenItems() { return forbiddenItems; } /* Actions */ @Override public void setup(ConfigurationSection config) { - forbiddenItems = caliburn.deserializeExItemList(config, "forbiddenItems"); + for (String entry : config.getStringList("forbiddenItems")) { + if (entry == null) { + continue; + } + boolean star = !entry.contains("*"); + entry = entry.replace("*", ""); + ExItem item = caliburn.getExItem(entry); + if (item != null) { + forbiddenItems.put(item, star); + } + } } @Override @@ -65,8 +77,16 @@ public class ForbiddenItemsRequirement implements Requirement { continue; } ExItem exItem = caliburn.getExItem(item); - if (forbiddenItems.contains(exItem)) { - return false; + for (Entry entry : forbiddenItems.entrySet()) { + if (entry.getValue()) { + if (exItem.isSubsumableUnder(entry.getKey())) { + return false; + } + } else { + if (exItem.equals(entry.getKey())) { + return false; + } + } } } return true; @@ -84,19 +104,29 @@ public class ForbiddenItemsRequirement implements Requirement { } boolean first = true; - for (ExItem forbiddenItem : forbiddenItems) { - ChatColor color = exInventory.contains(forbiddenItem) ? ChatColor.DARK_RED : ChatColor.GREEN; + for (Entry entry : forbiddenItems.entrySet()) { + boolean contains = containsItem(exInventory, entry.getKey(), entry.getValue()); + ChatColor color = contains ? ChatColor.DARK_RED : ChatColor.GREEN; if (!first) { builder.append(", ").color(ChatColor.WHITE); } else { first = false; } - builder.append(forbiddenItem.getName()).color(color); + builder.append(entry.getKey().getName()).color(color); } return builder.create(); } + private boolean containsItem(Set exInventory, ExItem forbiddenItem, boolean deepCheck) { + for (ExItem item : exInventory) { + if ((deepCheck && item.isSubsumableUnder(forbiddenItem)) || (!deepCheck && item.equals(forbiddenItem))) { + return true; + } + } + return false; + } + @Override public void demand(Player player) { } diff --git a/pom.xml b/pom.xml index 03af532c..2c6aadeb 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ de.erethon caliburn - 1.0-RC-04 + 1.0-RC-05 compile