From a8e1e38345c79e5bd3d237ea9ea62bf834379236 Mon Sep 17 00:00:00 2001 From: Alex 'mcmonkey' Goodwin Date: Sat, 4 Jul 2020 11:13:10 -0700 Subject: [PATCH] deprecate cuboid.full, upgrade location.furnace_*_time, delete 1.12 material tags --- .../denizen/objects/CuboidTag.java | 9 +-- .../denizen/objects/LocationTag.java | 78 ++++++++++++++----- .../denizen/objects/MaterialTag.java | 44 +---------- 3 files changed, 60 insertions(+), 71 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/CuboidTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/CuboidTag.java index f9bd33e2da..024fa2a3a1 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/CuboidTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/CuboidTag.java @@ -14,6 +14,7 @@ import com.denizenscript.denizencore.tags.TagContext; import com.denizenscript.denizencore.tags.TagRunnable; import com.denizenscript.denizencore.utilities.CoreUtilities; +import com.denizenscript.denizencore.utilities.Deprecations; import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.npc.NPC; import org.bukkit.Bukkit; @@ -1501,14 +1502,8 @@ public static void registerTags() { return new ElementTag(notname); }); - // <--[tag] - // @attribute - // @returns ElementTag - // @group conversion - // @description - // Returns a full reusable identification for this cuboid, without applying the notable name or other special-case formats. - // --> registerTag("full", (attribute, cuboid) -> { + Deprecations.cuboidFullTag.warn(attribute.context); return new ElementTag(cuboid.identifyFull()); }); } diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/LocationTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/LocationTag.java index 1d86f19efa..889835346b 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/LocationTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/LocationTag.java @@ -2981,35 +2981,47 @@ else if (attribute.startsWith("vertical", 2)) { }); // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @mechanism LocationTag.furnace_burn_time + // @attribute + // @returns DurationTag + // @mechanism LocationTag.furnace_burn_duration // @description // Returns the burn time a furnace has left. // --> + registerTag("furnace_burn_duration", (attribute, object) -> { + return new DurationTag((long) ((Furnace) object.getBlockStateForTag(attribute)).getBurnTime()); + }); registerTag("furnace_burn_time", (attribute, object) -> { + Deprecations.furnaceTimeTags.warn(attribute.context); return new ElementTag(((Furnace) object.getBlockStateForTag(attribute)).getBurnTime()); }); // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @mechanism LocationTag.furnace_cook_time + // @attribute + // @returns DurationTag + // @mechanism LocationTag.furnace_burn_duration // @description // Returns the cook time a furnace has been cooking its current item for. // --> + registerTag("furnace_burn_duration", (attribute, object) -> { + return new DurationTag((long) ((Furnace) object.getBlockStateForTag(attribute)).getCookTime()); + }); registerTag("furnace_cook_time", (attribute, object) -> { + Deprecations.furnaceTimeTags.warn(attribute.context); return new ElementTag(((Furnace) object.getBlockStateForTag(attribute)).getCookTime()); }); // <--[tag] - // @attribute - // @returns ElementTag(Number) - // @mechanism LocationTag.furnace_cook_time_total + // @attribute + // @returns DurationTag + // @mechanism LocationTag.furnace_cook_duration_total // @description // Returns the total cook time a furnace has left. // --> + registerTag("furnace_cook_duration_total", (attribute, object) -> { + return new DurationTag((long) ((Furnace) object.getBlockStateForTag(attribute)).getCookTimeTotal()); + }); registerTag("furnace_cook_time_total", (attribute, object) -> { + Deprecations.furnaceTimeTags.warn(attribute.context); return new ElementTag(((Furnace) object.getBlockStateForTag(attribute)).getCookTimeTotal()); }); @@ -3442,14 +3454,22 @@ && getBlockState() instanceof CreatureSpawner) { // <--[mechanism] // @object LocationTag - // @name furnace_burn_time - // @input ElementTag(Number) + // @name furnace_burn_duration + // @input DurationTag // @description - // Sets the burn time for a furnace in ticks. Maximum is 32767. + // Sets the burn time for a furnace in ticks. Maximum is 32767 ticks. // @tags - // + // // --> + if (mechanism.matches("furnace_burn_duration") && mechanism.requireObject(DurationTag.class)) { + if (getBlockState() instanceof Furnace) { + Furnace furnace = (Furnace) getBlockState(); + furnace.setBurnTime((short) mechanism.valueAsType(DurationTag.class).getTicks()); + furnace.update(); + } + } if (mechanism.matches("furnace_burn_time")) { + Deprecations.furnaceTimeTags.warn(mechanism.context); if (getBlockState() instanceof Furnace) { Furnace furnace = (Furnace) getBlockState(); furnace.setBurnTime((short) mechanism.getValue().asInt()); @@ -3459,14 +3479,22 @@ && getBlockState() instanceof CreatureSpawner) { // <--[mechanism] // @object LocationTag - // @name furnace_cook_time - // @input ElementTag(Number) + // @name furnace_cook_duration + // @input DurationTag // @description - // Sets the current cook time for a furnace in ticks. Maximum is 32767. + // Sets the current cook time for a furnace in ticks. Maximum is 32767 ticks. // @tags - // + // // --> + if (mechanism.matches("furnace_cook_duration")) { + if (getBlockState() instanceof Furnace) { + Furnace furnace = (Furnace) getBlockState(); + furnace.setCookTime((short) mechanism.valueAsType(DurationTag.class).getTicks()); + furnace.update(); + } + } if (mechanism.matches("furnace_cook_time")) { + Deprecations.furnaceTimeTags.warn(mechanism.context); if (getBlockState() instanceof Furnace) { Furnace furnace = (Furnace) getBlockState(); furnace.setCookTime((short) mechanism.getValue().asInt()); @@ -3476,14 +3504,22 @@ && getBlockState() instanceof CreatureSpawner) { // <--[mechanism] // @object LocationTag - // @name furnace_cook_time_total - // @input ElementTag(Number) + // @name furnace_cook_duration_total + // @input DurationTag // @description - // Sets the total cook time for a furnace in ticks. Maximum is 32767. + // Sets the total cook time for a furnace in ticks. Maximum is 32767 ticks. // @tags - // + // // --> + if (mechanism.matches("furnace_cook_duration_total")) { + if (getBlockState() instanceof Furnace) { + Furnace furnace = (Furnace) getBlockState(); + furnace.setCookTimeTotal((short) mechanism.valueAsType(DurationTag.class).getTicks()); + furnace.update(); + } + } if (mechanism.matches("furnace_cook_time_total")) { + Deprecations.furnaceTimeTags.warn(mechanism.context); if (getBlockState() instanceof Furnace) { Furnace furnace = (Furnace) getBlockState(); furnace.setCookTimeTotal((short) mechanism.getValue().asInt()); diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/MaterialTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/MaterialTag.java index 274462328f..2ae382582f 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/MaterialTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/MaterialTag.java @@ -702,31 +702,6 @@ public static void registerTags() { return new ElementTag(object.material.getMaxStackSize()); }); - // <--[tag] - // @attribute ]> - // @returns ElementTag(Boolean) - // @description - // Returns true if the material is a variety of the specified material. - // Example: will return true. - // Invalid for 1.13+ servers. - // --> - registerTag("is_made_of", (attribute, object) -> { - MaterialTag compared = attribute.contextAsType(1, MaterialTag.class); - return new ElementTag(compared != null && object.material == compared.getMaterial()); - }); - - // <--[tag] - // @attribute - // @returns ElementTag - // @description - // Returns the bukkit Material enum value. For example: - // will return 'sapling' - // Unneeded for 1.13+ servers. - // --> - registerTag("bukkit_enum", (attribute, object) -> { - return new ElementTag(object.material.name()); - }); - // <--[tag] // @attribute // @returns ElementTag @@ -751,24 +726,7 @@ public static void registerTags() { // Returns the name of the material. // --> registerTag("name", (attribute, object) -> { - return new ElementTag(object.forcedIdentity != null ? object.forcedIdentityLow : - CoreUtilities.toLowerCase(object.material.name())); - }); - - // <--[tag] - // @attribute - // @returns ElementTag - // @description - // Returns the material's full identification. - // Irrelevant on modern (1.13+) servers. - // --> - registerTag("full", (attribute, object) -> { - if (object.hasData()) { - return new ElementTag(object.identifyFull()); - } - else { - return new ElementTag(object.identify()); - } + return new ElementTag(object.forcedIdentity != null ? object.forcedIdentityLow : CoreUtilities.toLowerCase(object.material.name())); }); // <--[tag]