diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/PropertyRegistry.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/PropertyRegistry.java index 9cdd68fd02..f9d5521453 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/PropertyRegistry.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/PropertyRegistry.java @@ -16,7 +16,6 @@ import com.denizenscript.denizencore.objects.core.ListTag; import com.denizenscript.denizencore.objects.core.QueueTag; import com.denizenscript.denizencore.objects.core.ScriptTag; -import com.denizenscript.denizencore.objects.properties.Property; import com.denizenscript.denizencore.objects.properties.PropertyParser; import dev.unizen.denizen.objects.properties.entity.*; import dev.unizen.denizen.objects.properties.material.*; @@ -161,7 +160,18 @@ public static void registermainProperties() { if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_13)) { PropertyParser.registerProperty(MaterialAge.class, MaterialTag.class); PropertyParser.registerProperty(MaterialAttached.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialBedSide.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialBrewingStandBottles.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialBubbleColumnDrag.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialCakeBites.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialChestType.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialCommandBlockConditional.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialComparatorMode.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialDaylightDetectorInverted.class, MaterialTag.class); PropertyParser.registerProperty(MaterialDirectional.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialDispenserTriggered.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialDoorHinge.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialEndPortalFrameEye.class, MaterialTag.class); PropertyParser.registerProperty(MaterialHalf.class, MaterialTag.class); PropertyParser.registerProperty(MaterialSlab.class, MaterialTag.class); PropertyParser.registerProperty(MaterialLeaves.class, MaterialTag.class); @@ -177,6 +187,11 @@ public static void registermainProperties() { PropertyParser.registerProperty(MaterialSwitchFace.class, MaterialTag.class); PropertyParser.registerProperty(MaterialWaterlogged.class, MaterialTag.class); } + if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_14)) { + PropertyParser.registerProperty(MaterialBambooLeaves.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialBellAttachment.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialCampfireSignal.class, MaterialTag.class); + } // register core TradeTag properties PropertyParser.registerProperty(TradeHasXp.class, TradeTag.class); diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java index 52881cbc4b..3ce307feb4 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java @@ -51,13 +51,14 @@ public ObjectTag getObjectAttribute(Attribute attribute) { } // <--[tag] - // @attribute + // @attribute // @returns ElementTag(Number) // @group properties // @description // Returns the maximum level for a levelable material (like water, lava, and Cauldrons), or a cake. + // NOTE: For cake materials, you may also use . // --> - if (attribute.startsWith("maximum_level")) { + if (attribute.startsWith("max_level") || attribute.startsWith("maximum_level")) { return new ElementTag(getMax()).getObjectAttribute(attribute.fulfill(1)); } @@ -68,6 +69,7 @@ public ObjectTag getObjectAttribute(Attribute attribute) { // @group properties // @description // Returns the current level for a levelable material (like water, lava, and Cauldrons), or a cake. + // NOTE: For cake materials, you may also use . // --> if (attribute.startsWith("level")) { return new ElementTag(getCurrent()).getObjectAttribute(attribute.fulfill(1)); @@ -112,7 +114,10 @@ public void setCurrent(int level) { @Override public String getPropertyString() { - return String.valueOf(getCurrent()); + if (isCake()) { + return null; + } + return getCurrent() != 0 ? String.valueOf(getCurrent()) : null; } @Override @@ -131,7 +136,7 @@ public void adjust(Mechanism mechanism) { // Sets the current level for a levelable material (like water, lava, and Cauldrons), or a cake. // @tags // - // + // // --> if (mechanism.matches("level") && mechanism.requireInteger()) { int level = mechanism.getValue().asInt(); diff --git a/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialBambooLeaves.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialBambooLeaves.java new file mode 100644 index 0000000000..82279c8f1a --- /dev/null +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialBambooLeaves.java @@ -0,0 +1,110 @@ +package dev.unizen.denizen.objects.properties.material; + +import com.denizenscript.denizen.objects.MaterialTag; +import com.denizenscript.denizencore.objects.Mechanism; +import com.denizenscript.denizencore.objects.ObjectTag; +import com.denizenscript.denizencore.objects.core.ElementTag; +import com.denizenscript.denizencore.objects.properties.Property; +import com.denizenscript.denizencore.tags.Attribute; +import org.bukkit.block.data.type.Bamboo; + +public class MaterialBambooLeaves implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Bamboo; + } + + public static MaterialBambooLeaves getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialBambooLeaves((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "bamboo_leaves" + }; + + public static final String[] handledMechs = new String[] { + "bamboo_leaves" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialBambooLeaves(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Bamboo getBamboo() { + return (Bamboo) material.getModernData().data; + } + + private String getLeaves() { + return getBamboo().getLeaves().name(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getBamboo().getLeaves() != Bamboo.Leaves.NONE ? getLeaves() : null; + } + + @Override + public String getPropertyId() { + return "bamboo_leaves"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag + // @mechanism MaterialTag.bamboo_leaves + // @group properties + // @description + // Returns the size of the leaves on this material, if the material is a bamboo block. + // Can be NONE, SMALL, or LARGE. + // --> + if (attribute.startsWith("bamboo_leaves")) { + return new ElementTag(getLeaves()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name bamboo_leaves + // @input ElementTag + // @description + // Sets the size of the leaves on this bamboo material. + // Can be NONE, SMALL, or LARGE. + // @tags + // + // --> + if (mechanism.matches("bamboo_leaves") && mechanism.requireEnum(false, Bamboo.Leaves.values())) { + getBamboo().setLeaves(Bamboo.Leaves.valueOf(mechanism.getValue().asString().toUpperCase())); + } + } +} diff --git a/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialBedSide.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialBedSide.java new file mode 100644 index 0000000000..452cb3a8e8 --- /dev/null +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialBedSide.java @@ -0,0 +1,120 @@ +package dev.unizen.denizen.objects.properties.material; + +import com.denizenscript.denizen.objects.MaterialTag; +import com.denizenscript.denizencore.objects.Mechanism; +import com.denizenscript.denizencore.objects.ObjectTag; +import com.denizenscript.denizencore.objects.core.ElementTag; +import com.denizenscript.denizencore.objects.properties.Property; +import com.denizenscript.denizencore.tags.Attribute; +import org.bukkit.block.data.type.Bed; + +public class MaterialBedSide implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Bed; + } + + public static MaterialBedSide getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialBedSide((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "bed_side", "occupied" + }; + + public static final String[] handledMechs = new String[] { + "bed_side" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialBedSide(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Bed getBed() { + return (Bed) material.getModernData().data; + } + + private String getSide() { + return getBed().getPart().name(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getSide(); + } + + @Override + public String getPropertyId() { + return "bed_side"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag + // @mechanism MaterialTag.bed_side + // @group properties + // @description + // If the material is a bed, returns which side of the bed it is. + // Can be either HEAD or FOOT. + // --> + if (attribute.startsWith("bed_side")) { + return new ElementTag(getSide()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @group properties + // @description + // If the material is a bed, returns whether it is occupied. + // --> + if (attribute.startsWith("occupied")) { + return new ElementTag(getBed().isOccupied()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name bed_side + // @input ElementTag + // @description + // If the material is a bed, sets which side of the bed the material is. + // @tags + // + // --> + if (mechanism.matches("bed_side") && mechanism.requireEnum(false, Bed.Part.values())) { + getBed().setPart(Bed.Part.valueOf(mechanism.getValue().asString().toUpperCase())); + } + } +} diff --git a/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialBellAttachment.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialBellAttachment.java new file mode 100644 index 0000000000..d2473f0a65 --- /dev/null +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialBellAttachment.java @@ -0,0 +1,110 @@ +package dev.unizen.denizen.objects.properties.material; + +import com.denizenscript.denizen.objects.MaterialTag; +import com.denizenscript.denizencore.objects.Mechanism; +import com.denizenscript.denizencore.objects.ObjectTag; +import com.denizenscript.denizencore.objects.core.ElementTag; +import com.denizenscript.denizencore.objects.properties.Property; +import com.denizenscript.denizencore.tags.Attribute; +import org.bukkit.block.data.type.Bell; + +public class MaterialBellAttachment implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Bell; + } + + public static MaterialBellAttachment getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialBellAttachment((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "bell_attachment" + }; + + public static final String[] handledMechs = new String[] { + "bell_attachment" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialBellAttachment(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Bell getBell() { + return (Bell) material.getModernData().data; + } + + private String getAttachment() { + return getBell().getAttachment().name(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getBell().getAttachment() != Bell.Attachment.FLOOR ? getAttachment() : null; + } + + @Override + public String getPropertyId() { + return "bell_attachment"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag + // @mechanism MaterialTag.bell_attachment + // @group properties + // @description + // If the material is a bell, returns the kind of attachment the material is using. + // Can be one of: <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/Bell.Attachment.html> + // --> + if (attribute.startsWith("bell_attachment")) { + return new ElementTag(getAttachment()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name bell_attachment + // @input ElementTag + // @description + // If the material is a bell, sets the kind of attachment the material will use. + // Can be one of: <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/Bell.Attachment.html> + // @tags + // + // --> + if (mechanism.matches("bell_attachment") && mechanism.requireEnum(false, Bell.Attachment.values())) { + getBell().setAttachment(Bell.Attachment.valueOf(mechanism.getValue().asString().toUpperCase())); + } + } +} diff --git a/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialBrewingStandBottles.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialBrewingStandBottles.java new file mode 100644 index 0000000000..ff89c4fdc1 --- /dev/null +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialBrewingStandBottles.java @@ -0,0 +1,190 @@ +package dev.unizen.denizen.objects.properties.material; + +import com.denizenscript.denizen.objects.MaterialTag; +import com.denizenscript.denizen.utilities.debugging.Debug; +import com.denizenscript.denizencore.objects.Mechanism; +import com.denizenscript.denizencore.objects.ObjectTag; +import com.denizenscript.denizencore.objects.core.ElementTag; +import com.denizenscript.denizencore.objects.core.ListTag; +import com.denizenscript.denizencore.objects.properties.Property; +import com.denizenscript.denizencore.tags.Attribute; +import org.bukkit.block.data.type.BrewingStand; + +public class MaterialBrewingStandBottles implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof BrewingStand; + } + + public static MaterialBrewingStandBottles getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialBrewingStandBottles((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "bottles", "has_bottles", "has_bottle", "max_bottles" + }; + + public static final String[] handledMechs = new String[] { + "bottles" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialBrewingStandBottles(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private BrewingStand getStand() { + return (BrewingStand) material.getModernData().data; + } + + private boolean hasBottles() { + return !getStand().getBottles().isEmpty(); + } + + private ListTag getBottles() { + ListTag output = new ListTag(); + for (int bottle : getStand().getBottles()) { + output.add(String.valueOf(bottle + 1)); + } + return output; + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return hasBottles() ? getBottles().identify() : null; + } + + @Override + public String getPropertyId() { + return "bottles"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the maximum number of bottles that can be on this brewing stand material. + // Currently, the maximum number of bottles a brewing stand can hold is 3. + // --> + if (attribute.startsWith("max_bottles") || attribute.startsWith("maximum_bottles")) { + return new ElementTag(getStand().getMaximumBottles()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @mechanism MaterialTag.bottles + // @group properties + // @description + // Returns whether this brewing stand material has any bottles in it. + // --> + if (attribute.startsWith("has_bottles")) { + return new ElementTag(hasBottles()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute ]> + // @returns ElementTag(Boolean) + // @mechanism MaterialTag.bottles + // @group properties + // @description + // Returns whether this brewing stand material has the specified bottle. + // The specified bottle can be either 1, 2, or 3. + // --> + if (attribute.startsWith("has_bottle") && attribute.hasContext(1)) { + ElementTag context = new ElementTag(attribute.getContext(1)); + if (!context.isInt()) { + Debug.echoError("The specified bottle must be 1, 2, or 3!"); + return null; + } + int bottle = context.asInt(); + if (bottle < 1 || bottle > 3) { + Debug.echoError("The specified bottle must be 1, 2, or 3!"); + return null; + } + return new ElementTag(getStand().hasBottle(bottle - 1)).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ListTag(Number) + // @mechanism MaterialTag.bottles + // @group properties + // @description + // Returns the indexes of all bottles present on this brewing stand material. + // --> + if (attribute.startsWith("bottles")) { + return new ListTag(getBottles()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name bottles + // @input ListTag(Number) + // @description + // If the material is a brewing stand, sets which bottles are present on it. + // The list must only contain the numbers 1, 2, and/or 3! + // @tags + // + // ]> + // + // + // --> + if (mechanism.matches("bottles")) { + boolean bottle1 = false; + boolean bottle2 = false; + boolean bottle3 = false; + for (String input : mechanism.valueAsType(ListTag.class)) { + ElementTag parsedInput = new ElementTag(input); + if (parsedInput.isInt()) { + switch (parsedInput.asInt()) { + case 1: + bottle1 = true; + break; + case 2: + bottle2 = true; + break; + case 3: + bottle3 = true; + break; + } + } + } + getStand().setBottle(0, bottle1); + getStand().setBottle(1, bottle2); + getStand().setBottle(2, bottle3); + } + } +} diff --git a/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialBubbleColumnDrag.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialBubbleColumnDrag.java new file mode 100644 index 0000000000..227cf85714 --- /dev/null +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialBubbleColumnDrag.java @@ -0,0 +1,110 @@ +package dev.unizen.denizen.objects.properties.material; + +import com.denizenscript.denizen.objects.MaterialTag; +import com.denizenscript.denizencore.objects.Mechanism; +import com.denizenscript.denizencore.objects.ObjectTag; +import com.denizenscript.denizencore.objects.core.ElementTag; +import com.denizenscript.denizencore.objects.properties.Property; +import com.denizenscript.denizencore.tags.Attribute; +import org.bukkit.block.data.type.BubbleColumn; + +public class MaterialBubbleColumnDrag implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof BubbleColumn; + } + + public static MaterialBubbleColumnDrag getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialBubbleColumnDrag((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "drags_down" + }; + + public static final String[] handledMechs = new String[] { + "drags_down" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialBubbleColumnDrag(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private BubbleColumn getBubbleColumn() { + return (BubbleColumn) material.getModernData().data; + } + + private boolean isDragging() { + return getBubbleColumn().isDrag(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return !isDragging() ? "false" : null; + } + + @Override + public String getPropertyId() { + return "drags_down"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @mechanism MaterialTag.drags_down + // @group properties + // @description + // Returns whether this bubble column material is dragging the player down. + // If false, then the material is pushing the player up. + // --> + if (attribute.startsWith("drags_down")) { + return new ElementTag(isDragging()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name drags_down + // @input ElementTag(Boolean) + // @description + // If the material is a bubble column, sets whether the material is dragging the player down. + // If false, then the material is pushing the player up. + // @tags + // + // --> + if (mechanism.matches("drags_down") && mechanism.requireBoolean()) { + getBubbleColumn().setDrag(mechanism.getValue().asBoolean()); + } + } +} diff --git a/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialCakeBites.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialCakeBites.java new file mode 100644 index 0000000000..0a187d6413 --- /dev/null +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialCakeBites.java @@ -0,0 +1,132 @@ +package dev.unizen.denizen.objects.properties.material; + +import com.denizenscript.denizen.objects.MaterialTag; +import com.denizenscript.denizen.utilities.debugging.Debug; +import com.denizenscript.denizencore.objects.Mechanism; +import com.denizenscript.denizencore.objects.ObjectTag; +import com.denizenscript.denizencore.objects.core.ElementTag; +import com.denizenscript.denizencore.objects.properties.Property; +import com.denizenscript.denizencore.tags.Attribute; +import org.bukkit.block.data.type.Cake; + +public class MaterialCakeBites implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Cake; + } + + public static MaterialCakeBites getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialCakeBites((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "bites", "max_bites" + }; + + public static final String[] handledMechs = new String[] { + "bites" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialCakeBites(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Cake getCake() { + return (Cake) material.getModernData().data; + } + + private int getBites() { + return getCake().getBites(); + } + + private int getMaxBites() { + return getCake().getMaximumBites(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getBites() != 0 ? String.valueOf(getBites()) : null; + } + + @Override + public String getPropertyId() { + return "bites"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // If the material is a cake, returns the maximum number of bites the material can have. + // --> + if (attribute.startsWith("max_bites") || attribute.startsWith("maximum_bites")) { + return new ElementTag(getMaxBites()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @mechanism MaterialTag.bites + // @group properties + // @description + // If the material is a cake, returns the number of bites the material has. + // 0 bites means the cake is untouched. + // --> + if (attribute.startsWith("bites")) { + return new ElementTag(getBites()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name bites + // @input ElementTag(Number) + // @description + // If the material is a cake, sets the number of bites the material has. + // 0 means the material is untouched. + // @tags + // + // + // --> + if (mechanism.matches("bites") && mechanism.requireInteger()) { + int value = mechanism.getValue().asInt(); + if (value < 0 || value > getMaxBites()) { + Debug.echoError("The number of cake bites must be between 0 and " + getMaxBites() + "!"); + return; + } + getCake().setBites(value); + } + } +} diff --git a/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialCampfireSignal.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialCampfireSignal.java new file mode 100644 index 0000000000..4d74c68567 --- /dev/null +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialCampfireSignal.java @@ -0,0 +1,108 @@ +package dev.unizen.denizen.objects.properties.material; + +import com.denizenscript.denizen.objects.MaterialTag; +import com.denizenscript.denizencore.objects.Mechanism; +import com.denizenscript.denizencore.objects.ObjectTag; +import com.denizenscript.denizencore.objects.core.ElementTag; +import com.denizenscript.denizencore.objects.properties.Property; +import com.denizenscript.denizencore.tags.Attribute; +import org.bukkit.block.data.type.Campfire; + +public class MaterialCampfireSignal implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Campfire; + } + + public static MaterialCampfireSignal getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialCampfireSignal((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "signal" + }; + + public static final String[] handledMechs = new String[] { + "signal" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialCampfireSignal(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Campfire getCampfire() { + return (Campfire) material.getModernData().data; + } + + private boolean isSignal() { + return getCampfire().isSignalFire(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return isSignal() ? "true" : null; + } + + @Override + public String getPropertyId() { + return "signal"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @mechanism MaterialTag.signal + // @group properties + // @description + // If the material is a campfire, returns if the material is a signal fire. + // --> + if (attribute.startsWith("signal")) { + return new ElementTag(isSignal()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name signal + // @input ElementTag(Boolean) + // @description + // If the material is a campfire, sets if the material is a signal fire. + // @tags + // + // --> + if (mechanism.matches("signal") && mechanism.requireBoolean()) { + getCampfire().setSignalFire(mechanism.getValue().asBoolean()); + } + } +} diff --git a/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialChestType.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialChestType.java new file mode 100644 index 0000000000..5f8773e52e --- /dev/null +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialChestType.java @@ -0,0 +1,110 @@ +package dev.unizen.denizen.objects.properties.material; + +import com.denizenscript.denizen.objects.MaterialTag; +import com.denizenscript.denizencore.objects.Mechanism; +import com.denizenscript.denizencore.objects.ObjectTag; +import com.denizenscript.denizencore.objects.core.ElementTag; +import com.denizenscript.denizencore.objects.properties.Property; +import com.denizenscript.denizencore.tags.Attribute; +import org.bukkit.block.data.type.Chest; + +public class MaterialChestType implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Chest; + } + + public static MaterialChestType getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialChestType((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "chest_type" + }; + + public static final String[] handledMechs = new String[] { + "chest_type" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialChestType(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Chest getChest() { + return (Chest) material.getModernData().data; + } + + private String getType() { + return getChest().getType().name(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getChest().getType() != Chest.Type.SINGLE ? getType() : null; + } + + @Override + public String getPropertyId() { + return "chest_type"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag + // @mechanism MaterialTag.chest_type + // @group properties + // @description + // If the material is a chest, returns what kind of chest it is. + // Can be SINGLE, LEFT, or RIGHT. If the type is LEFT or RIGHT, then the chest material is a half of a double chest. + // --> + if (attribute.startsWith("chest_type")) { + return new ElementTag(getType()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name chest_type + // @input ElementTag + // @description + // If the material is a chest, sets what kind of chest it is. + // Can be SINGLE, LEFT, or RIGHT. If the type is LEFT or RIGHT, then the chest material is a half of a double chest. + // @tags + // + // --> + if (mechanism.matches("chest_type") && mechanism.requireEnum(false, Chest.Type.values())) { + getChest().setType(Chest.Type.valueOf(mechanism.getValue().asString().toUpperCase())); + } + } +} diff --git a/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialCommandBlockConditional.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialCommandBlockConditional.java new file mode 100644 index 0000000000..ad08d0fd28 --- /dev/null +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialCommandBlockConditional.java @@ -0,0 +1,108 @@ +package dev.unizen.denizen.objects.properties.material; + +import com.denizenscript.denizen.objects.MaterialTag; +import com.denizenscript.denizencore.objects.Mechanism; +import com.denizenscript.denizencore.objects.ObjectTag; +import com.denizenscript.denizencore.objects.core.ElementTag; +import com.denizenscript.denizencore.objects.properties.Property; +import com.denizenscript.denizencore.tags.Attribute; +import org.bukkit.block.data.type.CommandBlock; + +public class MaterialCommandBlockConditional implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof CommandBlock; + } + + public static MaterialCommandBlockConditional getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialCommandBlockConditional((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "conditional" + }; + + public static final String[] handledMechs = new String[] { + "conditional" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialCommandBlockConditional(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private CommandBlock getCmdBlock() { + return (CommandBlock) material.getModernData().data; + } + + private boolean isConditional() { + return getCmdBlock().isConditional(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return isConditional() ? "true" : null; + } + + @Override + public String getPropertyId() { + return "conditional"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @mechanism MaterialTag.conditional + // @group properties + // @description + // If the material is a command block, returns whether this command block is conditional. + // --> + if (attribute.startsWith("conditional")) { + return new ElementTag(isConditional()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name conditional + // @input ElementTag(Boolean) + // @description + // If the material is a command block, sets whether this material is conditional. + // @tags + // + // --> + if (mechanism.matches("conditional") && mechanism.requireBoolean()) { + getCmdBlock().setConditional(mechanism.getValue().asBoolean()); + } + } +} diff --git a/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialComparatorMode.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialComparatorMode.java new file mode 100644 index 0000000000..f10f6b1fa3 --- /dev/null +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialComparatorMode.java @@ -0,0 +1,110 @@ +package dev.unizen.denizen.objects.properties.material; + +import com.denizenscript.denizen.objects.MaterialTag; +import com.denizenscript.denizencore.objects.Mechanism; +import com.denizenscript.denizencore.objects.ObjectTag; +import com.denizenscript.denizencore.objects.core.ElementTag; +import com.denizenscript.denizencore.objects.properties.Property; +import com.denizenscript.denizencore.tags.Attribute; +import org.bukkit.block.data.type.Comparator; + +public class MaterialComparatorMode implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Comparator; + } + + public static MaterialComparatorMode getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialComparatorMode((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "comparator_mode" + }; + + public static final String[] handledMechs = new String[] { + "comparator_mode" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialComparatorMode(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Comparator getComparator() { + return (Comparator) material.getModernData().data; + } + + private String getMode() { + return getComparator().getMode().name(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getComparator().getMode() != Comparator.Mode.COMPARE ? getMode() : null; + } + + @Override + public String getPropertyId() { + return "comparator_mode"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag + // @mechanism MaterialTag.comparator_mode + // @group properties + // @description + // If the material is a redstone comparator, returns the mode the material is in. + // Can be either COMPARE or SUBTRACT. + // --> + if (attribute.startsWith("comparator_mode")) { + return new ElementTag(getMode()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name comparator_mode + // @input ElementTag + // @description + // If the material is a redstone comparator, sets the mode the material is in. + // Can be either COMPARE or SUBTRACT. + // @tags + // + // --> + if (mechanism.matches("comparator_mode") && mechanism.requireEnum(false, Comparator.Mode.values())) { + getComparator().setMode(Comparator.Mode.valueOf(mechanism.getValue().asString().toUpperCase())); + } + } +} diff --git a/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialDaylightDetectorInverted.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialDaylightDetectorInverted.java new file mode 100644 index 0000000000..d714fbd14e --- /dev/null +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialDaylightDetectorInverted.java @@ -0,0 +1,112 @@ +package dev.unizen.denizen.objects.properties.material; + +import com.denizenscript.denizen.objects.MaterialTag; +import com.denizenscript.denizencore.objects.Mechanism; +import com.denizenscript.denizencore.objects.ObjectTag; +import com.denizenscript.denizencore.objects.core.ElementTag; +import com.denizenscript.denizencore.objects.properties.Property; +import com.denizenscript.denizencore.tags.Attribute; +import org.bukkit.block.data.type.DaylightDetector; + +public class MaterialDaylightDetectorInverted implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof DaylightDetector; + } + + public static MaterialDaylightDetectorInverted getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialDaylightDetectorInverted((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "inverted" + }; + + public static final String[] handledMechs = new String[] { + "inverted" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialDaylightDetectorInverted(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private DaylightDetector getDetector() { + return (DaylightDetector) material.getModernData().data; + } + + private boolean isInverted() { + return getDetector().isInverted(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return isInverted() ? "true" : null; + } + + @Override + public String getPropertyId() { + return "inverted"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @mechanism MaterialTag.inverted + // @group properties + // @description + // Returns whether the daylight detector material is inverted. + // If the material is inverted, it will activate in the absence of light. + // Otherwise, it activates in the presence of light. + // --> + if (attribute.startsWith("inverted")) { + return new ElementTag(isInverted()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name inverted + // @input ElementTag(Boolean) + // @description + // Sets whether the daylight detector material is inverted. + // If the material is inverted, it will activate in the absence of light. + // Otherwise, it activates in the presence of light. + // @tags + // + // --> + if (mechanism.matches("inverted") && mechanism.requireBoolean()) { + getDetector().setInverted(mechanism.getValue().asBoolean()); + } + } +} diff --git a/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialDispenserTriggered.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialDispenserTriggered.java new file mode 100644 index 0000000000..3043ebd949 --- /dev/null +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialDispenserTriggered.java @@ -0,0 +1,108 @@ +package dev.unizen.denizen.objects.properties.material; + +import com.denizenscript.denizen.objects.MaterialTag; +import com.denizenscript.denizencore.objects.Mechanism; +import com.denizenscript.denizencore.objects.ObjectTag; +import com.denizenscript.denizencore.objects.core.ElementTag; +import com.denizenscript.denizencore.objects.properties.Property; +import com.denizenscript.denizencore.tags.Attribute; +import org.bukkit.block.data.type.Dispenser; + +public class MaterialDispenserTriggered implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Dispenser; + } + + public static MaterialDispenserTriggered getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialDispenserTriggered((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "triggered" + }; + + public static final String[] handledMechs = new String[] { + "triggered" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialDispenserTriggered(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Dispenser getDispenser() { + return (Dispenser) material.getModernData().data; + } + + private boolean triggered() { + return getDispenser().isTriggered(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return triggered() ? "true" : null; + } + + @Override + public String getPropertyId() { + return "triggered"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @mechanism MaterialTag.triggered + // @group properties + // @description + // Returns whether the dispenser material is triggered. + // --> + if (attribute.startsWith("triggered")) { + return new ElementTag(triggered()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name triggered + // @input ElementTag(Boolean) + // @description + // Sets whether the dispenser material is triggered. + // @tags + // + // --> + if (mechanism.matches("triggered") && mechanism.requireBoolean()) { + getDispenser().setTriggered(mechanism.getValue().asBoolean()); + } + } +} diff --git a/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialDoorHinge.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialDoorHinge.java new file mode 100644 index 0000000000..40bd6a2f9a --- /dev/null +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialDoorHinge.java @@ -0,0 +1,110 @@ +package dev.unizen.denizen.objects.properties.material; + +import com.denizenscript.denizen.objects.MaterialTag; +import com.denizenscript.denizencore.objects.Mechanism; +import com.denizenscript.denizencore.objects.ObjectTag; +import com.denizenscript.denizencore.objects.core.ElementTag; +import com.denizenscript.denizencore.objects.properties.Property; +import com.denizenscript.denizencore.tags.Attribute; +import org.bukkit.block.data.type.Door; + +public class MaterialDoorHinge implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Door; + } + + public static MaterialDoorHinge getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialDoorHinge((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "hinge" + }; + + public static final String[] handledMechs = new String[] { + "hinge" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialDoorHinge(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Door getDoor() { + return (Door) material.getModernData().data; + } + + private String getHinge() { + return getDoor().getHinge().name(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getDoor().getHinge() != Door.Hinge.LEFT ? getHinge() : null; + } + + @Override + public String getPropertyId() { + return "hinge"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag + // @mechanism MaterialTag.hinge + // @group properties + // @description + // Returns which hinge the door material is using. + // Can be either LEFT or RIGHT. + // --> + if (attribute.startsWith("hinge")) { + return new ElementTag(getHinge()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name hinge + // @input ElementTag + // @description + // Sets the hinge the door material is using. + // Can be either LEFT or RIGHT. + // @tags + // + // --> + if (mechanism.matches("hinge") && mechanism.requireEnum(false, Door.Hinge.values())) { + getDoor().setHinge(Door.Hinge.valueOf(mechanism.getValue().asString().toUpperCase())); + } + } +} diff --git a/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialEndPortalFrameEye.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialEndPortalFrameEye.java new file mode 100644 index 0000000000..c3632dd8ee --- /dev/null +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialEndPortalFrameEye.java @@ -0,0 +1,108 @@ +package dev.unizen.denizen.objects.properties.material; + +import com.denizenscript.denizen.objects.MaterialTag; +import com.denizenscript.denizencore.objects.Mechanism; +import com.denizenscript.denizencore.objects.ObjectTag; +import com.denizenscript.denizencore.objects.core.ElementTag; +import com.denizenscript.denizencore.objects.properties.Property; +import com.denizenscript.denizencore.tags.Attribute; +import org.bukkit.block.data.type.EndPortalFrame; + +public class MaterialEndPortalFrameEye implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof EndPortalFrame; + } + + public static MaterialEndPortalFrameEye getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialEndPortalFrameEye((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "has_eye" + }; + + public static final String[] handledMechs = new String[] { + "has_eye" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialEndPortalFrameEye(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private EndPortalFrame getFrame() { + return (EndPortalFrame) material.getModernData().data; + } + + private boolean hasEye() { + return getFrame().hasEye(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return hasEye() ? "true" : null; + } + + @Override + public String getPropertyId() { + return "has_eye"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @mechanism MaterialTag.has_eye + // @group properties + // @description + // Returns whether this end portal frame material has an Eye of Ender in it. + // --> + if (attribute.startsWith("has_eye")) { + return new ElementTag(hasEye()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name has_eye + // @input ElementTag(Boolean) + // @description + // Sets whether this end portal frame material has an Eye of Ender in it. + // @tags + // + // --> + if (mechanism.matches("has_eye") && mechanism.requireBoolean()) { + getFrame().setEye(mechanism.getValue().asBoolean()); + } + } +}