From 6e8fa1bdd565c9676bcf6340791a4f8b600eac4a Mon Sep 17 00:00:00 2001 From: MusicScore <16635607+MusicScore@users.noreply.github.com> Date: Fri, 16 Aug 2019 16:59:51 -0400 Subject: [PATCH 1/2] Implement BlockFace.Type interfaces, part 3 Covers everything from redstone power onwards --- .../objects/properties/PropertyRegistry.java | 22 ++- .../material/MaterialRedstonePower.java | 131 ++++++++++++++++ .../material/MaterialRepeaterDelay.java | 146 +++++++++++++++++ .../material/MaterialSaplingStage.java | 131 ++++++++++++++++ .../material/MaterialScaffoldingBottom.java | 109 +++++++++++++ .../MaterialScaffoldingDistanceToBottom.java | 119 ++++++++++++++ .../material/MaterialSeaPickles.java | 146 +++++++++++++++++ .../properties/material/MaterialSlabType.java | 110 +++++++++++++ .../material/MaterialSnowLayers.java | 146 +++++++++++++++++ .../material/MaterialStairsShape.java | 110 +++++++++++++ .../material/MaterialStructureBlockMode.java | 110 +++++++++++++ .../material/MaterialTntUnstable.java | 110 +++++++++++++ .../material/MaterialTripwireDisarmed.java | 111 +++++++++++++ .../material/MaterialTurtleEggsAmount.java | 146 +++++++++++++++++ .../material/MaterialTurtleEggsHatch.java | 147 ++++++++++++++++++ 15 files changed, 1787 insertions(+), 7 deletions(-) create mode 100644 plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialRedstonePower.java create mode 100644 plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialRepeaterDelay.java create mode 100644 plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSaplingStage.java create mode 100644 plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialScaffoldingBottom.java create mode 100644 plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialScaffoldingDistanceToBottom.java create mode 100644 plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSeaPickles.java create mode 100644 plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSlabType.java create mode 100644 plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSnowLayers.java create mode 100644 plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialStairsShape.java create mode 100644 plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialStructureBlockMode.java create mode 100644 plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTntUnstable.java create mode 100644 plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTripwireDisarmed.java create mode 100644 plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTurtleEggsAmount.java create mode 100644 plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTurtleEggsHatch.java 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..0d017e72f1 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 @@ -167,15 +167,23 @@ public static void registermainProperties() { PropertyParser.registerProperty(MaterialLeaves.class, MaterialTag.class); PropertyParser.registerProperty(MaterialLevel.class, MaterialTag.class); PropertyParser.registerProperty(MaterialLightable.class, MaterialTag.class); - PropertyParser.registerProperty(MaterialMultipleFacing.class, MaterialTag.class); - PropertyParser.registerProperty(MaterialOpen.class, MaterialTag.class); - PropertyParser.registerProperty(MaterialOrientation.class, MaterialTag.class); - PropertyParser.registerProperty(MaterialRailShape.class, MaterialTag.class); PropertyParser.registerProperty(MaterialRedstonePower.class, MaterialTag.class); - PropertyParser.registerProperty(MaterialRotation.class, MaterialTag.class); - PropertyParser.registerProperty(MaterialSnowy.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialRepeaterDelay.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialSaplingStage.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialSeaPickles.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialSlabType.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialSnowLayers.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialStairsShape.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialStructureBlockMode.class, MaterialTag.class); PropertyParser.registerProperty(MaterialSwitchFace.class, MaterialTag.class); - PropertyParser.registerProperty(MaterialWaterlogged.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialTntUnstable.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialTripwireDisarmed.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialTurtleEggsAmount.class, MaterialTag.class); + PropertyParser.registerProperty(MaterialTurtleEggsHatch.class, MaterialTag.class); + } + if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_14)) { + PropertyParser.registerProperty(MaterialScaffoldingBottom.class,MaterialTag.class); + PropertyParser.registerProperty(MaterialScaffoldingDistanceToBottom.class, MaterialTag.class); } // register core TradeTag properties diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialRedstonePower.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialRedstonePower.java new file mode 100644 index 0000000000..d22f851bdf --- /dev/null +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialRedstonePower.java @@ -0,0 +1,131 @@ +package com.denizenscript.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.AnaloguePowerable; + +public class MaterialRedstonePower implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof AnaloguePowerable; + } + + public static MaterialRedstonePower getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialRedstonePower((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "redstone_power", "max_redstone_power" + }; + + public static final String[] handledMechs = new String[] { + "redstone_power" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialRedstonePower(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private AnaloguePowerable getPowerable() { + return (AnaloguePowerable) material.getModernData().data; + } + + private int getPower() { + return getPowerable().getPower(); + } + + private int getMaxPower() { + return getPowerable().getMaximumPower(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getPower() != 0 ? String.valueOf(getPower()) : null; + } + + @Override + public String getPropertyId() { + return "redstone_power"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @mechanism MaterialTag.redstone_power + // @group properties + // @description + // If the material can have redstone power sent through it, returns the current power sent by this material. + // --> + if (attribute.startsWith("redstone_power")) { + return new ElementTag(getPower()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @mechanism MaterialTag.power + // @group properties + // @description + // If the material can have redstone power sent through it, returns the maximum power that the material can send. + // --> + if (attribute.startsWith("max_redstone_power")) { + return new ElementTag(getMaxPower()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name redstone_power + // @input ElementTag(Number) + // @description + // Sets the redstone power the material sends, if it can send redstone power. + // @tags + // + // + // --> + if (mechanism.matches("redstone_power") && mechanism.requireInteger()) { + int power = mechanism.getValue().asInt(); + if (power < 0 || power > getMaxPower()) { + Debug.echoError("Redstone power for material '" + material.getMaterial().name() + "' must be between 0 and " + getMaxPower() + "!"); + return; + } + getPowerable().setPower(power); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialRepeaterDelay.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialRepeaterDelay.java new file mode 100644 index 0000000000..a8abf3a00a --- /dev/null +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialRepeaterDelay.java @@ -0,0 +1,146 @@ +package com.denizenscript.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.Repeater; + +public class MaterialRepeaterDelay implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Repeater; + } + + public static MaterialRepeaterDelay getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialRepeaterDelay((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "delay", "max_delay", "min_delay" + }; + + public static final String[] handledMechs = new String[] { + "delay" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialRepeaterDelay(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Repeater getRepeater() { + return (Repeater) material.getModernData().data; + } + + private int getDelay() { + return getRepeater().getDelay(); + } + + private int getMaxDelay() { + return getRepeater().getMaximumDelay(); + } + + private int getMinDelay() { + return getRepeater().getMinimumDelay(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getDelay() != getMinDelay() ? String.valueOf(getDelay()) : null; + } + + @Override + public String getPropertyId() { + return "delay"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the maximum delay the redstone repeater material can have. + // --> + if (attribute.startsWith("max_delay")) { + return new ElementTag(getMaxDelay()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the minimum delay the redstone repeater material can have. + // --> + if (attribute.startsWith("min_delay")) { + return new ElementTag(getMinDelay()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @mechanism MaterialTag.delay + // @group properties + // @description + // Returns the delay the redstone repeater material currently has. + // --> + if (attribute.startsWith("delay")) { + return new ElementTag(getDelay()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name delay + // @input ElementTag(Number) + // @description + // Sets the delay of the redstone repeater material. + // @tags + // + // + // + // --> + if (mechanism.matches("delay") && mechanism.requireInteger()) { + int delay = mechanism.getValue().asInt(); + if (delay < getMinDelay() || delay > getMaxDelay()) { + Debug.echoError("Invalid delay specified! Must be between '" + getMinDelay() + "' and '" + getMaxDelay() + "'!"); + return; + } + getRepeater().setDelay(delay); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSaplingStage.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSaplingStage.java new file mode 100644 index 0000000000..23894aeae9 --- /dev/null +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSaplingStage.java @@ -0,0 +1,131 @@ +package com.denizenscript.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.Sapling; + +public class MaterialSaplingStage implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Sapling; + } + + public static MaterialSaplingStage getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialSaplingStage((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "growth_stage", "max_growth_stage" + }; + + public static final String[] handledMechs = new String[] { + "growth_stage" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialSaplingStage(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Sapling getSapling() { + return (Sapling) material.getModernData().data; + } + + private int getStage() { + return getSapling().getStage(); + } + + private int getMaxStage() { + return getSapling().getMaximumStage(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getStage() != 0 ? String.valueOf(getStage()) : null; + } + + @Override + public String getPropertyId() { + return "growth_stage"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the maximum growth stage of the sapling or bamboo material. + // Once the material's growth stage reaches this number, the material will attempt to grow into a tree as its next stage. + // --> + if (attribute.startsWith("max_growth_stage")) { + return new ElementTag(getMaxStage()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @mechanism MaterialTag.growth_stage + // @group properties + // @description + // Returns the growth stage of the sapling or bamboo material. + // --> + if (attribute.startsWith("growth_stage")) { + return new ElementTag(getStage()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name growth_stage + // @input ElementTag(Number) + // @description + // Sets the growth stage of the sapling or bamboo material. + // @tags + // + // + // --> + if (mechanism.matches("growth_stage") && mechanism.requireInteger()) { + int stage = mechanism.getValue().asInt(); + if (stage < 0 || stage > getMaxStage()) { + Debug.echoError("The growth stage must be between '0' and '" + getMaxStage() + "'!"); + return; + } + getSapling().setStage(stage); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialScaffoldingBottom.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialScaffoldingBottom.java new file mode 100644 index 0000000000..6be3f9c1ab --- /dev/null +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialScaffoldingBottom.java @@ -0,0 +1,109 @@ +package com.denizenscript.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.Scaffolding; + +public class MaterialScaffoldingBottom implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Scaffolding; + } + + public static MaterialScaffoldingBottom getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialScaffoldingBottom((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "is_bottom" + }; + + public static final String[] handledMechs = new String[] { + "is_bottom" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialScaffoldingBottom(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Scaffolding getScaffolding() { + return (Scaffolding) material.getModernData().data; + } + + private boolean isBottom() { + return getScaffolding().isBottom(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return isBottom() ? "true" : null; + } + + @Override + public String getPropertyId() { + return "is_bottom"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @mechanism MaterialTag.is_bottom + // @group properties + // @description + // Returns whether this scaffolding material is a "bottom" scaffolding. + // If false, then the scaffolding should be on top of another scaffolding. + // --> + if (attribute.startsWith("is_bottom")) { + return new ElementTag(isBottom()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name is_bottom + // @input ElementTag(Boolean) + // @description + // Sets whether this scaffolding material is a "bottom" scaffolding. + // @tags + // + // --> + if (mechanism.matches("is_bottom") && mechanism.requireBoolean()) { + getScaffolding().setBottom(mechanism.getValue().asBoolean()); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialScaffoldingDistanceToBottom.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialScaffoldingDistanceToBottom.java new file mode 100644 index 0000000000..7c7eef5fc3 --- /dev/null +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialScaffoldingDistanceToBottom.java @@ -0,0 +1,119 @@ +package com.denizenscript.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.Scaffolding; + +public class MaterialScaffoldingDistanceToBottom implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Scaffolding; + } + + public static MaterialScaffoldingDistanceToBottom getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialScaffoldingDistanceToBottom((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "distance_to_bottom", "max_distance_to_bottom" + }; + + public static final String[] handledMechs = new String[] { + "distance_to_bottom" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialScaffoldingDistanceToBottom(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Scaffolding getScaffolding() { + return (Scaffolding) material.getModernData().data; + } + + private int getDistance() { + return getScaffolding().getDistance(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return !getScaffolding().isBottom() ? String.valueOf(getDistance()) : null; + } + + @Override + public String getPropertyId() { + return "distance_to_bottom"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @group properties + // @description + // Returns the maximum distance the scaffolding material can have from a "bottom" scaffolding. + // --> + if (attribute.startsWith("distance_to_bottom")) { + return new ElementTag(getDistance()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @mechanism MaterialTag.distance_to_bottom + // @group properties + // @description + // Returns how far the scaffolding material is from a "bottom" scaffolding. + // --> + if (attribute.startsWith("distance_to_bottom")) { + return new ElementTag(getDistance()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name distance_to_bottom + // @input ElementTag(Boolean) + // @description + // Sets how far the scaffolding material is from a "bottom" scaffolding. + // @tags + // + // --> + if (mechanism.matches("distance_to_bottom") && mechanism.requireInteger()) { + getScaffolding().setDistance(mechanism.getValue().asInt()); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSeaPickles.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSeaPickles.java new file mode 100644 index 0000000000..babc00c8e8 --- /dev/null +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSeaPickles.java @@ -0,0 +1,146 @@ +package com.denizenscript.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.SeaPickle; + +public class MaterialSeaPickles implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof SeaPickle; + } + + public static MaterialSeaPickles getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialSeaPickles((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "pickles", "min_pickles", "max_pickles" + }; + + public static final String[] handledMechs = new String[] { + "pickles" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialSeaPickles(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private SeaPickle getSeaPickle() { + return (SeaPickle) material.getModernData().data; + } + + private int getPickles() { + return getSeaPickle().getPickles(); + } + + private int getMinPickles() { + return getSeaPickle().getMinimumPickles(); + } + + private int getMaxPickles() { + return getSeaPickle().getMaximumPickles(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getPickles() != getMinPickles() ? String.valueOf(getPickles()) : null; + } + + @Override + public String getPropertyId() { + return "pickles"; + } + + /////////// + // 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 pickles the sea pickle material can have. + // --> + if (attribute.startsWith("min_pickles")) { + return new ElementTag(getMinPickles()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the minimum number of pickles the sea pickle material can have. + // --> + if (attribute.startsWith("max_pickles")) { + return new ElementTag(getMaxPickles()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @mechanism MaterialTag.pickles + // @group properties + // @description + // Returns how many pickles the sea pickle material has. + // --> + if (attribute.startsWith("pickles")) { + return new ElementTag(getPickles()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name pickles + // @input ElementTag(Number) + // @description + // Sets how many pickles the sea pickle material has. + // @tags + // + // + // + // --> + if (mechanism.matches("pickles") && mechanism.requireInteger()) { + int pickles = mechanism.getValue().asInt(); + if (pickles < getMinPickles() || pickles > getMaxPickles()) { + Debug.echoError("The number of pickles must be between '" + getMinPickles() + "' and '" + getMaxPickles() + "'!"); + return; + } + getSeaPickle().setPickles(pickles); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSlabType.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSlabType.java new file mode 100644 index 0000000000..346ee7704b --- /dev/null +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSlabType.java @@ -0,0 +1,110 @@ +package com.denizenscript.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.Slab; + +public class MaterialSlabType implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Slab; + } + + public static MaterialSlabType getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialSlabType((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "slab_type" + }; + + public static final String[] handledMechs = new String[] { + "slab_type" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialSlabType(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Slab getSlab() { + return (Slab) material.getModernData().data; + } + + private String getType() { + return getSlab().getType().name(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getSlab().getType() != Slab.Type.BOTTOM ? getType() : null; + } + + @Override + public String getPropertyId() { + return "slab_type"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag + // @mechanism MaterialTag.slab_type + // @group properties + // @description + // Returns the type of the slab material. + // Can be BOTTOM, TOP, or DOUBLE. + // --> + if (attribute.startsWith("slab_type")) { + return new ElementTag(getType()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name slab_type + // @input ElementTag + // @description + // Sets the type of the slab material. + // Can be BOTTOM, TOP, or DOUBLE. + // @tags + // + // --> + if (mechanism.matches("slab_type") && mechanism.requireEnum(false, Slab.Type.values())) { + getSlab().setType(Slab.Type.valueOf(mechanism.getValue().asString().toUpperCase())); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSnowLayers.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSnowLayers.java new file mode 100644 index 0000000000..97901da99f --- /dev/null +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSnowLayers.java @@ -0,0 +1,146 @@ +package com.denizenscript.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.Snow; + +public class MaterialSnowLayers implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Snow; + } + + public static MaterialSnowLayers getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialSnowLayers((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "snow_layers", "min_snow_layers", "max_snow_layers" + }; + + public static final String[] handledMechs = new String[] { + "snow_layers" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialSnowLayers(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Snow getSnow() { + return (Snow) material.getModernData().data; + } + + private int getLayers() { + return getSnow().getLayers(); + } + + private int getMinLayers() { + return getSnow().getMinimumLayers(); + } + + private int getMaxLayers() { + return getSnow().getMaximumLayers(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getLayers() != getMinLayers() ? String.valueOf(getLayers()) : null; + } + + @Override + public String getPropertyId() { + return "snow_layers"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the minimum amount of layers this snow layer material can have. + // --> + if (attribute.startsWith("min_snow_layers")) { + return new ElementTag(getMinLayers()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the maximum amount of layers this snow layer material can have. + // --> + if (attribute.startsWith("max_snow_layers")) { + return new ElementTag(getMaxLayers()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @mechanism MaterialTag.snow_layers + // @group properties + // @description + // Returns the amount of layers this snow layer material can have. + // --> + if (attribute.startsWith("snow_layers")) { + return new ElementTag(getLayers()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name snow_layers + // @input ElementTag(Number) + // @description + // Sets the amount of layers this snow layer can have. + // @tags + // + // + // + // --> + if (mechanism.matches("snow_layers") && mechanism.requireInteger()) { + int layers = mechanism.getValue().asInt(); + if (layers < getMinLayers() || layers > getMaxLayers()) { + Debug.echoError("The number of snow layers must be between '" + getMinLayers() + "' and '" + getMaxLayers() + "'!"); + return; + } + getSnow().setLayers(layers); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialStairsShape.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialStairsShape.java new file mode 100644 index 0000000000..b44902f5bb --- /dev/null +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialStairsShape.java @@ -0,0 +1,110 @@ +package com.denizenscript.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.Stairs; + +public class MaterialStairsShape implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Stairs; + } + + public static MaterialStairsShape getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialStairsShape((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "stair_shape" + }; + + public static final String[] handledMechs = new String[] { + "stair_shape" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialStairsShape(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Stairs getStairs() { + return (Stairs) material.getModernData().data; + } + + private String getShape() { + return getStairs().getShape().name(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getStairs().getShape() != Stairs.Shape.STRAIGHT ? getShape() : null; + } + + @Override + public String getPropertyId() { + return "stair_shape"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag + // @mechanism MaterialTag.stair_shape + // @group properties + // @description + // Returns the shape of the stairs material. + // Can be any of: <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/Stairs.Shape.html> + // --> + if (attribute.startsWith("stair_shape")) { + return new ElementTag(getShape()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name stair_shape + // @input ElementTag + // @description + // Sets the shape of the stairs material. + // Can be any of: <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/Stairs.Shape.html> + // @tags + // + // --> + if (mechanism.matches("stair_shape") && mechanism.requireEnum(false, Stairs.Shape.values())) { + getStairs().setShape(Stairs.Shape.valueOf(mechanism.getValue().asString().toUpperCase())); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialStructureBlockMode.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialStructureBlockMode.java new file mode 100644 index 0000000000..4e3852119b --- /dev/null +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialStructureBlockMode.java @@ -0,0 +1,110 @@ +package com.denizenscript.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.StructureBlock; + +public class MaterialStructureBlockMode implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof StructureBlock; + } + + public static MaterialStructureBlockMode getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialStructureBlockMode((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "mode" + }; + + public static final String[] handledMechs = new String[] { + "mode" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialStructureBlockMode(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private StructureBlock getStructureBlock() { + return (StructureBlock) material.getModernData().data; + } + + private String getMode() { + return getStructureBlock().getMode().name(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getMode(); + } + + @Override + public String getPropertyId() { + return "mode"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag + // @mechanism MaterialTag.mode + // @group properties + // @description + // Returns the mode of the structure block material. + // Can be any of: <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/StructureBlock.Mode.html> + // --> + if (attribute.startsWith("mode")) { + return new ElementTag(getMode()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name mode + // @input ElementTag + // @description + // Sets the mode of the structure block material. + // Can be any of: <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/StructureBlock.Mode.html> + // @tags + // + // --> + if (mechanism.matches("mode") && mechanism.requireEnum(false, StructureBlock.Mode.values())) { + getStructureBlock().setMode(StructureBlock.Mode.valueOf(mechanism.getValue().asString().toUpperCase())); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTntUnstable.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTntUnstable.java new file mode 100644 index 0000000000..732738e0c6 --- /dev/null +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTntUnstable.java @@ -0,0 +1,110 @@ +package com.denizenscript.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.TNT; + +public class MaterialTntUnstable implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof TNT; + } + + public static MaterialTntUnstable getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialTntUnstable((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "unstable" + }; + + public static final String[] handledMechs = new String[] { + "unstable" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialTntUnstable(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private TNT getTnt() { + return (TNT) material.getModernData().data; + } + + private boolean isUnstable() { + return getTnt().isUnstable(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return isUnstable() ? "true" : null; + } + + @Override + public String getPropertyId() { + return "unstable"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @mechanism MaterialTag.unstable + // @group properties + // @description + // Returns whether the TNT material is unstable. + // If true, then punching the material will cause it to explode. + // --> + if (attribute.startsWith("unstable")) { + return new ElementTag(isUnstable()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name unstable + // @input ElementTag(Boolean) + // @description + // Sets whether the TNT material is unstable. + // If true, then punching the material will cause it to explode. + // @tags + // + // --> + if (mechanism.matches("unstable") && mechanism.requireBoolean()) { + getTnt().setUnstable(mechanism.getValue().asBoolean()); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTripwireDisarmed.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTripwireDisarmed.java new file mode 100644 index 0000000000..1528f94938 --- /dev/null +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTripwireDisarmed.java @@ -0,0 +1,111 @@ +package com.denizenscript.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.Tripwire; + +public class MaterialTripwireDisarmed implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Tripwire; + } + + public static MaterialTripwireDisarmed getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialTripwireDisarmed((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "disarmed" + }; + + public static final String[] handledMechs = new String[] { + "disarmed" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialTripwireDisarmed(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Tripwire getTripwire() { + return (Tripwire) material.getModernData().data; + } + + private boolean isDisarmed() { + return getTripwire().isDisarmed(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + // The natural state of a tripwire string is disarmed. + return !isDisarmed() ? "false" : null; + } + + @Override + public String getPropertyId() { + return "disarmed"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @mechanism MaterialTag.disarmed + // @group properties + // @description + // Returns whether this tripwire material is disarmed. + // If true, then breaking the material will not produce a current. + // --> + if (attribute.startsWith("disarmed")) { + return new ElementTag(isDisarmed()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name disarmed + // @input ElementTag(Boolean) + // @description + // Sets whether this tripwire material is disarmed. + // If true, then breaking the material will not produce a current. + // @tags + // + // --> + if (mechanism.matches("disarmed") && mechanism.requireBoolean()) { + getTripwire().setDisarmed(mechanism.getValue().asBoolean()); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTurtleEggsAmount.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTurtleEggsAmount.java new file mode 100644 index 0000000000..e761b25db6 --- /dev/null +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTurtleEggsAmount.java @@ -0,0 +1,146 @@ +package com.denizenscript.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.TurtleEgg; + +public class MaterialTurtleEggsAmount implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof TurtleEgg; + } + + public static MaterialTurtleEggsAmount getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialTurtleEggsAmount((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "eggs" + }; + + public static final String[] handledMechs = new String[] { + "eggs" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialTurtleEggsAmount(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private TurtleEgg getTurtleEgg() { + return (TurtleEgg) material.getModernData().data; + } + + private int getAmount() { + return getTurtleEgg().getEggs(); + } + + private int getMinAmount() { + return getTurtleEgg().getMinimumEggs(); + } + + private int getMaxAmount() { + return getTurtleEgg().getMaximumEggs(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getAmount() != getMinAmount() ? String.valueOf(getAmount()) : null; + } + + @Override + public String getPropertyId() { + return "eggs"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the minimum number of eggs that the turtle egg material can have. + // --> + if (attribute.startsWith("min_eggs")) { + return new ElementTag(getMinAmount()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the maximum number of eggs that the turtle egg material can have. + // --> + if (attribute.startsWith("max_eggs")) { + return new ElementTag(getMaxAmount()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @mechanism MaterialTag.eggs + // @group properties + // @description + // Returns the number of eggs that the turtle egg material has. + // --> + if (attribute.startsWith("eggs")) { + return new ElementTag(getAmount()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name eggs + // @input ElementTag(Number) + // @description + // Sets how many eggs this turtle egg material has. + // @tags + // + // + // + // --> + if (mechanism.matches("eggs") && mechanism.requireInteger()) { + int eggs = mechanism.getValue().asInt(); + if (eggs < getMinAmount() || eggs > getMaxAmount()) { + Debug.echoError("The egg count must be between '" + getMinAmount() + "' and '" + getMaxAmount() + "'!"); + return; + } + getTurtleEgg().setEggs(eggs); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTurtleEggsHatch.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTurtleEggsHatch.java new file mode 100644 index 0000000000..dd735d8742 --- /dev/null +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTurtleEggsHatch.java @@ -0,0 +1,147 @@ +package com.denizenscript.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.TurtleEgg; + +public class MaterialTurtleEggsHatch implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof TurtleEgg; + } + + public static MaterialTurtleEggsHatch getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialTurtleEggsHatch((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "hatch", "min_hatch", "max_hatch" + }; + + public static final String[] handledMechs = new String[] { + "hatch" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialTurtleEggsHatch(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private TurtleEgg getTurtleEgg() { + return (TurtleEgg) material.getModernData().data; + } + + private int getHatch() { + return getTurtleEgg().getHatch(); + } + + private int getMinHatch() { + return getTurtleEgg().getMinimumEggs(); + } + + private int getMaxHatch() { + return getTurtleEgg().getMaximumHatch(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getHatch() != getMinHatch() ? String.valueOf(getHatch()) : null; + } + + @Override + public String getPropertyId() { + return "hatch"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the minimum value that the hatch property of the turtle egg material may have. + // --> + if (attribute.startsWith("min_hatch")) { + return new ElementTag(getMinHatch()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the maximum value that the hatch property of the turtle egg material may have. + // --> + if (attribute.startsWith("max_hatch")) { + return new ElementTag(getMaxHatch()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @mechanism MaterialTag.hatch + // @group properties + // @description + // Returns the value of the hatch property of the turtle egg material. + // --> + if (attribute.startsWith("hatch")) { + return new ElementTag(getHatch()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name hatch + // @input ElementTag(Number) + // @description + // Sets the value of the hatch property of the turtle egg material. + // When the hatch value is at the maximum allowed value, the turtle egg will be very close to hatching. + // @tags + // + // + // + // --> + if (mechanism.matches("hatch") && mechanism.requireInteger()) { + int hatch = mechanism.getValue().asInt(); + if (hatch < getMinHatch() || hatch > getMinHatch()) { + Debug.echoError("The value of the hatch property must be between '" + getMinHatch() + "' and '" + getMaxHatch() + "'!"); + return; + } + getTurtleEgg().setHatch(hatch); + } + } +} From 498fb6002808838f13db8eb846f6bee10f2620f8 Mon Sep 17 00:00:00 2001 From: MusicScore <16635607+MusicScore@users.noreply.github.com> Date: Tue, 15 Oct 2019 13:11:17 -0400 Subject: [PATCH 2/2] Move new files to new package, remove slab property Slab material property was added upstream --- .../objects/properties/PropertyRegistry.java | 2 - .../material/MaterialRedstonePower.java | 131 -------- .../properties/material/MaterialSlabType.java | 110 ------- .../material/MaterialRepeaterDelay.java | 292 ++++++++--------- .../material/MaterialSaplingStage.java | 262 ++++++++-------- .../material/MaterialScaffoldingBottom.java | 218 ++++++------- .../MaterialScaffoldingDistanceToBottom.java | 238 +++++++------- .../material/MaterialSeaPickles.java | 292 ++++++++--------- .../material/MaterialSnowLayers.java | 292 ++++++++--------- .../material/MaterialStairsShape.java | 220 ++++++------- .../material/MaterialStructureBlockMode.java | 220 ++++++------- .../material/MaterialTntUnstable.java | 220 ++++++------- .../material/MaterialTripwireDisarmed.java | 222 ++++++------- .../material/MaterialTurtleEggsAmount.java | 292 ++++++++--------- .../material/MaterialTurtleEggsHatch.java | 294 +++++++++--------- 15 files changed, 1531 insertions(+), 1774 deletions(-) delete mode 100644 plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialRedstonePower.java delete mode 100644 plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSlabType.java rename plugin/src/main/java/{com/denizenscript => dev/unizen}/denizen/objects/properties/material/MaterialRepeaterDelay.java (95%) rename plugin/src/main/java/{com/denizenscript => dev/unizen}/denizen/objects/properties/material/MaterialSaplingStage.java (95%) rename plugin/src/main/java/{com/denizenscript => dev/unizen}/denizen/objects/properties/material/MaterialScaffoldingBottom.java (94%) rename plugin/src/main/java/{com/denizenscript => dev/unizen}/denizen/objects/properties/material/MaterialScaffoldingDistanceToBottom.java (95%) rename plugin/src/main/java/{com/denizenscript => dev/unizen}/denizen/objects/properties/material/MaterialSeaPickles.java (95%) rename plugin/src/main/java/{com/denizenscript => dev/unizen}/denizen/objects/properties/material/MaterialSnowLayers.java (95%) rename plugin/src/main/java/{com/denizenscript => dev/unizen}/denizen/objects/properties/material/MaterialStairsShape.java (94%) rename plugin/src/main/java/{com/denizenscript => dev/unizen}/denizen/objects/properties/material/MaterialStructureBlockMode.java (94%) rename plugin/src/main/java/{com/denizenscript => dev/unizen}/denizen/objects/properties/material/MaterialTntUnstable.java (94%) rename plugin/src/main/java/{com/denizenscript => dev/unizen}/denizen/objects/properties/material/MaterialTripwireDisarmed.java (94%) rename plugin/src/main/java/{com/denizenscript => dev/unizen}/denizen/objects/properties/material/MaterialTurtleEggsAmount.java (95%) rename plugin/src/main/java/{com/denizenscript => dev/unizen}/denizen/objects/properties/material/MaterialTurtleEggsHatch.java (95%) 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 0d017e72f1..2f12a493c1 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.*; @@ -171,7 +170,6 @@ public static void registermainProperties() { PropertyParser.registerProperty(MaterialRepeaterDelay.class, MaterialTag.class); PropertyParser.registerProperty(MaterialSaplingStage.class, MaterialTag.class); PropertyParser.registerProperty(MaterialSeaPickles.class, MaterialTag.class); - PropertyParser.registerProperty(MaterialSlabType.class, MaterialTag.class); PropertyParser.registerProperty(MaterialSnowLayers.class, MaterialTag.class); PropertyParser.registerProperty(MaterialStairsShape.class, MaterialTag.class); PropertyParser.registerProperty(MaterialStructureBlockMode.class, MaterialTag.class); diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialRedstonePower.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialRedstonePower.java deleted file mode 100644 index d22f851bdf..0000000000 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialRedstonePower.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.denizenscript.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.AnaloguePowerable; - -public class MaterialRedstonePower implements Property { - - public static boolean describes(ObjectTag material) { - return material instanceof MaterialTag - && ((MaterialTag) material).hasModernData() - && ((MaterialTag) material).getModernData().data instanceof AnaloguePowerable; - } - - public static MaterialRedstonePower getFrom(ObjectTag material) { - if (!describes(material)) { - return null; - } - return new MaterialRedstonePower((MaterialTag) material); - } - - public static final String[] handledTags = new String[] { - "redstone_power", "max_redstone_power" - }; - - public static final String[] handledMechs = new String[] { - "redstone_power" - }; - - - /////////////////// - // Instance Fields and Methods - ///////////// - - private MaterialRedstonePower(MaterialTag material) { - this.material = material; - } - - private MaterialTag material; - - private AnaloguePowerable getPowerable() { - return (AnaloguePowerable) material.getModernData().data; - } - - private int getPower() { - return getPowerable().getPower(); - } - - private int getMaxPower() { - return getPowerable().getMaximumPower(); - } - - ///////// - // Property Methods - /////// - - @Override - public String getPropertyString() { - return getPower() != 0 ? String.valueOf(getPower()) : null; - } - - @Override - public String getPropertyId() { - return "redstone_power"; - } - - /////////// - // ObjectTag Attributes - //////// - - @Override - public String getAttribute(Attribute attribute) { - if (attribute == null) { - return null; - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @mechanism MaterialTag.redstone_power - // @group properties - // @description - // If the material can have redstone power sent through it, returns the current power sent by this material. - // --> - if (attribute.startsWith("redstone_power")) { - return new ElementTag(getPower()).getAttribute(attribute.fulfill(1)); - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @mechanism MaterialTag.power - // @group properties - // @description - // If the material can have redstone power sent through it, returns the maximum power that the material can send. - // --> - if (attribute.startsWith("max_redstone_power")) { - return new ElementTag(getMaxPower()).getAttribute(attribute.fulfill(1)); - } - - return null; - } - - @Override - public void adjust(Mechanism mechanism) { - - // <--[mechanism] - // @object MaterialTag - // @name redstone_power - // @input ElementTag(Number) - // @description - // Sets the redstone power the material sends, if it can send redstone power. - // @tags - // - // - // --> - if (mechanism.matches("redstone_power") && mechanism.requireInteger()) { - int power = mechanism.getValue().asInt(); - if (power < 0 || power > getMaxPower()) { - Debug.echoError("Redstone power for material '" + material.getMaterial().name() + "' must be between 0 and " + getMaxPower() + "!"); - return; - } - getPowerable().setPower(power); - } - } -} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSlabType.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSlabType.java deleted file mode 100644 index 346ee7704b..0000000000 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSlabType.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.denizenscript.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.Slab; - -public class MaterialSlabType implements Property { - - public static boolean describes(ObjectTag material) { - return material instanceof MaterialTag - && ((MaterialTag) material).hasModernData() - && ((MaterialTag) material).getModernData().data instanceof Slab; - } - - public static MaterialSlabType getFrom(ObjectTag material) { - if (!describes(material)) { - return null; - } - return new MaterialSlabType((MaterialTag) material); - } - - public static final String[] handledTags = new String[] { - "slab_type" - }; - - public static final String[] handledMechs = new String[] { - "slab_type" - }; - - - /////////////////// - // Instance Fields and Methods - ///////////// - - private MaterialSlabType(MaterialTag material) { - this.material = material; - } - - private MaterialTag material; - - private Slab getSlab() { - return (Slab) material.getModernData().data; - } - - private String getType() { - return getSlab().getType().name(); - } - - ///////// - // Property Methods - /////// - - @Override - public String getPropertyString() { - return getSlab().getType() != Slab.Type.BOTTOM ? getType() : null; - } - - @Override - public String getPropertyId() { - return "slab_type"; - } - - /////////// - // ObjectTag Attributes - //////// - - @Override - public String getAttribute(Attribute attribute) { - if (attribute == null) { - return null; - } - - // <--[tag] - // @attribute - // @returns ElementTag - // @mechanism MaterialTag.slab_type - // @group properties - // @description - // Returns the type of the slab material. - // Can be BOTTOM, TOP, or DOUBLE. - // --> - if (attribute.startsWith("slab_type")) { - return new ElementTag(getType()).getAttribute(attribute.fulfill(1)); - } - - return null; - } - - @Override - public void adjust(Mechanism mechanism) { - - // <--[mechanism] - // @object MaterialTag - // @name slab_type - // @input ElementTag - // @description - // Sets the type of the slab material. - // Can be BOTTOM, TOP, or DOUBLE. - // @tags - // - // --> - if (mechanism.matches("slab_type") && mechanism.requireEnum(false, Slab.Type.values())) { - getSlab().setType(Slab.Type.valueOf(mechanism.getValue().asString().toUpperCase())); - } - } -} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialRepeaterDelay.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialRepeaterDelay.java similarity index 95% rename from plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialRepeaterDelay.java rename to plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialRepeaterDelay.java index a8abf3a00a..883ddb14ca 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialRepeaterDelay.java +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialRepeaterDelay.java @@ -1,146 +1,146 @@ -package com.denizenscript.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.Repeater; - -public class MaterialRepeaterDelay implements Property { - - public static boolean describes(ObjectTag material) { - return material instanceof MaterialTag - && ((MaterialTag) material).hasModernData() - && ((MaterialTag) material).getModernData().data instanceof Repeater; - } - - public static MaterialRepeaterDelay getFrom(ObjectTag material) { - if (!describes(material)) { - return null; - } - return new MaterialRepeaterDelay((MaterialTag) material); - } - - public static final String[] handledTags = new String[] { - "delay", "max_delay", "min_delay" - }; - - public static final String[] handledMechs = new String[] { - "delay" - }; - - - /////////////////// - // Instance Fields and Methods - ///////////// - - private MaterialRepeaterDelay(MaterialTag material) { - this.material = material; - } - - private MaterialTag material; - - private Repeater getRepeater() { - return (Repeater) material.getModernData().data; - } - - private int getDelay() { - return getRepeater().getDelay(); - } - - private int getMaxDelay() { - return getRepeater().getMaximumDelay(); - } - - private int getMinDelay() { - return getRepeater().getMinimumDelay(); - } - - ///////// - // Property Methods - /////// - - @Override - public String getPropertyString() { - return getDelay() != getMinDelay() ? String.valueOf(getDelay()) : null; - } - - @Override - public String getPropertyId() { - return "delay"; - } - - /////////// - // ObjectTag Attributes - //////// - - @Override - public String getAttribute(Attribute attribute) { - if (attribute == null) { - return null; - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @group properties - // @description - // Returns the maximum delay the redstone repeater material can have. - // --> - if (attribute.startsWith("max_delay")) { - return new ElementTag(getMaxDelay()).getAttribute(attribute.fulfill(1)); - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @group properties - // @description - // Returns the minimum delay the redstone repeater material can have. - // --> - if (attribute.startsWith("min_delay")) { - return new ElementTag(getMinDelay()).getAttribute(attribute.fulfill(1)); - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @mechanism MaterialTag.delay - // @group properties - // @description - // Returns the delay the redstone repeater material currently has. - // --> - if (attribute.startsWith("delay")) { - return new ElementTag(getDelay()).getAttribute(attribute.fulfill(1)); - } - - return null; - } - - @Override - public void adjust(Mechanism mechanism) { - - // <--[mechanism] - // @object MaterialTag - // @name delay - // @input ElementTag(Number) - // @description - // Sets the delay of the redstone repeater material. - // @tags - // - // - // - // --> - if (mechanism.matches("delay") && mechanism.requireInteger()) { - int delay = mechanism.getValue().asInt(); - if (delay < getMinDelay() || delay > getMaxDelay()) { - Debug.echoError("Invalid delay specified! Must be between '" + getMinDelay() + "' and '" + getMaxDelay() + "'!"); - return; - } - getRepeater().setDelay(delay); - } - } -} +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.Repeater; + +public class MaterialRepeaterDelay implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Repeater; + } + + public static MaterialRepeaterDelay getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialRepeaterDelay((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "delay", "max_delay", "min_delay" + }; + + public static final String[] handledMechs = new String[] { + "delay" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialRepeaterDelay(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Repeater getRepeater() { + return (Repeater) material.getModernData().data; + } + + private int getDelay() { + return getRepeater().getDelay(); + } + + private int getMaxDelay() { + return getRepeater().getMaximumDelay(); + } + + private int getMinDelay() { + return getRepeater().getMinimumDelay(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getDelay() != getMinDelay() ? String.valueOf(getDelay()) : null; + } + + @Override + public String getPropertyId() { + return "delay"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the maximum delay the redstone repeater material can have. + // --> + if (attribute.startsWith("max_delay")) { + return new ElementTag(getMaxDelay()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the minimum delay the redstone repeater material can have. + // --> + if (attribute.startsWith("min_delay")) { + return new ElementTag(getMinDelay()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @mechanism MaterialTag.delay + // @group properties + // @description + // Returns the delay the redstone repeater material currently has. + // --> + if (attribute.startsWith("delay")) { + return new ElementTag(getDelay()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name delay + // @input ElementTag(Number) + // @description + // Sets the delay of the redstone repeater material. + // @tags + // + // + // + // --> + if (mechanism.matches("delay") && mechanism.requireInteger()) { + int delay = mechanism.getValue().asInt(); + if (delay < getMinDelay() || delay > getMaxDelay()) { + Debug.echoError("Invalid delay specified! Must be between '" + getMinDelay() + "' and '" + getMaxDelay() + "'!"); + return; + } + getRepeater().setDelay(delay); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSaplingStage.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialSaplingStage.java similarity index 95% rename from plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSaplingStage.java rename to plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialSaplingStage.java index 23894aeae9..ef37d64c4b 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSaplingStage.java +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialSaplingStage.java @@ -1,131 +1,131 @@ -package com.denizenscript.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.Sapling; - -public class MaterialSaplingStage implements Property { - - public static boolean describes(ObjectTag material) { - return material instanceof MaterialTag - && ((MaterialTag) material).hasModernData() - && ((MaterialTag) material).getModernData().data instanceof Sapling; - } - - public static MaterialSaplingStage getFrom(ObjectTag material) { - if (!describes(material)) { - return null; - } - return new MaterialSaplingStage((MaterialTag) material); - } - - public static final String[] handledTags = new String[] { - "growth_stage", "max_growth_stage" - }; - - public static final String[] handledMechs = new String[] { - "growth_stage" - }; - - - /////////////////// - // Instance Fields and Methods - ///////////// - - private MaterialSaplingStage(MaterialTag material) { - this.material = material; - } - - private MaterialTag material; - - private Sapling getSapling() { - return (Sapling) material.getModernData().data; - } - - private int getStage() { - return getSapling().getStage(); - } - - private int getMaxStage() { - return getSapling().getMaximumStage(); - } - - ///////// - // Property Methods - /////// - - @Override - public String getPropertyString() { - return getStage() != 0 ? String.valueOf(getStage()) : null; - } - - @Override - public String getPropertyId() { - return "growth_stage"; - } - - /////////// - // ObjectTag Attributes - //////// - - @Override - public String getAttribute(Attribute attribute) { - if (attribute == null) { - return null; - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @group properties - // @description - // Returns the maximum growth stage of the sapling or bamboo material. - // Once the material's growth stage reaches this number, the material will attempt to grow into a tree as its next stage. - // --> - if (attribute.startsWith("max_growth_stage")) { - return new ElementTag(getMaxStage()).getAttribute(attribute.fulfill(1)); - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @mechanism MaterialTag.growth_stage - // @group properties - // @description - // Returns the growth stage of the sapling or bamboo material. - // --> - if (attribute.startsWith("growth_stage")) { - return new ElementTag(getStage()).getAttribute(attribute.fulfill(1)); - } - - return null; - } - - @Override - public void adjust(Mechanism mechanism) { - - // <--[mechanism] - // @object MaterialTag - // @name growth_stage - // @input ElementTag(Number) - // @description - // Sets the growth stage of the sapling or bamboo material. - // @tags - // - // - // --> - if (mechanism.matches("growth_stage") && mechanism.requireInteger()) { - int stage = mechanism.getValue().asInt(); - if (stage < 0 || stage > getMaxStage()) { - Debug.echoError("The growth stage must be between '0' and '" + getMaxStage() + "'!"); - return; - } - getSapling().setStage(stage); - } - } -} +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.Sapling; + +public class MaterialSaplingStage implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Sapling; + } + + public static MaterialSaplingStage getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialSaplingStage((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "growth_stage", "max_growth_stage" + }; + + public static final String[] handledMechs = new String[] { + "growth_stage" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialSaplingStage(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Sapling getSapling() { + return (Sapling) material.getModernData().data; + } + + private int getStage() { + return getSapling().getStage(); + } + + private int getMaxStage() { + return getSapling().getMaximumStage(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getStage() != 0 ? String.valueOf(getStage()) : null; + } + + @Override + public String getPropertyId() { + return "growth_stage"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the maximum growth stage of the sapling or bamboo material. + // Once the material's growth stage reaches this number, the material will attempt to grow into a tree as its next stage. + // --> + if (attribute.startsWith("max_growth_stage")) { + return new ElementTag(getMaxStage()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @mechanism MaterialTag.growth_stage + // @group properties + // @description + // Returns the growth stage of the sapling or bamboo material. + // --> + if (attribute.startsWith("growth_stage")) { + return new ElementTag(getStage()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name growth_stage + // @input ElementTag(Number) + // @description + // Sets the growth stage of the sapling or bamboo material. + // @tags + // + // + // --> + if (mechanism.matches("growth_stage") && mechanism.requireInteger()) { + int stage = mechanism.getValue().asInt(); + if (stage < 0 || stage > getMaxStage()) { + Debug.echoError("The growth stage must be between '0' and '" + getMaxStage() + "'!"); + return; + } + getSapling().setStage(stage); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialScaffoldingBottom.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialScaffoldingBottom.java similarity index 94% rename from plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialScaffoldingBottom.java rename to plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialScaffoldingBottom.java index 6be3f9c1ab..23424e870e 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialScaffoldingBottom.java +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialScaffoldingBottom.java @@ -1,109 +1,109 @@ -package com.denizenscript.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.Scaffolding; - -public class MaterialScaffoldingBottom implements Property { - - public static boolean describes(ObjectTag material) { - return material instanceof MaterialTag - && ((MaterialTag) material).hasModernData() - && ((MaterialTag) material).getModernData().data instanceof Scaffolding; - } - - public static MaterialScaffoldingBottom getFrom(ObjectTag material) { - if (!describes(material)) { - return null; - } - return new MaterialScaffoldingBottom((MaterialTag) material); - } - - public static final String[] handledTags = new String[] { - "is_bottom" - }; - - public static final String[] handledMechs = new String[] { - "is_bottom" - }; - - - /////////////////// - // Instance Fields and Methods - ///////////// - - private MaterialScaffoldingBottom(MaterialTag material) { - this.material = material; - } - - private MaterialTag material; - - private Scaffolding getScaffolding() { - return (Scaffolding) material.getModernData().data; - } - - private boolean isBottom() { - return getScaffolding().isBottom(); - } - - ///////// - // Property Methods - /////// - - @Override - public String getPropertyString() { - return isBottom() ? "true" : null; - } - - @Override - public String getPropertyId() { - return "is_bottom"; - } - - /////////// - // ObjectTag Attributes - //////// - - @Override - public String getAttribute(Attribute attribute) { - if (attribute == null) { - return null; - } - - // <--[tag] - // @attribute - // @returns ElementTag(Boolean) - // @mechanism MaterialTag.is_bottom - // @group properties - // @description - // Returns whether this scaffolding material is a "bottom" scaffolding. - // If false, then the scaffolding should be on top of another scaffolding. - // --> - if (attribute.startsWith("is_bottom")) { - return new ElementTag(isBottom()).getAttribute(attribute.fulfill(1)); - } - - return null; - } - - @Override - public void adjust(Mechanism mechanism) { - - // <--[mechanism] - // @object MaterialTag - // @name is_bottom - // @input ElementTag(Boolean) - // @description - // Sets whether this scaffolding material is a "bottom" scaffolding. - // @tags - // - // --> - if (mechanism.matches("is_bottom") && mechanism.requireBoolean()) { - getScaffolding().setBottom(mechanism.getValue().asBoolean()); - } - } -} +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.Scaffolding; + +public class MaterialScaffoldingBottom implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Scaffolding; + } + + public static MaterialScaffoldingBottom getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialScaffoldingBottom((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "is_bottom" + }; + + public static final String[] handledMechs = new String[] { + "is_bottom" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialScaffoldingBottom(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Scaffolding getScaffolding() { + return (Scaffolding) material.getModernData().data; + } + + private boolean isBottom() { + return getScaffolding().isBottom(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return isBottom() ? "true" : null; + } + + @Override + public String getPropertyId() { + return "is_bottom"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @mechanism MaterialTag.is_bottom + // @group properties + // @description + // Returns whether this scaffolding material is a "bottom" scaffolding. + // If false, then the scaffolding should be on top of another scaffolding. + // --> + if (attribute.startsWith("is_bottom")) { + return new ElementTag(isBottom()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name is_bottom + // @input ElementTag(Boolean) + // @description + // Sets whether this scaffolding material is a "bottom" scaffolding. + // @tags + // + // --> + if (mechanism.matches("is_bottom") && mechanism.requireBoolean()) { + getScaffolding().setBottom(mechanism.getValue().asBoolean()); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialScaffoldingDistanceToBottom.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialScaffoldingDistanceToBottom.java similarity index 95% rename from plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialScaffoldingDistanceToBottom.java rename to plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialScaffoldingDistanceToBottom.java index 7c7eef5fc3..716d1d1685 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialScaffoldingDistanceToBottom.java +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialScaffoldingDistanceToBottom.java @@ -1,119 +1,119 @@ -package com.denizenscript.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.Scaffolding; - -public class MaterialScaffoldingDistanceToBottom implements Property { - - public static boolean describes(ObjectTag material) { - return material instanceof MaterialTag - && ((MaterialTag) material).hasModernData() - && ((MaterialTag) material).getModernData().data instanceof Scaffolding; - } - - public static MaterialScaffoldingDistanceToBottom getFrom(ObjectTag material) { - if (!describes(material)) { - return null; - } - return new MaterialScaffoldingDistanceToBottom((MaterialTag) material); - } - - public static final String[] handledTags = new String[] { - "distance_to_bottom", "max_distance_to_bottom" - }; - - public static final String[] handledMechs = new String[] { - "distance_to_bottom" - }; - - - /////////////////// - // Instance Fields and Methods - ///////////// - - private MaterialScaffoldingDistanceToBottom(MaterialTag material) { - this.material = material; - } - - private MaterialTag material; - - private Scaffolding getScaffolding() { - return (Scaffolding) material.getModernData().data; - } - - private int getDistance() { - return getScaffolding().getDistance(); - } - - ///////// - // Property Methods - /////// - - @Override - public String getPropertyString() { - return !getScaffolding().isBottom() ? String.valueOf(getDistance()) : null; - } - - @Override - public String getPropertyId() { - return "distance_to_bottom"; - } - - /////////// - // ObjectTag Attributes - //////// - - @Override - public String getAttribute(Attribute attribute) { - if (attribute == null) { - return null; - } - - // <--[tag] - // @attribute - // @returns ElementTag(Boolean) - // @group properties - // @description - // Returns the maximum distance the scaffolding material can have from a "bottom" scaffolding. - // --> - if (attribute.startsWith("distance_to_bottom")) { - return new ElementTag(getDistance()).getAttribute(attribute.fulfill(1)); - } - - // <--[tag] - // @attribute - // @returns ElementTag(Boolean) - // @mechanism MaterialTag.distance_to_bottom - // @group properties - // @description - // Returns how far the scaffolding material is from a "bottom" scaffolding. - // --> - if (attribute.startsWith("distance_to_bottom")) { - return new ElementTag(getDistance()).getAttribute(attribute.fulfill(1)); - } - - return null; - } - - @Override - public void adjust(Mechanism mechanism) { - - // <--[mechanism] - // @object MaterialTag - // @name distance_to_bottom - // @input ElementTag(Boolean) - // @description - // Sets how far the scaffolding material is from a "bottom" scaffolding. - // @tags - // - // --> - if (mechanism.matches("distance_to_bottom") && mechanism.requireInteger()) { - getScaffolding().setDistance(mechanism.getValue().asInt()); - } - } -} +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.Scaffolding; + +public class MaterialScaffoldingDistanceToBottom implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Scaffolding; + } + + public static MaterialScaffoldingDistanceToBottom getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialScaffoldingDistanceToBottom((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "distance_to_bottom", "max_distance_to_bottom" + }; + + public static final String[] handledMechs = new String[] { + "distance_to_bottom" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialScaffoldingDistanceToBottom(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Scaffolding getScaffolding() { + return (Scaffolding) material.getModernData().data; + } + + private int getDistance() { + return getScaffolding().getDistance(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return !getScaffolding().isBottom() ? String.valueOf(getDistance()) : null; + } + + @Override + public String getPropertyId() { + return "distance_to_bottom"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @group properties + // @description + // Returns the maximum distance the scaffolding material can have from a "bottom" scaffolding. + // --> + if (attribute.startsWith("distance_to_bottom")) { + return new ElementTag(getDistance()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @mechanism MaterialTag.distance_to_bottom + // @group properties + // @description + // Returns how far the scaffolding material is from a "bottom" scaffolding. + // --> + if (attribute.startsWith("distance_to_bottom")) { + return new ElementTag(getDistance()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name distance_to_bottom + // @input ElementTag(Boolean) + // @description + // Sets how far the scaffolding material is from a "bottom" scaffolding. + // @tags + // + // --> + if (mechanism.matches("distance_to_bottom") && mechanism.requireInteger()) { + getScaffolding().setDistance(mechanism.getValue().asInt()); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSeaPickles.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialSeaPickles.java similarity index 95% rename from plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSeaPickles.java rename to plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialSeaPickles.java index babc00c8e8..2d7721e909 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSeaPickles.java +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialSeaPickles.java @@ -1,146 +1,146 @@ -package com.denizenscript.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.SeaPickle; - -public class MaterialSeaPickles implements Property { - - public static boolean describes(ObjectTag material) { - return material instanceof MaterialTag - && ((MaterialTag) material).hasModernData() - && ((MaterialTag) material).getModernData().data instanceof SeaPickle; - } - - public static MaterialSeaPickles getFrom(ObjectTag material) { - if (!describes(material)) { - return null; - } - return new MaterialSeaPickles((MaterialTag) material); - } - - public static final String[] handledTags = new String[] { - "pickles", "min_pickles", "max_pickles" - }; - - public static final String[] handledMechs = new String[] { - "pickles" - }; - - - /////////////////// - // Instance Fields and Methods - ///////////// - - private MaterialSeaPickles(MaterialTag material) { - this.material = material; - } - - private MaterialTag material; - - private SeaPickle getSeaPickle() { - return (SeaPickle) material.getModernData().data; - } - - private int getPickles() { - return getSeaPickle().getPickles(); - } - - private int getMinPickles() { - return getSeaPickle().getMinimumPickles(); - } - - private int getMaxPickles() { - return getSeaPickle().getMaximumPickles(); - } - - ///////// - // Property Methods - /////// - - @Override - public String getPropertyString() { - return getPickles() != getMinPickles() ? String.valueOf(getPickles()) : null; - } - - @Override - public String getPropertyId() { - return "pickles"; - } - - /////////// - // 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 pickles the sea pickle material can have. - // --> - if (attribute.startsWith("min_pickles")) { - return new ElementTag(getMinPickles()).getAttribute(attribute.fulfill(1)); - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @group properties - // @description - // Returns the minimum number of pickles the sea pickle material can have. - // --> - if (attribute.startsWith("max_pickles")) { - return new ElementTag(getMaxPickles()).getAttribute(attribute.fulfill(1)); - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @mechanism MaterialTag.pickles - // @group properties - // @description - // Returns how many pickles the sea pickle material has. - // --> - if (attribute.startsWith("pickles")) { - return new ElementTag(getPickles()).getAttribute(attribute.fulfill(1)); - } - - return null; - } - - @Override - public void adjust(Mechanism mechanism) { - - // <--[mechanism] - // @object MaterialTag - // @name pickles - // @input ElementTag(Number) - // @description - // Sets how many pickles the sea pickle material has. - // @tags - // - // - // - // --> - if (mechanism.matches("pickles") && mechanism.requireInteger()) { - int pickles = mechanism.getValue().asInt(); - if (pickles < getMinPickles() || pickles > getMaxPickles()) { - Debug.echoError("The number of pickles must be between '" + getMinPickles() + "' and '" + getMaxPickles() + "'!"); - return; - } - getSeaPickle().setPickles(pickles); - } - } -} +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.SeaPickle; + +public class MaterialSeaPickles implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof SeaPickle; + } + + public static MaterialSeaPickles getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialSeaPickles((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "pickles", "min_pickles", "max_pickles" + }; + + public static final String[] handledMechs = new String[] { + "pickles" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialSeaPickles(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private SeaPickle getSeaPickle() { + return (SeaPickle) material.getModernData().data; + } + + private int getPickles() { + return getSeaPickle().getPickles(); + } + + private int getMinPickles() { + return getSeaPickle().getMinimumPickles(); + } + + private int getMaxPickles() { + return getSeaPickle().getMaximumPickles(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getPickles() != getMinPickles() ? String.valueOf(getPickles()) : null; + } + + @Override + public String getPropertyId() { + return "pickles"; + } + + /////////// + // 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 pickles the sea pickle material can have. + // --> + if (attribute.startsWith("min_pickles")) { + return new ElementTag(getMinPickles()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the minimum number of pickles the sea pickle material can have. + // --> + if (attribute.startsWith("max_pickles")) { + return new ElementTag(getMaxPickles()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @mechanism MaterialTag.pickles + // @group properties + // @description + // Returns how many pickles the sea pickle material has. + // --> + if (attribute.startsWith("pickles")) { + return new ElementTag(getPickles()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name pickles + // @input ElementTag(Number) + // @description + // Sets how many pickles the sea pickle material has. + // @tags + // + // + // + // --> + if (mechanism.matches("pickles") && mechanism.requireInteger()) { + int pickles = mechanism.getValue().asInt(); + if (pickles < getMinPickles() || pickles > getMaxPickles()) { + Debug.echoError("The number of pickles must be between '" + getMinPickles() + "' and '" + getMaxPickles() + "'!"); + return; + } + getSeaPickle().setPickles(pickles); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSnowLayers.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialSnowLayers.java similarity index 95% rename from plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSnowLayers.java rename to plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialSnowLayers.java index 97901da99f..553318824a 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialSnowLayers.java +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialSnowLayers.java @@ -1,146 +1,146 @@ -package com.denizenscript.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.Snow; - -public class MaterialSnowLayers implements Property { - - public static boolean describes(ObjectTag material) { - return material instanceof MaterialTag - && ((MaterialTag) material).hasModernData() - && ((MaterialTag) material).getModernData().data instanceof Snow; - } - - public static MaterialSnowLayers getFrom(ObjectTag material) { - if (!describes(material)) { - return null; - } - return new MaterialSnowLayers((MaterialTag) material); - } - - public static final String[] handledTags = new String[] { - "snow_layers", "min_snow_layers", "max_snow_layers" - }; - - public static final String[] handledMechs = new String[] { - "snow_layers" - }; - - - /////////////////// - // Instance Fields and Methods - ///////////// - - private MaterialSnowLayers(MaterialTag material) { - this.material = material; - } - - private MaterialTag material; - - private Snow getSnow() { - return (Snow) material.getModernData().data; - } - - private int getLayers() { - return getSnow().getLayers(); - } - - private int getMinLayers() { - return getSnow().getMinimumLayers(); - } - - private int getMaxLayers() { - return getSnow().getMaximumLayers(); - } - - ///////// - // Property Methods - /////// - - @Override - public String getPropertyString() { - return getLayers() != getMinLayers() ? String.valueOf(getLayers()) : null; - } - - @Override - public String getPropertyId() { - return "snow_layers"; - } - - /////////// - // ObjectTag Attributes - //////// - - @Override - public String getAttribute(Attribute attribute) { - if (attribute == null) { - return null; - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @group properties - // @description - // Returns the minimum amount of layers this snow layer material can have. - // --> - if (attribute.startsWith("min_snow_layers")) { - return new ElementTag(getMinLayers()).getAttribute(attribute.fulfill(1)); - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @group properties - // @description - // Returns the maximum amount of layers this snow layer material can have. - // --> - if (attribute.startsWith("max_snow_layers")) { - return new ElementTag(getMaxLayers()).getAttribute(attribute.fulfill(1)); - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @mechanism MaterialTag.snow_layers - // @group properties - // @description - // Returns the amount of layers this snow layer material can have. - // --> - if (attribute.startsWith("snow_layers")) { - return new ElementTag(getLayers()).getAttribute(attribute.fulfill(1)); - } - - return null; - } - - @Override - public void adjust(Mechanism mechanism) { - - // <--[mechanism] - // @object MaterialTag - // @name snow_layers - // @input ElementTag(Number) - // @description - // Sets the amount of layers this snow layer can have. - // @tags - // - // - // - // --> - if (mechanism.matches("snow_layers") && mechanism.requireInteger()) { - int layers = mechanism.getValue().asInt(); - if (layers < getMinLayers() || layers > getMaxLayers()) { - Debug.echoError("The number of snow layers must be between '" + getMinLayers() + "' and '" + getMaxLayers() + "'!"); - return; - } - getSnow().setLayers(layers); - } - } -} +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.Snow; + +public class MaterialSnowLayers implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Snow; + } + + public static MaterialSnowLayers getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialSnowLayers((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "snow_layers", "min_snow_layers", "max_snow_layers" + }; + + public static final String[] handledMechs = new String[] { + "snow_layers" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialSnowLayers(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Snow getSnow() { + return (Snow) material.getModernData().data; + } + + private int getLayers() { + return getSnow().getLayers(); + } + + private int getMinLayers() { + return getSnow().getMinimumLayers(); + } + + private int getMaxLayers() { + return getSnow().getMaximumLayers(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getLayers() != getMinLayers() ? String.valueOf(getLayers()) : null; + } + + @Override + public String getPropertyId() { + return "snow_layers"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the minimum amount of layers this snow layer material can have. + // --> + if (attribute.startsWith("min_snow_layers")) { + return new ElementTag(getMinLayers()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the maximum amount of layers this snow layer material can have. + // --> + if (attribute.startsWith("max_snow_layers")) { + return new ElementTag(getMaxLayers()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @mechanism MaterialTag.snow_layers + // @group properties + // @description + // Returns the amount of layers this snow layer material can have. + // --> + if (attribute.startsWith("snow_layers")) { + return new ElementTag(getLayers()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name snow_layers + // @input ElementTag(Number) + // @description + // Sets the amount of layers this snow layer can have. + // @tags + // + // + // + // --> + if (mechanism.matches("snow_layers") && mechanism.requireInteger()) { + int layers = mechanism.getValue().asInt(); + if (layers < getMinLayers() || layers > getMaxLayers()) { + Debug.echoError("The number of snow layers must be between '" + getMinLayers() + "' and '" + getMaxLayers() + "'!"); + return; + } + getSnow().setLayers(layers); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialStairsShape.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialStairsShape.java similarity index 94% rename from plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialStairsShape.java rename to plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialStairsShape.java index b44902f5bb..3130e41bf3 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialStairsShape.java +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialStairsShape.java @@ -1,110 +1,110 @@ -package com.denizenscript.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.Stairs; - -public class MaterialStairsShape implements Property { - - public static boolean describes(ObjectTag material) { - return material instanceof MaterialTag - && ((MaterialTag) material).hasModernData() - && ((MaterialTag) material).getModernData().data instanceof Stairs; - } - - public static MaterialStairsShape getFrom(ObjectTag material) { - if (!describes(material)) { - return null; - } - return new MaterialStairsShape((MaterialTag) material); - } - - public static final String[] handledTags = new String[] { - "stair_shape" - }; - - public static final String[] handledMechs = new String[] { - "stair_shape" - }; - - - /////////////////// - // Instance Fields and Methods - ///////////// - - private MaterialStairsShape(MaterialTag material) { - this.material = material; - } - - private MaterialTag material; - - private Stairs getStairs() { - return (Stairs) material.getModernData().data; - } - - private String getShape() { - return getStairs().getShape().name(); - } - - ///////// - // Property Methods - /////// - - @Override - public String getPropertyString() { - return getStairs().getShape() != Stairs.Shape.STRAIGHT ? getShape() : null; - } - - @Override - public String getPropertyId() { - return "stair_shape"; - } - - /////////// - // ObjectTag Attributes - //////// - - @Override - public String getAttribute(Attribute attribute) { - if (attribute == null) { - return null; - } - - // <--[tag] - // @attribute - // @returns ElementTag - // @mechanism MaterialTag.stair_shape - // @group properties - // @description - // Returns the shape of the stairs material. - // Can be any of: <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/Stairs.Shape.html> - // --> - if (attribute.startsWith("stair_shape")) { - return new ElementTag(getShape()).getAttribute(attribute.fulfill(1)); - } - - return null; - } - - @Override - public void adjust(Mechanism mechanism) { - - // <--[mechanism] - // @object MaterialTag - // @name stair_shape - // @input ElementTag - // @description - // Sets the shape of the stairs material. - // Can be any of: <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/Stairs.Shape.html> - // @tags - // - // --> - if (mechanism.matches("stair_shape") && mechanism.requireEnum(false, Stairs.Shape.values())) { - getStairs().setShape(Stairs.Shape.valueOf(mechanism.getValue().asString().toUpperCase())); - } - } -} +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.Stairs; + +public class MaterialStairsShape implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Stairs; + } + + public static MaterialStairsShape getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialStairsShape((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "stair_shape" + }; + + public static final String[] handledMechs = new String[] { + "stair_shape" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialStairsShape(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Stairs getStairs() { + return (Stairs) material.getModernData().data; + } + + private String getShape() { + return getStairs().getShape().name(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getStairs().getShape() != Stairs.Shape.STRAIGHT ? getShape() : null; + } + + @Override + public String getPropertyId() { + return "stair_shape"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag + // @mechanism MaterialTag.stair_shape + // @group properties + // @description + // Returns the shape of the stairs material. + // Can be any of: <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/Stairs.Shape.html> + // --> + if (attribute.startsWith("stair_shape")) { + return new ElementTag(getShape()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name stair_shape + // @input ElementTag + // @description + // Sets the shape of the stairs material. + // Can be any of: <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/Stairs.Shape.html> + // @tags + // + // --> + if (mechanism.matches("stair_shape") && mechanism.requireEnum(false, Stairs.Shape.values())) { + getStairs().setShape(Stairs.Shape.valueOf(mechanism.getValue().asString().toUpperCase())); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialStructureBlockMode.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialStructureBlockMode.java similarity index 94% rename from plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialStructureBlockMode.java rename to plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialStructureBlockMode.java index 4e3852119b..637f85b75c 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialStructureBlockMode.java +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialStructureBlockMode.java @@ -1,110 +1,110 @@ -package com.denizenscript.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.StructureBlock; - -public class MaterialStructureBlockMode implements Property { - - public static boolean describes(ObjectTag material) { - return material instanceof MaterialTag - && ((MaterialTag) material).hasModernData() - && ((MaterialTag) material).getModernData().data instanceof StructureBlock; - } - - public static MaterialStructureBlockMode getFrom(ObjectTag material) { - if (!describes(material)) { - return null; - } - return new MaterialStructureBlockMode((MaterialTag) material); - } - - public static final String[] handledTags = new String[] { - "mode" - }; - - public static final String[] handledMechs = new String[] { - "mode" - }; - - - /////////////////// - // Instance Fields and Methods - ///////////// - - private MaterialStructureBlockMode(MaterialTag material) { - this.material = material; - } - - private MaterialTag material; - - private StructureBlock getStructureBlock() { - return (StructureBlock) material.getModernData().data; - } - - private String getMode() { - return getStructureBlock().getMode().name(); - } - - ///////// - // Property Methods - /////// - - @Override - public String getPropertyString() { - return getMode(); - } - - @Override - public String getPropertyId() { - return "mode"; - } - - /////////// - // ObjectTag Attributes - //////// - - @Override - public String getAttribute(Attribute attribute) { - if (attribute == null) { - return null; - } - - // <--[tag] - // @attribute - // @returns ElementTag - // @mechanism MaterialTag.mode - // @group properties - // @description - // Returns the mode of the structure block material. - // Can be any of: <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/StructureBlock.Mode.html> - // --> - if (attribute.startsWith("mode")) { - return new ElementTag(getMode()).getAttribute(attribute.fulfill(1)); - } - - return null; - } - - @Override - public void adjust(Mechanism mechanism) { - - // <--[mechanism] - // @object MaterialTag - // @name mode - // @input ElementTag - // @description - // Sets the mode of the structure block material. - // Can be any of: <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/StructureBlock.Mode.html> - // @tags - // - // --> - if (mechanism.matches("mode") && mechanism.requireEnum(false, StructureBlock.Mode.values())) { - getStructureBlock().setMode(StructureBlock.Mode.valueOf(mechanism.getValue().asString().toUpperCase())); - } - } -} +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.StructureBlock; + +public class MaterialStructureBlockMode implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof StructureBlock; + } + + public static MaterialStructureBlockMode getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialStructureBlockMode((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "mode" + }; + + public static final String[] handledMechs = new String[] { + "mode" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialStructureBlockMode(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private StructureBlock getStructureBlock() { + return (StructureBlock) material.getModernData().data; + } + + private String getMode() { + return getStructureBlock().getMode().name(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getMode(); + } + + @Override + public String getPropertyId() { + return "mode"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag + // @mechanism MaterialTag.mode + // @group properties + // @description + // Returns the mode of the structure block material. + // Can be any of: <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/StructureBlock.Mode.html> + // --> + if (attribute.startsWith("mode")) { + return new ElementTag(getMode()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name mode + // @input ElementTag + // @description + // Sets the mode of the structure block material. + // Can be any of: <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/StructureBlock.Mode.html> + // @tags + // + // --> + if (mechanism.matches("mode") && mechanism.requireEnum(false, StructureBlock.Mode.values())) { + getStructureBlock().setMode(StructureBlock.Mode.valueOf(mechanism.getValue().asString().toUpperCase())); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTntUnstable.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialTntUnstable.java similarity index 94% rename from plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTntUnstable.java rename to plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialTntUnstable.java index 732738e0c6..f05fc15a65 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTntUnstable.java +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialTntUnstable.java @@ -1,110 +1,110 @@ -package com.denizenscript.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.TNT; - -public class MaterialTntUnstable implements Property { - - public static boolean describes(ObjectTag material) { - return material instanceof MaterialTag - && ((MaterialTag) material).hasModernData() - && ((MaterialTag) material).getModernData().data instanceof TNT; - } - - public static MaterialTntUnstable getFrom(ObjectTag material) { - if (!describes(material)) { - return null; - } - return new MaterialTntUnstable((MaterialTag) material); - } - - public static final String[] handledTags = new String[] { - "unstable" - }; - - public static final String[] handledMechs = new String[] { - "unstable" - }; - - - /////////////////// - // Instance Fields and Methods - ///////////// - - private MaterialTntUnstable(MaterialTag material) { - this.material = material; - } - - private MaterialTag material; - - private TNT getTnt() { - return (TNT) material.getModernData().data; - } - - private boolean isUnstable() { - return getTnt().isUnstable(); - } - - ///////// - // Property Methods - /////// - - @Override - public String getPropertyString() { - return isUnstable() ? "true" : null; - } - - @Override - public String getPropertyId() { - return "unstable"; - } - - /////////// - // ObjectTag Attributes - //////// - - @Override - public String getAttribute(Attribute attribute) { - if (attribute == null) { - return null; - } - - // <--[tag] - // @attribute - // @returns ElementTag(Boolean) - // @mechanism MaterialTag.unstable - // @group properties - // @description - // Returns whether the TNT material is unstable. - // If true, then punching the material will cause it to explode. - // --> - if (attribute.startsWith("unstable")) { - return new ElementTag(isUnstable()).getAttribute(attribute.fulfill(1)); - } - - return null; - } - - @Override - public void adjust(Mechanism mechanism) { - - // <--[mechanism] - // @object MaterialTag - // @name unstable - // @input ElementTag(Boolean) - // @description - // Sets whether the TNT material is unstable. - // If true, then punching the material will cause it to explode. - // @tags - // - // --> - if (mechanism.matches("unstable") && mechanism.requireBoolean()) { - getTnt().setUnstable(mechanism.getValue().asBoolean()); - } - } -} +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.TNT; + +public class MaterialTntUnstable implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof TNT; + } + + public static MaterialTntUnstable getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialTntUnstable((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "unstable" + }; + + public static final String[] handledMechs = new String[] { + "unstable" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialTntUnstable(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private TNT getTnt() { + return (TNT) material.getModernData().data; + } + + private boolean isUnstable() { + return getTnt().isUnstable(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return isUnstable() ? "true" : null; + } + + @Override + public String getPropertyId() { + return "unstable"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @mechanism MaterialTag.unstable + // @group properties + // @description + // Returns whether the TNT material is unstable. + // If true, then punching the material will cause it to explode. + // --> + if (attribute.startsWith("unstable")) { + return new ElementTag(isUnstable()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name unstable + // @input ElementTag(Boolean) + // @description + // Sets whether the TNT material is unstable. + // If true, then punching the material will cause it to explode. + // @tags + // + // --> + if (mechanism.matches("unstable") && mechanism.requireBoolean()) { + getTnt().setUnstable(mechanism.getValue().asBoolean()); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTripwireDisarmed.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialTripwireDisarmed.java similarity index 94% rename from plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTripwireDisarmed.java rename to plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialTripwireDisarmed.java index 1528f94938..473e64697b 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTripwireDisarmed.java +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialTripwireDisarmed.java @@ -1,111 +1,111 @@ -package com.denizenscript.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.Tripwire; - -public class MaterialTripwireDisarmed implements Property { - - public static boolean describes(ObjectTag material) { - return material instanceof MaterialTag - && ((MaterialTag) material).hasModernData() - && ((MaterialTag) material).getModernData().data instanceof Tripwire; - } - - public static MaterialTripwireDisarmed getFrom(ObjectTag material) { - if (!describes(material)) { - return null; - } - return new MaterialTripwireDisarmed((MaterialTag) material); - } - - public static final String[] handledTags = new String[] { - "disarmed" - }; - - public static final String[] handledMechs = new String[] { - "disarmed" - }; - - - /////////////////// - // Instance Fields and Methods - ///////////// - - private MaterialTripwireDisarmed(MaterialTag material) { - this.material = material; - } - - private MaterialTag material; - - private Tripwire getTripwire() { - return (Tripwire) material.getModernData().data; - } - - private boolean isDisarmed() { - return getTripwire().isDisarmed(); - } - - ///////// - // Property Methods - /////// - - @Override - public String getPropertyString() { - // The natural state of a tripwire string is disarmed. - return !isDisarmed() ? "false" : null; - } - - @Override - public String getPropertyId() { - return "disarmed"; - } - - /////////// - // ObjectTag Attributes - //////// - - @Override - public String getAttribute(Attribute attribute) { - if (attribute == null) { - return null; - } - - // <--[tag] - // @attribute - // @returns ElementTag(Boolean) - // @mechanism MaterialTag.disarmed - // @group properties - // @description - // Returns whether this tripwire material is disarmed. - // If true, then breaking the material will not produce a current. - // --> - if (attribute.startsWith("disarmed")) { - return new ElementTag(isDisarmed()).getAttribute(attribute.fulfill(1)); - } - - return null; - } - - @Override - public void adjust(Mechanism mechanism) { - - // <--[mechanism] - // @object MaterialTag - // @name disarmed - // @input ElementTag(Boolean) - // @description - // Sets whether this tripwire material is disarmed. - // If true, then breaking the material will not produce a current. - // @tags - // - // --> - if (mechanism.matches("disarmed") && mechanism.requireBoolean()) { - getTripwire().setDisarmed(mechanism.getValue().asBoolean()); - } - } -} +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.Tripwire; + +public class MaterialTripwireDisarmed implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof Tripwire; + } + + public static MaterialTripwireDisarmed getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialTripwireDisarmed((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "disarmed" + }; + + public static final String[] handledMechs = new String[] { + "disarmed" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialTripwireDisarmed(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private Tripwire getTripwire() { + return (Tripwire) material.getModernData().data; + } + + private boolean isDisarmed() { + return getTripwire().isDisarmed(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + // The natural state of a tripwire string is disarmed. + return !isDisarmed() ? "false" : null; + } + + @Override + public String getPropertyId() { + return "disarmed"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Boolean) + // @mechanism MaterialTag.disarmed + // @group properties + // @description + // Returns whether this tripwire material is disarmed. + // If true, then breaking the material will not produce a current. + // --> + if (attribute.startsWith("disarmed")) { + return new ElementTag(isDisarmed()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name disarmed + // @input ElementTag(Boolean) + // @description + // Sets whether this tripwire material is disarmed. + // If true, then breaking the material will not produce a current. + // @tags + // + // --> + if (mechanism.matches("disarmed") && mechanism.requireBoolean()) { + getTripwire().setDisarmed(mechanism.getValue().asBoolean()); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTurtleEggsAmount.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialTurtleEggsAmount.java similarity index 95% rename from plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTurtleEggsAmount.java rename to plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialTurtleEggsAmount.java index e761b25db6..b29ceba6ad 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTurtleEggsAmount.java +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialTurtleEggsAmount.java @@ -1,146 +1,146 @@ -package com.denizenscript.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.TurtleEgg; - -public class MaterialTurtleEggsAmount implements Property { - - public static boolean describes(ObjectTag material) { - return material instanceof MaterialTag - && ((MaterialTag) material).hasModernData() - && ((MaterialTag) material).getModernData().data instanceof TurtleEgg; - } - - public static MaterialTurtleEggsAmount getFrom(ObjectTag material) { - if (!describes(material)) { - return null; - } - return new MaterialTurtleEggsAmount((MaterialTag) material); - } - - public static final String[] handledTags = new String[] { - "eggs" - }; - - public static final String[] handledMechs = new String[] { - "eggs" - }; - - - /////////////////// - // Instance Fields and Methods - ///////////// - - private MaterialTurtleEggsAmount(MaterialTag material) { - this.material = material; - } - - private MaterialTag material; - - private TurtleEgg getTurtleEgg() { - return (TurtleEgg) material.getModernData().data; - } - - private int getAmount() { - return getTurtleEgg().getEggs(); - } - - private int getMinAmount() { - return getTurtleEgg().getMinimumEggs(); - } - - private int getMaxAmount() { - return getTurtleEgg().getMaximumEggs(); - } - - ///////// - // Property Methods - /////// - - @Override - public String getPropertyString() { - return getAmount() != getMinAmount() ? String.valueOf(getAmount()) : null; - } - - @Override - public String getPropertyId() { - return "eggs"; - } - - /////////// - // ObjectTag Attributes - //////// - - @Override - public String getAttribute(Attribute attribute) { - if (attribute == null) { - return null; - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @group properties - // @description - // Returns the minimum number of eggs that the turtle egg material can have. - // --> - if (attribute.startsWith("min_eggs")) { - return new ElementTag(getMinAmount()).getAttribute(attribute.fulfill(1)); - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @group properties - // @description - // Returns the maximum number of eggs that the turtle egg material can have. - // --> - if (attribute.startsWith("max_eggs")) { - return new ElementTag(getMaxAmount()).getAttribute(attribute.fulfill(1)); - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @mechanism MaterialTag.eggs - // @group properties - // @description - // Returns the number of eggs that the turtle egg material has. - // --> - if (attribute.startsWith("eggs")) { - return new ElementTag(getAmount()).getAttribute(attribute.fulfill(1)); - } - - return null; - } - - @Override - public void adjust(Mechanism mechanism) { - - // <--[mechanism] - // @object MaterialTag - // @name eggs - // @input ElementTag(Number) - // @description - // Sets how many eggs this turtle egg material has. - // @tags - // - // - // - // --> - if (mechanism.matches("eggs") && mechanism.requireInteger()) { - int eggs = mechanism.getValue().asInt(); - if (eggs < getMinAmount() || eggs > getMaxAmount()) { - Debug.echoError("The egg count must be between '" + getMinAmount() + "' and '" + getMaxAmount() + "'!"); - return; - } - getTurtleEgg().setEggs(eggs); - } - } -} +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.TurtleEgg; + +public class MaterialTurtleEggsAmount implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof TurtleEgg; + } + + public static MaterialTurtleEggsAmount getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialTurtleEggsAmount((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "eggs" + }; + + public static final String[] handledMechs = new String[] { + "eggs" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialTurtleEggsAmount(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private TurtleEgg getTurtleEgg() { + return (TurtleEgg) material.getModernData().data; + } + + private int getAmount() { + return getTurtleEgg().getEggs(); + } + + private int getMinAmount() { + return getTurtleEgg().getMinimumEggs(); + } + + private int getMaxAmount() { + return getTurtleEgg().getMaximumEggs(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getAmount() != getMinAmount() ? String.valueOf(getAmount()) : null; + } + + @Override + public String getPropertyId() { + return "eggs"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the minimum number of eggs that the turtle egg material can have. + // --> + if (attribute.startsWith("min_eggs")) { + return new ElementTag(getMinAmount()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the maximum number of eggs that the turtle egg material can have. + // --> + if (attribute.startsWith("max_eggs")) { + return new ElementTag(getMaxAmount()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @mechanism MaterialTag.eggs + // @group properties + // @description + // Returns the number of eggs that the turtle egg material has. + // --> + if (attribute.startsWith("eggs")) { + return new ElementTag(getAmount()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name eggs + // @input ElementTag(Number) + // @description + // Sets how many eggs this turtle egg material has. + // @tags + // + // + // + // --> + if (mechanism.matches("eggs") && mechanism.requireInteger()) { + int eggs = mechanism.getValue().asInt(); + if (eggs < getMinAmount() || eggs > getMaxAmount()) { + Debug.echoError("The egg count must be between '" + getMinAmount() + "' and '" + getMaxAmount() + "'!"); + return; + } + getTurtleEgg().setEggs(eggs); + } + } +} diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTurtleEggsHatch.java b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialTurtleEggsHatch.java similarity index 95% rename from plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTurtleEggsHatch.java rename to plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialTurtleEggsHatch.java index dd735d8742..8e1c9fec5a 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialTurtleEggsHatch.java +++ b/plugin/src/main/java/dev/unizen/denizen/objects/properties/material/MaterialTurtleEggsHatch.java @@ -1,147 +1,147 @@ -package com.denizenscript.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.TurtleEgg; - -public class MaterialTurtleEggsHatch implements Property { - - public static boolean describes(ObjectTag material) { - return material instanceof MaterialTag - && ((MaterialTag) material).hasModernData() - && ((MaterialTag) material).getModernData().data instanceof TurtleEgg; - } - - public static MaterialTurtleEggsHatch getFrom(ObjectTag material) { - if (!describes(material)) { - return null; - } - return new MaterialTurtleEggsHatch((MaterialTag) material); - } - - public static final String[] handledTags = new String[] { - "hatch", "min_hatch", "max_hatch" - }; - - public static final String[] handledMechs = new String[] { - "hatch" - }; - - - /////////////////// - // Instance Fields and Methods - ///////////// - - private MaterialTurtleEggsHatch(MaterialTag material) { - this.material = material; - } - - private MaterialTag material; - - private TurtleEgg getTurtleEgg() { - return (TurtleEgg) material.getModernData().data; - } - - private int getHatch() { - return getTurtleEgg().getHatch(); - } - - private int getMinHatch() { - return getTurtleEgg().getMinimumEggs(); - } - - private int getMaxHatch() { - return getTurtleEgg().getMaximumHatch(); - } - - ///////// - // Property Methods - /////// - - @Override - public String getPropertyString() { - return getHatch() != getMinHatch() ? String.valueOf(getHatch()) : null; - } - - @Override - public String getPropertyId() { - return "hatch"; - } - - /////////// - // ObjectTag Attributes - //////// - - @Override - public String getAttribute(Attribute attribute) { - if (attribute == null) { - return null; - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @group properties - // @description - // Returns the minimum value that the hatch property of the turtle egg material may have. - // --> - if (attribute.startsWith("min_hatch")) { - return new ElementTag(getMinHatch()).getAttribute(attribute.fulfill(1)); - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @group properties - // @description - // Returns the maximum value that the hatch property of the turtle egg material may have. - // --> - if (attribute.startsWith("max_hatch")) { - return new ElementTag(getMaxHatch()).getAttribute(attribute.fulfill(1)); - } - - // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @mechanism MaterialTag.hatch - // @group properties - // @description - // Returns the value of the hatch property of the turtle egg material. - // --> - if (attribute.startsWith("hatch")) { - return new ElementTag(getHatch()).getAttribute(attribute.fulfill(1)); - } - - return null; - } - - @Override - public void adjust(Mechanism mechanism) { - - // <--[mechanism] - // @object MaterialTag - // @name hatch - // @input ElementTag(Number) - // @description - // Sets the value of the hatch property of the turtle egg material. - // When the hatch value is at the maximum allowed value, the turtle egg will be very close to hatching. - // @tags - // - // - // - // --> - if (mechanism.matches("hatch") && mechanism.requireInteger()) { - int hatch = mechanism.getValue().asInt(); - if (hatch < getMinHatch() || hatch > getMinHatch()) { - Debug.echoError("The value of the hatch property must be between '" + getMinHatch() + "' and '" + getMaxHatch() + "'!"); - return; - } - getTurtleEgg().setHatch(hatch); - } - } -} +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.TurtleEgg; + +public class MaterialTurtleEggsHatch implements Property { + + public static boolean describes(ObjectTag material) { + return material instanceof MaterialTag + && ((MaterialTag) material).hasModernData() + && ((MaterialTag) material).getModernData().data instanceof TurtleEgg; + } + + public static MaterialTurtleEggsHatch getFrom(ObjectTag material) { + if (!describes(material)) { + return null; + } + return new MaterialTurtleEggsHatch((MaterialTag) material); + } + + public static final String[] handledTags = new String[] { + "hatch", "min_hatch", "max_hatch" + }; + + public static final String[] handledMechs = new String[] { + "hatch" + }; + + + /////////////////// + // Instance Fields and Methods + ///////////// + + private MaterialTurtleEggsHatch(MaterialTag material) { + this.material = material; + } + + private MaterialTag material; + + private TurtleEgg getTurtleEgg() { + return (TurtleEgg) material.getModernData().data; + } + + private int getHatch() { + return getTurtleEgg().getHatch(); + } + + private int getMinHatch() { + return getTurtleEgg().getMinimumEggs(); + } + + private int getMaxHatch() { + return getTurtleEgg().getMaximumHatch(); + } + + ///////// + // Property Methods + /////// + + @Override + public String getPropertyString() { + return getHatch() != getMinHatch() ? String.valueOf(getHatch()) : null; + } + + @Override + public String getPropertyId() { + return "hatch"; + } + + /////////// + // ObjectTag Attributes + //////// + + @Override + public String getAttribute(Attribute attribute) { + if (attribute == null) { + return null; + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the minimum value that the hatch property of the turtle egg material may have. + // --> + if (attribute.startsWith("min_hatch")) { + return new ElementTag(getMinHatch()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @group properties + // @description + // Returns the maximum value that the hatch property of the turtle egg material may have. + // --> + if (attribute.startsWith("max_hatch")) { + return new ElementTag(getMaxHatch()).getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns ElementTag(Number) + // @mechanism MaterialTag.hatch + // @group properties + // @description + // Returns the value of the hatch property of the turtle egg material. + // --> + if (attribute.startsWith("hatch")) { + return new ElementTag(getHatch()).getAttribute(attribute.fulfill(1)); + } + + return null; + } + + @Override + public void adjust(Mechanism mechanism) { + + // <--[mechanism] + // @object MaterialTag + // @name hatch + // @input ElementTag(Number) + // @description + // Sets the value of the hatch property of the turtle egg material. + // When the hatch value is at the maximum allowed value, the turtle egg will be very close to hatching. + // @tags + // + // + // + // --> + if (mechanism.matches("hatch") && mechanism.requireInteger()) { + int hatch = mechanism.getValue().asInt(); + if (hatch < getMinHatch() || hatch > getMinHatch()) { + Debug.echoError("The value of the hatch property must be between '" + getMinHatch() + "' and '" + getMaxHatch() + "'!"); + return; + } + getTurtleEgg().setHatch(hatch); + } + } +}