From d250453645fbbe1a1de0f4ed0a5cddf006dd7d20 Mon Sep 17 00:00:00 2001 From: Xenmai Date: Fri, 3 Nov 2017 18:43:41 +0100 Subject: [PATCH] Organize Tags Part 1 --- .../tags/objects/CuboidTag.java | 82 ++--- .../tags/objects/FormattedTextTag.java | 20 +- .../tags/objects/InventoryTag.java | 82 ++--- .../denizen2sponge/tags/objects/ItemTag.java | 294 +++++++++--------- 4 files changed, 239 insertions(+), 239 deletions(-) diff --git a/src/main/java/com/denizenscript/denizen2sponge/tags/objects/CuboidTag.java b/src/main/java/com/denizenscript/denizen2sponge/tags/objects/CuboidTag.java index bba721c..9ecadaf 100644 --- a/src/main/java/com/denizenscript/denizen2sponge/tags/objects/CuboidTag.java +++ b/src/main/java/com/denizenscript/denizen2sponge/tags/objects/CuboidTag.java @@ -56,47 +56,6 @@ public boolean contains(UtilLocation point) { static { // <--[tag] // @Since 0.3.0 - // @Name CuboidTag.min - // @Updated 2016/11/24 - // @Group Identification - // @ReturnType LocationTag - // @Returns the minimum location of this cuboid. IE, it's lowest-valued corner. - // @Example "0,1,2/4,5,6/world" .min returns "0,1,2,world". - // --> - handlers.put("min", (dat, obj) -> new LocationTag(((CuboidTag) obj).internal.min)); - // <--[tag] - // @Since 0.3.0 - // @Name CuboidTag.max - // @Updated 2016/11/24 - // @Group Identification - // @ReturnType LocationTag - // @Returns the maximum location of this cuboid. IE, it's highest-valued corner. - // @Example "0,1,2/4,5,6/world" .max returns "4,5,6,world". - // --> - handlers.put("max", (dat, obj) -> new LocationTag(((CuboidTag) obj).internal.max)); - // <--[tag] - // @Since 0.3.0 - // @Name CuboidTag.world - // @Updated 2016/11/24 - // @Group Identification - // @ReturnType WorldTag - // @Returns the world of the location. - // @Example "0,1,2/4,5,6/world" .world returns "world". - // --> - handlers.put("world", (dat, obj) -> new WorldTag(((CuboidTag) obj).internal.min.world)); - // <--[tag] - // @Since 0.3.0 - // @Name CuboidTag.contains[] - // @Updated 2016/11/24 - // @Group Mathematics - // @ReturnType WorldTag - // @Returns whether the cuboid contains the specified location. - // @Example "0,1,2/4,5,6/world" .contains[1,2,3,world] returns "true". - // --> - handlers.put("contains", (dat, obj) -> new BooleanTag(((CuboidTag) obj).contains( - LocationTag.getFor(dat.error, dat.getNextModifier()).getInternal()))); - // <--[tag] - // @Since 0.3.0 // @Name CuboidTag.block_locations[] // @Updated 2016/11/24 // @Group Connected Information @@ -131,6 +90,47 @@ public boolean contains(UtilLocation point) { } return lt; }); + // <--[tag] + // @Since 0.3.0 + // @Name CuboidTag.contains[] + // @Updated 2016/11/24 + // @Group Mathematics + // @ReturnType BooleanTag + // @Returns whether the cuboid contains the specified location. + // @Example "0,1,2/4,5,6/world" .contains[1,2,3,world] returns "true". + // --> + handlers.put("contains", (dat, obj) -> new BooleanTag(((CuboidTag) obj).contains( + LocationTag.getFor(dat.error, dat.getNextModifier()).getInternal()))); + // <--[tag] + // @Since 0.3.0 + // @Name CuboidTag.max + // @Updated 2016/11/24 + // @Group Identification + // @ReturnType LocationTag + // @Returns the maximum location of this cuboid. IE, it's highest-valued corner. + // @Example "0,1,2/4,5,6/world" .max returns "4,5,6,world". + // --> + handlers.put("max", (dat, obj) -> new LocationTag(((CuboidTag) obj).internal.max)); + // <--[tag] + // @Since 0.3.0 + // @Name CuboidTag.min + // @Updated 2016/11/24 + // @Group Identification + // @ReturnType LocationTag + // @Returns the minimum location of this cuboid. IE, it's lowest-valued corner. + // @Example "0,1,2/4,5,6/world" .min returns "0,1,2,world". + // --> + handlers.put("min", (dat, obj) -> new LocationTag(((CuboidTag) obj).internal.min)); + // <--[tag] + // @Since 0.3.0 + // @Name CuboidTag.world + // @Updated 2016/11/24 + // @Group Identification + // @ReturnType WorldTag + // @Returns the world of the location. + // @Example "0,1,2/4,5,6/world" .world returns "world". + // --> + handlers.put("world", (dat, obj) -> new WorldTag(((CuboidTag) obj).internal.min.world)); } public static CuboidTag getFor(Action error, String text) { diff --git a/src/main/java/com/denizenscript/denizen2sponge/tags/objects/FormattedTextTag.java b/src/main/java/com/denizenscript/denizen2sponge/tags/objects/FormattedTextTag.java index 85e4937..aa24a9c 100644 --- a/src/main/java/com/denizenscript/denizen2sponge/tags/objects/FormattedTextTag.java +++ b/src/main/java/com/denizenscript/denizen2sponge/tags/objects/FormattedTextTag.java @@ -37,6 +37,16 @@ public Text getInternal() { static { // <--[tag] // @Since 0.3.0 + // @Name FormattedTextTag.append[] + // @Updated 2016/09/21 + // @Group Modification + // @ReturnType TextTag + // @Returns the text followed by another piece of text. + // --> + handlers.put("append", (dat, obj) -> new FormattedTextTag(Text.join(((FormattedTextTag) obj).internal, + FormattedTextTag.getFor(dat.error, dat.getNextModifier()).internal))); + // <--[tag] + // @Since 0.3.0 // @Name FormattedTextTag.color_codes // @Updated 2017/08/31 // @Group Conversion @@ -54,16 +64,6 @@ public Text getInternal() { // @Returns a plain version of this formatted text. // --> handlers.put("plain", (dat, obj) -> new TextTag(((FormattedTextTag) obj).internal.toPlain())); - // <--[tag] - // @Since 0.3.0 - // @Name FormattedTextTag.append[] - // @Updated 2016/09/21 - // @Group Modification - // @ReturnType TextTag - // @Returns the text followed by another piece of text. - // --> - handlers.put("append", (dat, obj) -> new FormattedTextTag(Text.join(((FormattedTextTag) obj).internal, - FormattedTextTag.getFor(dat.error, dat.getNextModifier()).internal))); } public static FormattedTextTag getFor(Action error, String text) { diff --git a/src/main/java/com/denizenscript/denizen2sponge/tags/objects/InventoryTag.java b/src/main/java/com/denizenscript/denizen2sponge/tags/objects/InventoryTag.java index de67cd0..d3c2d72 100644 --- a/src/main/java/com/denizenscript/denizen2sponge/tags/objects/InventoryTag.java +++ b/src/main/java/com/denizenscript/denizen2sponge/tags/objects/InventoryTag.java @@ -56,22 +56,6 @@ public Inventory getInternal() { public final static HashMap> handlers = new HashMap<>(); static { - // @Name InventoryTag.name - // @Updated 2017/06/10 - // @Group General Information - // @ReturnType TextTag - // @Returns the inventory's name (in English). - // @Example "player/bob" .name might return "Bob". - // --> - handlers.put("name", (dat, obj) -> new TextTag(((InventoryTag) obj).internal.getName().get(Locale.ENGLISH))); - // @Name InventoryTag.size - // @Updated 2017/06/11 - // @Group General Information - // @ReturnType IntegerTag - // @Returns the inventory's size (in slots). - // @Example "block/0,1,2,world" .size might return "36". - // --> - handlers.put("size", (dat, obj) -> new IntegerTag(((InventoryTag) obj).internal.size())); // @Name InventoryTag.contains[] // @Updated 2017/06/17 // @Group General Information @@ -88,31 +72,6 @@ public Inventory getInternal() { // @Example "block/0,1,2,world" .contains_any[diamond] might return "true". // --> handlers.put("contains_any", (dat, obj) -> new BooleanTag(((InventoryTag) obj).internal.containsAny(ItemTag.getFor(dat.error, dat.getNextModifier()).getInternal()))); - // @Name InventoryTag.slot[] - // @Updated 2017/09/05 - // @Group General Information - // @ReturnType ItemTag - // @Returns the item in the inventory's specified slot. - // @Example "block/0,1,2,world" .slot[8] might return "diamond". - // --> - handlers.put("slot", (dat, obj) -> { - Inventory inventory = ((InventoryTag) obj).internal.query(OrderedInventory.class); - if (inventory instanceof EmptyInventory) { - if (!dat.hasFallback()) { - dat.error.run("This inventory does not contain slots ordered by index!"); - } - return new NullTag(); - } - int slot = (int) IntegerTag.getFor(dat.error, dat.getNextModifier()).getInternal(); - if (slot < 1 || slot > inventory.capacity()) { - if (!dat.hasFallback()) { - dat.error.run("Invalid slot index specified!"); - } - return new NullTag(); - } - ItemStack item = ((OrderedInventory) inventory).peek(new SlotIndex(slot - 1)).orElse(ItemStack.empty()); - return new ItemTag(item); - }); // @Name InventoryTag.fuel // @Updated 2017/09/05 // @Group General Information @@ -131,6 +90,14 @@ public Inventory getInternal() { ItemStack item = inventory.peek().orElse(ItemStack.empty()); return new ItemTag(item); }); + // @Name InventoryTag.name + // @Updated 2017/06/10 + // @Group General Information + // @ReturnType TextTag + // @Returns the inventory's name (in English). + // @Example "player/bob" .name might return "Bob". + // --> + handlers.put("name", (dat, obj) -> new TextTag(((InventoryTag) obj).internal.getName().get(Locale.ENGLISH))); // @Name InventoryTag.result // @Updated 2017/09/05 // @Group General Information @@ -149,6 +116,39 @@ public Inventory getInternal() { ItemStack item = inventory.peek().orElse(ItemStack.empty()); return new ItemTag(item); }); + // @Name InventoryTag.size + // @Updated 2017/06/11 + // @Group General Information + // @ReturnType IntegerTag + // @Returns the inventory's size (in slots). + // @Example "block/0,1,2,world" .size might return "36". + // --> + handlers.put("size", (dat, obj) -> new IntegerTag(((InventoryTag) obj).internal.size())); + // @Name InventoryTag.slot[] + // @Updated 2017/09/05 + // @Group General Information + // @ReturnType ItemTag + // @Returns the item in the inventory's specified slot. + // @Example "block/0,1,2,world" .slot[8] might return "diamond". + // --> + handlers.put("slot", (dat, obj) -> { + Inventory inventory = ((InventoryTag) obj).internal.query(OrderedInventory.class); + if (inventory instanceof EmptyInventory) { + if (!dat.hasFallback()) { + dat.error.run("This inventory does not contain slots ordered by index!"); + } + return new NullTag(); + } + int slot = (int) IntegerTag.getFor(dat.error, dat.getNextModifier()).getInternal(); + if (slot < 1 || slot > inventory.capacity()) { + if (!dat.hasFallback()) { + dat.error.run("Invalid slot index specified!"); + } + return new NullTag(); + } + ItemStack item = ((OrderedInventory) inventory).peek(new SlotIndex(slot - 1)).orElse(ItemStack.empty()); + return new ItemTag(item); + }); } public static InventoryTag getFor(Action error, String text) { diff --git a/src/main/java/com/denizenscript/denizen2sponge/tags/objects/ItemTag.java b/src/main/java/com/denizenscript/denizen2sponge/tags/objects/ItemTag.java index 1fe37a0..794fafd 100644 --- a/src/main/java/com/denizenscript/denizen2sponge/tags/objects/ItemTag.java +++ b/src/main/java/com/denizenscript/denizen2sponge/tags/objects/ItemTag.java @@ -45,33 +45,6 @@ public ItemStack getInternal() { public final static HashMap> handlers = new HashMap<>(); static { - // <--[tag] - // @Since 0.3.0 - // @Name ItemTag.item_type - // @Updated 2016/11/24 - // @Group Identification - // @ReturnType ItemTypeTag - // @Returns the type of the item. - // --> - handlers.put("item_type", (dat, obj) -> new ItemTypeTag(((ItemTag) obj).internal.getType())); - // <--[tag] - // @Since 0.3.0 - // @Name ItemTag.quantity - // @Updated 2017/04/04 - // @Group Identification - // @ReturnType IntegerTag - // @Returns the amount of items in this stack. - // --> - handlers.put("quantity", (dat, obj) -> new IntegerTag(((ItemTag) obj).internal.getQuantity())); - // <--[tag] - // @Since 0.3.0 - // @Name ItemTag.max_stack_quantity - // @Updated 2017/04/04 - // @Group Identification - // @ReturnType IntegerTag - // @Returns the maximum amount of items of this type in a stack. - // --> - handlers.put("max_stack_quantity", (dat, obj) -> new IntegerTag(((ItemTag) obj).internal.getMaxStackQuantity())); // <--[tag] // @Since 0.3.0 // @Name ItemTag.data @@ -83,99 +56,52 @@ public ItemStack getInternal() { handlers.put("data", (dat, obj) -> DataKeys.getAllKeys(((ItemTag) obj).internal)); // <--[tag] // @Since 0.3.0 - // @Name ItemTag.get[] + // @Name ItemTag.flag[] // @Updated 2016/11/24 - // @Group General Information + // @Group Flag Data // @ReturnType Dynamic - // @Returns the value of the specified key on the entity. - // --> - handlers.put("get", (dat, obj) -> { - String keyName = dat.getNextModifier().toString(); - Key key = DataKeys.getKeyForName(keyName); - if (key == null) { - dat.error.run("Invalid key '" + keyName + "'!"); - return new NullTag(); - } - return DataKeys.getValue(((ItemTag) obj).internal, key, dat.error); - }); - // <--[tag] - // @Since 0.3.0 - // @Name ItemTag.without_flags[] - // @Updated 2017/02/13 - // @Group General Information - // @ReturnType ItemTag - // @Returns a copy of the item, with the specified flags removed. + // @Returns the flag of the specified key from the entity. May become TextTag regardless of input original type. + // Optionally don't specify anything to get the entire flag map. // --> - handlers.put("without_flags", (dat, obj) -> { + handlers.put("flag", (dat, obj) -> { MapTag flags; ItemStack e = ((ItemTag) obj).internal; Optional fm = e.get(FlagHelper.FLAGMAP); if (fm.isPresent()) { - flags = new MapTag(fm.get().flags.getInternal()); + flags = fm.get().flags; } else { flags = new MapTag(); } - ListTag toRemove = ListTag.getFor(dat.error, dat.getNextModifier()); - for (AbstractTagObject k : toRemove.getInternal()) { - flags.getInternal().remove(k.toString()); - } - ItemStack its = ((ItemTag) obj).internal.createSnapshot().createStack(); - its.offer(new FlagMapDataImpl(new FlagMap(flags))); - return new ItemTag(its); - }); - // <--[tag] - // @Since 0.3.0 - // @Name ItemTag.with_flags[] - // @Updated 2016/12/04 - // @Group General Information - // @ReturnType ItemTag - // @Returns a copy of the item, with the specified flag adjustments. - // --> - handlers.put("with_flags", (dat, obj) -> { - MapTag flags; - ItemStack e = ((ItemTag) obj).internal; - Optional fm = e.get(FlagHelper.FLAGMAP); - if (fm.isPresent()) { - flags = new MapTag(fm.get().flags.getInternal()); + if (!dat.hasNextModifier()) { + return flags; } - else { - flags = new MapTag(); + String flagName = CoreUtilities.toLowerCase(dat.getNextModifier().toString()); + AbstractTagObject ato = flags.getInternal().get(flagName); + if (ato == null) { + if (!dat.hasFallback()) { + dat.error.run("Invalid flag specified, not present on this item!"); + } + return new NullTag(); } - MapTag toApply = MapTag.getFor(dat.error, dat.getNextModifier()); - flags.getInternal().putAll(toApply.getInternal()); - ItemStack its = ((ItemTag) obj).internal.createSnapshot().createStack(); - its.offer(new FlagMapDataImpl(new FlagMap(flags))); - return new ItemTag(its); - }); - // <--[tag] - // @Since 0.3.0 - // @Name ItemTag.with_quantity[] - // @Updated 2016/12/04 - // @Group General Information - // @ReturnType ItemTag - // @Returns a copy of the item, with the specified quantity. - // --> - handlers.put("with_quantity", (dat, obj) -> { - ItemStack its = ((ItemTag) obj).internal.createSnapshot().createStack(); - its.setQuantity((int) IntegerTag.getFor(dat.error, dat.getNextModifier()).getInternal()); - return new ItemTag(its); + return ato; }); // <--[tag] // @Since 0.3.0 - // @Name ItemTag.with[] + // @Name ItemTag.get[] // @Updated 2016/11/24 // @Group General Information - // @ReturnType ItemTag - // @Returns a copy of the item, with the specified data adjustments. + // @ReturnType Dynamic + // @Returns the value of the specified key on the entity. // --> - handlers.put("with", (dat, obj) -> { - ItemStack its = ((ItemTag) obj).internal.createSnapshot().createStack(); - MapTag toApply = MapTag.getFor(dat.error, dat.getNextModifier()); - for (Map.Entry a : toApply.getInternal().entrySet()) { - DataKeys.tryApply(its, DataKeys.getKeyForName(a.getKey()), a.getValue(), dat.error); + handlers.put("get", (dat, obj) -> { + String keyName = dat.getNextModifier().toString(); + Key key = DataKeys.getKeyForName(keyName); + if (key == null) { + dat.error.run("Invalid key '" + keyName + "'!"); + return new NullTag(); } - return new ItemTag(its); + return DataKeys.getValue(((ItemTag) obj).internal, key, dat.error); }); // <--[tag] // @Since 0.3.0 @@ -200,64 +126,59 @@ public ItemStack getInternal() { }); // <--[tag] // @Since 0.3.0 - // @Name ItemTag.flag[] + // @Name ItemTag.item_type // @Updated 2016/11/24 - // @Group Flag Data - // @ReturnType Dynamic - // @Returns the flag of the specified key from the entity. May become TextTag regardless of input original type. - // Optionally don't specify anything to get the entire flag map. + // @Group Identification + // @ReturnType ItemTypeTag + // @Returns the type of the item. // --> - handlers.put("flag", (dat, obj) -> { - MapTag flags; - ItemStack e = ((ItemTag) obj).internal; - Optional fm = e.get(FlagHelper.FLAGMAP); - if (fm.isPresent()) { - flags = fm.get().flags; - } - else { - flags = new MapTag(); - } - if (!dat.hasNextModifier()) { - return flags; - } - String flagName = CoreUtilities.toLowerCase(dat.getNextModifier().toString()); - AbstractTagObject ato = flags.getInternal().get(flagName); - if (ato == null) { - if (!dat.hasFallback()) { - dat.error.run("Invalid flag specified, not present on this item!"); - } - return new NullTag(); - } - return ato; - }); + handlers.put("item_type", (dat, obj) -> new ItemTypeTag(((ItemTag) obj).internal.getType())); // <--[tag] // @Since 0.3.0 - // @Name ItemTag.skull_type + // @Name ItemTag.max_stack_quantity + // @Updated 2017/04/04 + // @Group Identification + // @ReturnType IntegerTag + // @Returns the maximum amount of items of this type in a stack. + // --> + handlers.put("max_stack_quantity", (dat, obj) -> new IntegerTag(((ItemTag) obj).internal.getMaxStackQuantity())); + // <--[tag] + // @Since 0.3.0 + // @Name ItemTag.quantity + // @Updated 2017/04/04 + // @Group Identification + // @ReturnType IntegerTag + // @Returns the amount of items in this stack. + // --> + handlers.put("quantity", (dat, obj) -> new IntegerTag(((ItemTag) obj).internal.getQuantity())); + // <--[tag] + // @Since 0.3.0 + // @Name ItemTag.represented_player_name // @Updated 2017/10/15 // @Group Properties // @ReturnType TextTag - // @Returns the type of skull this item is. + // @Returns the represented player's name of this skull item. // --> - handlers.put("skull_type", (dat, obj) -> { + handlers.put("represented_player_name", (dat, obj) -> { ItemStack item = ((ItemTag) obj).internal; Optional type = item.get(Keys.SKULL_TYPE); - if (!type.isPresent()) { + if (!type.isPresent() || type.get() != SkullTypes.PLAYER) { if (!dat.hasFallback()) { - dat.error.run("This item is not a skull!"); + dat.error.run("This item is not a player skull!"); } return new NullTag(); } - return new TextTag(type.get().getId()); + return new TextTag(item.get(Keys.REPRESENTED_PLAYER).get().getName().get()); }); // <--[tag] // @Since 0.3.0 - // @Name ItemTag.represented_player_name - // @Updated 2017/10/15 + // @Name ItemTag.represented_player_skin + // @Updated 2017/10/16 // @Group Properties // @ReturnType TextTag - // @Returns the represented player's name of this skull item. + // @Returns the represented player's skin of this skull item. // --> - handlers.put("represented_player_name", (dat, obj) -> { + handlers.put("represented_player_skin", (dat, obj) -> { ItemStack item = ((ItemTag) obj).internal; Optional type = item.get(Keys.SKULL_TYPE); if (!type.isPresent() || type.get() != SkullTypes.PLAYER) { @@ -266,7 +187,8 @@ public ItemStack getInternal() { } return new NullTag(); } - return new TextTag(item.get(Keys.REPRESENTED_PLAYER).get().getName().get()); + ProfileProperty p = item.get(Keys.REPRESENTED_PLAYER).get().getPropertyMap().get("textures").iterator().next(); + return new TextTag(p.getValue() + "|" + p.getSignature().get()); }); // <--[tag] // @Since 0.3.0 @@ -289,23 +211,101 @@ public ItemStack getInternal() { }); // <--[tag] // @Since 0.3.0 - // @Name ItemTag.represented_player_skin - // @Updated 2017/10/16 + // @Name ItemTag.skull_type + // @Updated 2017/10/15 // @Group Properties // @ReturnType TextTag - // @Returns the represented player's skin of this skull item. + // @Returns the type of skull this item is. // --> - handlers.put("represented_player_skin", (dat, obj) -> { + handlers.put("skull_type", (dat, obj) -> { ItemStack item = ((ItemTag) obj).internal; Optional type = item.get(Keys.SKULL_TYPE); - if (!type.isPresent() || type.get() != SkullTypes.PLAYER) { + if (!type.isPresent()) { if (!dat.hasFallback()) { - dat.error.run("This item is not a player skull!"); + dat.error.run("This item is not a skull!"); } return new NullTag(); } - ProfileProperty p = item.get(Keys.REPRESENTED_PLAYER).get().getPropertyMap().get("textures").iterator().next(); - return new TextTag(p.getValue() + "|" + p.getSignature().get()); + return new TextTag(type.get().getId()); + }); + // <--[tag] + // @Since 0.3.0 + // @Name ItemTag.with_flags[] + // @Updated 2016/12/04 + // @Group General Information + // @ReturnType ItemTag + // @Returns a copy of the item, with the specified flag adjustments. + // --> + handlers.put("with_flags", (dat, obj) -> { + MapTag flags; + ItemStack e = ((ItemTag) obj).internal; + Optional fm = e.get(FlagHelper.FLAGMAP); + if (fm.isPresent()) { + flags = new MapTag(fm.get().flags.getInternal()); + } + else { + flags = new MapTag(); + } + MapTag toApply = MapTag.getFor(dat.error, dat.getNextModifier()); + flags.getInternal().putAll(toApply.getInternal()); + ItemStack its = ((ItemTag) obj).internal.createSnapshot().createStack(); + its.offer(new FlagMapDataImpl(new FlagMap(flags))); + return new ItemTag(its); + }); + // <--[tag] + // @Since 0.3.0 + // @Name ItemTag.with_quantity[] + // @Updated 2016/12/04 + // @Group General Information + // @ReturnType ItemTag + // @Returns a copy of the item, with the specified quantity. + // --> + handlers.put("with_quantity", (dat, obj) -> { + ItemStack its = ((ItemTag) obj).internal.createSnapshot().createStack(); + its.setQuantity((int) IntegerTag.getFor(dat.error, dat.getNextModifier()).getInternal()); + return new ItemTag(its); + }); + // <--[tag] + // @Since 0.3.0 + // @Name ItemTag.with[] + // @Updated 2016/11/24 + // @Group General Information + // @ReturnType ItemTag + // @Returns a copy of the item, with the specified data adjustments. + // --> + handlers.put("with", (dat, obj) -> { + ItemStack its = ((ItemTag) obj).internal.createSnapshot().createStack(); + MapTag toApply = MapTag.getFor(dat.error, dat.getNextModifier()); + for (Map.Entry a : toApply.getInternal().entrySet()) { + DataKeys.tryApply(its, DataKeys.getKeyForName(a.getKey()), a.getValue(), dat.error); + } + return new ItemTag(its); + }); + // <--[tag] + // @Since 0.3.0 + // @Name ItemTag.without_flags[] + // @Updated 2017/02/13 + // @Group General Information + // @ReturnType ItemTag + // @Returns a copy of the item, with the specified flags removed. + // --> + handlers.put("without_flags", (dat, obj) -> { + MapTag flags; + ItemStack e = ((ItemTag) obj).internal; + Optional fm = e.get(FlagHelper.FLAGMAP); + if (fm.isPresent()) { + flags = new MapTag(fm.get().flags.getInternal()); + } + else { + flags = new MapTag(); + } + ListTag toRemove = ListTag.getFor(dat.error, dat.getNextModifier()); + for (AbstractTagObject k : toRemove.getInternal()) { + flags.getInternal().remove(k.toString()); + } + ItemStack its = ((ItemTag) obj).internal.createSnapshot().createStack(); + its.offer(new FlagMapDataImpl(new FlagMap(flags))); + return new ItemTag(its); }); }