diff --git a/plugin/src/main/java/com/denizenscript/denizen/events/BukkitScriptEvent.java b/plugin/src/main/java/com/denizenscript/denizen/events/BukkitScriptEvent.java index a2203ecf66..5bf85b4673 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/events/BukkitScriptEvent.java +++ b/plugin/src/main/java/com/denizenscript/denizen/events/BukkitScriptEvent.java @@ -216,7 +216,7 @@ public boolean nonSwitchWithCheck(ScriptPath path, ItemTag held) { } public BukkitTagContext getTagContext(ScriptPath path) { - BukkitTagContext context = (BukkitTagContext) getScriptEntryData().getTagContext(); + BukkitTagContext context = (BukkitTagContext) getScriptEntryData().getTagContext().clone(); context.script = new ScriptTag(path.container); context.debug = path.container.shouldDebug(); return context; diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/InventoryTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/InventoryTag.java index 54d770b87e..560d71ef1a 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/InventoryTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/InventoryTag.java @@ -1835,23 +1835,27 @@ else if (item != null && item.hasItemMeta() && item.getItemMeta().hasDisplayName return new ElementTag(found_items >= qty); } // <--[tag] - // @attribute ]> + // @attribute |...]> // @returns ElementTag(Boolean) // @description - // Returns whether the inventory contains an item with the specified scriptname. + // Returns whether the inventory contains an item with the specified scriptname(s). // --> if (attribute.startsWith("scriptname", 2)) { if (!attribute.hasContext(2)) { return null; } - String scrName = attribute.getContext(2); + ListTag scrNameList = attribute.contextAsType(2, ListTag.class); + HashSet scrNames = new HashSet<>(); + for (String name : scrNameList) { + scrNames.add(CoreUtilities.toLowerCase(name)); + } int qty = 1; // <--[tag] - // @attribute ].quantity[<#>]> + // @attribute |...].quantity[<#>]> // @returns ElementTag(Boolean) // @description - // Returns whether the inventory contains a certain quantity of an item with the specified scriptname. + // Returns whether the inventory contains a certain quantity of an item with the specified scriptname(s). // --> if ((attribute.startsWith("quantity", 3) || attribute.startsWith("qty", 3)) && attribute.hasContext(3)) { if (attribute.startsWith("qty", 3)) { @@ -1864,7 +1868,7 @@ else if (item != null && item.hasItemMeta() && item.getItemMeta().hasDisplayName int found_items = 0; for (ItemStack item : object.getContents()) { - if (item != null && scrName.equalsIgnoreCase(new ItemTag(item).getScriptName())) { + if (item != null && scrNames.contains(CoreUtilities.toLowerCase(new ItemTag(item).getScriptName()))) { found_items += item.getAmount(); if (found_items >= qty) { break; diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/item/TakeCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/item/TakeCommand.java index f6b4c289ea..fd340d42b2 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/item/TakeCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/item/TakeCommand.java @@ -90,9 +90,7 @@ private enum Type {MONEY, XP, ITEMINHAND, ITEM, INVENTORY, BYDISPLAY, SLOT, BYCO @Override public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException { - for (Argument arg : scriptEntry.getProcessedArgs()) { - if (!scriptEntry.hasObject("type") && arg.matches("money", "coins")) { scriptEntry.addObject("type", Type.MONEY); @@ -170,29 +168,22 @@ else if (!scriptEntry.hasObject("inventory") arg.reportUnhandled(); } } - scriptEntry.defaultObject("type", Type.ITEM) .defaultObject("quantity", new ElementTag(1)); - Type type = (Type) scriptEntry.getObject("type"); - if (type != Type.MONEY && scriptEntry.getObject("inventory") == null) { scriptEntry.addObject("inventory", Utilities.entryHasPlayer(scriptEntry) ? Utilities.getEntryPlayer(scriptEntry).getInventory() : null); } - if (!scriptEntry.hasObject("inventory") && type != Type.MONEY) { throw new InvalidArgumentsException("Must specify an inventory to take from!"); } - if (type == Type.ITEM && scriptEntry.getObject("items") == null) { throw new InvalidArgumentsException("Must specify item/items!"); } - } @Override public void execute(ScriptEntry scriptEntry) { - InventoryTag inventory = scriptEntry.getObjectTag("inventory"); ElementTag quantity = scriptEntry.getElement("quantity"); ElementTag displayname = scriptEntry.getElement("displayname"); @@ -202,14 +193,11 @@ public void execute(ScriptEntry scriptEntry) { ElementTag nbtKey = scriptEntry.getElement("nbt_key"); MaterialTag material = scriptEntry.getObjectTag("material"); Type type = (Type) scriptEntry.getObject("type"); - Object items_object = scriptEntry.getObject("items"); List items = null; - if (items_object != null) { items = (List) items_object; } - if (scriptEntry.dbCallShouldDebug()) { Debug.report(scriptEntry, getName(), ArgumentHelper.debugObj("Type", type.name()) + quantity.debug() @@ -222,7 +210,6 @@ public void execute(ScriptEntry scriptEntry) { + (material != null ? material.debug() : "") + (titleAuthor != null ? titleAuthor.debug() : "")); } - switch (type) { case INVENTORY: { inventory.clear();