Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Organize Tags
Browse files Browse the repository at this point in the history
Part 1
  • Loading branch information
Xenmai committed Nov 3, 2017
1 parent f68fe7a commit d250453
Show file tree
Hide file tree
Showing 4 changed files with 239 additions and 239 deletions.
Expand Up @@ -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[<LocationTag>]
// @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[<ListTag>]
// @Updated 2016/11/24
// @Group Connected Information
Expand Down Expand Up @@ -131,6 +90,47 @@ public boolean contains(UtilLocation point) {
}
return lt;
});
// <--[tag]
// @Since 0.3.0
// @Name CuboidTag.contains[<LocationTag>]
// @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<String> error, String text) {
Expand Down
Expand Up @@ -37,6 +37,16 @@ public Text getInternal() {
static {
// <--[tag]
// @Since 0.3.0
// @Name FormattedTextTag.append[<FormattedTextTag>]
// @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
Expand All @@ -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[<FormattedTextTag>]
// @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<String> error, String text) {
Expand Down
Expand Up @@ -56,22 +56,6 @@ public Inventory getInternal() {
public final static HashMap<String, Function2<TagData, AbstractTagObject, AbstractTagObject>> 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[<ItemTag>]
// @Updated 2017/06/17
// @Group General Information
Expand All @@ -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[<IntegerTag>]
// @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
Expand All @@ -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
Expand All @@ -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[<IntegerTag>]
// @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<String> error, String text) {
Expand Down

0 comments on commit d250453

Please sign in to comment.