Skip to content

Commit

Permalink
deprecate cuboid.full, upgrade location.furnace_*_time, delete 1.12 m…
Browse files Browse the repository at this point in the history
…aterial tags
  • Loading branch information
mcmonkey4eva committed Jul 4, 2020
1 parent c0038af commit a8e1e38
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 71 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -1501,14 +1502,8 @@ public static void registerTags() {
return new ElementTag(notname);
});

// <--[tag]
// @attribute <CuboidTag.full>
// @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());
});
}
Expand Down
Expand Up @@ -2981,35 +2981,47 @@ else if (attribute.startsWith("vertical", 2)) {
});

// <--[tag]
// @attribute <LocationTag.furnace_burn_time>
// @returns ElementTag(Number)
// @mechanism LocationTag.furnace_burn_time
// @attribute <LocationTag.furnace_burn_duration>
// @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 <LocationTag.furnace_cook_time>
// @returns ElementTag(Number)
// @mechanism LocationTag.furnace_cook_time
// @attribute <LocationTag.furnace_burn_duration>
// @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 <LocationTag.furnace_cook_time_total>
// @returns ElementTag(Number)
// @mechanism LocationTag.furnace_cook_time_total
// @attribute <LocationTag.furnace_cook_duration_total>
// @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());
});

Expand Down Expand Up @@ -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
// <LocationTag.furnace_burn_time>
// <LocationTag.furnace_burn_duration>
// -->
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());
Expand All @@ -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
// <LocationTag.furnace_cook_time>
// <LocationTag.furnace_burn_duration>
// -->
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());
Expand All @@ -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
// <LocationTag.furnace_cook_time_total>
// <LocationTag.furnace_cook_duration_total>
// -->
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());
Expand Down
Expand Up @@ -702,31 +702,6 @@ public static void registerTags() {
return new ElementTag(object.material.getMaxStackSize());
});

// <--[tag]
// @attribute <MaterialTag.is_made_of[<material>]>
// @returns ElementTag(Boolean)
// @description
// Returns true if the material is a variety of the specified material.
// Example: <m@red_wool.is_made_of[m@wool]> 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 <MaterialTag.bukkit_enum>
// @returns ElementTag
// @description
// Returns the bukkit Material enum value. For example: <m@birch_sapling.bukkit_enum>
// will return 'sapling'
// Unneeded for 1.13+ servers.
// -->
registerTag("bukkit_enum", (attribute, object) -> {
return new ElementTag(object.material.name());
});

// <--[tag]
// @attribute <MaterialTag.translated_name>
// @returns ElementTag
Expand All @@ -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 <MaterialTag.full>
// @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]
Expand Down

0 comments on commit a8e1e38

Please sign in to comment.