From 32b2b3fb59913a265cd8de4f341e041c4d2b1047 Mon Sep 17 00:00:00 2001 From: MCSamuel Date: Sun, 12 Oct 2025 18:26:24 -0700 Subject: [PATCH 1/6] Added Dried Ghast Hydration Level --- .../properties/material/MaterialLevel.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java index 054573c513..190c408f34 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java @@ -9,10 +9,7 @@ import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Brushable; import org.bukkit.block.data.Levelled; -import org.bukkit.block.data.type.Beehive; -import org.bukkit.block.data.type.Cake; -import org.bukkit.block.data.type.Farmland; -import org.bukkit.block.data.type.Snow; +import org.bukkit.block.data.type.*; public class MaterialLevel extends MaterialProperty { @@ -32,6 +29,7 @@ public class MaterialLevel extends MaterialProperty { // For farmland, this is the moisture level. // For composters, this is the amount of compost. // For brushable blocks (also referred to as "suspicious blocks"), this is the level of dusting. 1.20+ only. + // For dried ghasts, this is the level of hydration. 1.21+ only. // See also <@link tag MaterialTag.maximum_level> and <@link tag MaterialTag.minimum_level>. // --> @@ -42,7 +40,8 @@ public static boolean describes(MaterialTag material) { || data instanceof Snow || data instanceof Farmland || data instanceof Beehive - || (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20) && data instanceof Brushable); + || (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20) && data instanceof Brushable) + || (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21) && data instanceof DriedGhast); } @Override @@ -136,6 +135,10 @@ public boolean isBrushable() { return NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20) && getBlockData() instanceof Brushable; } + public boolean isDriedGhast() { + return NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21) && getBlockData() instanceof DriedGhast; + } + public int getCurrent() { if (isCake()) { return getCake().getBites(); @@ -152,6 +155,9 @@ else if (isFarmland()) { else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20) && isBrushable()) { return ((Brushable) getBlockData()).getDusted(); } + else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21) && isDriedGhast()) { + return ((DriedGhast) getBlockData()).getHydration(); + } return getLevelled().getLevel(); } @@ -171,6 +177,9 @@ else if (isFarmland()) { else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20) && isBrushable()) { return ((Brushable) getBlockData()).getMaximumDusted(); } + else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21) && isDriedGhast()) { + return ((DriedGhast) getBlockData()).getMaximumHydration(); + } return getLevelled().getMaximumLevel(); } @@ -202,6 +211,10 @@ else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20) && isBrushable()) { ((Brushable) getBlockData()).setDusted(level); return; } + else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21) && isDriedGhast()) { + ((DriedGhast) getBlockData()).setHydration(level); + return; + } getLevelled().setLevel(level); } } From d81e4c10c7f2e5cd2c4aa31fb189d77212f565ea Mon Sep 17 00:00:00 2001 From: MCSamuel Date: Sun, 12 Oct 2025 23:50:05 -0700 Subject: [PATCH 2/6] Removed unnecessary version checks --- .../objects/properties/material/MaterialLevel.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java index 190c408f34..05ff9e52c3 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java @@ -152,10 +152,10 @@ else if (isHive()) { else if (isFarmland()) { return getFarmland().getMoisture(); } - else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20) && isBrushable()) { + else if (isBrushable()) { return ((Brushable) getBlockData()).getDusted(); } - else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21) && isDriedGhast()) { + else if (isDriedGhast()) { return ((DriedGhast) getBlockData()).getHydration(); } return getLevelled().getLevel(); @@ -174,10 +174,10 @@ else if (isHive()) { else if (isFarmland()) { return getFarmland().getMaximumMoisture(); } - else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20) && isBrushable()) { + else if (isBrushable()) { return ((Brushable) getBlockData()).getMaximumDusted(); } - else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21) && isDriedGhast()) { + else if (isDriedGhast()) { return ((DriedGhast) getBlockData()).getMaximumHydration(); } return getLevelled().getMaximumLevel(); @@ -207,11 +207,11 @@ else if (isFarmland()) { getFarmland().setMoisture(level); return; } - else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20) && isBrushable()) { + else if (isBrushable()) { ((Brushable) getBlockData()).setDusted(level); return; } - else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21) && isDriedGhast()) { + else if (isDriedGhast()) { ((DriedGhast) getBlockData()).setHydration(level); return; } From 89f869bea3ab42cff7ef447c02a80df04841df38 Mon Sep 17 00:00:00 2001 From: MCSamuel Date: Thu, 30 Oct 2025 10:18:35 -0700 Subject: [PATCH 3/6] minor changes, removed multiple `isX` and `getX` methods --- .../properties/material/MaterialLevel.java | 179 ++++++------------ 1 file changed, 61 insertions(+), 118 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java index 05ff9e52c3..1cd7ea55bb 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java @@ -46,7 +46,28 @@ public static boolean describes(MaterialTag material) { @Override public ElementTag getPropertyValue() { - return new ElementTag(getCurrent()); + if (getBlockData() instanceof Cake cake) { + return new ElementTag(cake.getBites()); + } + else if (getBlockData() instanceof Snow snow) { + return new ElementTag(snow.getLayers()); + } + else if (getBlockData() instanceof Beehive beehive) { + return new ElementTag(beehive.getHoneyLevel()); + } + else if (getBlockData() instanceof Farmland farmland) { + return new ElementTag(farmland.getMoisture()); + } + else if (getBlockData() instanceof Levelled levelled) { + return new ElementTag(levelled.getLevel()); + } + else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20) && getBlockData() instanceof Brushable brushable) { + return new ElementTag(brushable.getDusted()); + } + else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21) && getBlockData() instanceof DriedGhast driedGhast) { + return new ElementTag(driedGhast.getHydration()); + } + return null; } @Override @@ -60,11 +81,31 @@ public void setPropertyValue(ElementTag value, Mechanism mechanism) { return; } int level = value.asInt(); - if (level < getMin() || level > getMax()) { - mechanism.echoError("Level value '" + level + "' is not valid. Must be between " + getMin() + " and " + getMax() + " for material '" + getBlockData().getMaterial().name() + "'."); + if (level < (getBlockData() instanceof Snow snow ? snow.getMinimumLayers() : 0) || level > getMax()) { + mechanism.echoError("Level value '" + level + "' is not valid. Must be between " + (getBlockData() instanceof Snow snow ? snow.getMinimumLayers() : 0) + " and " + getMax() + " for material '" + getBlockData().getMaterial().name() + "'."); return; } - setCurrent(level); + if (getBlockData() instanceof Cake cake) { + cake.setBites(level); + } + else if (getBlockData() instanceof Snow snow) { + snow.setLayers(level); + } + else if (getBlockData() instanceof Beehive beehive) { + beehive.setHoneyLevel(level); + } + else if (getBlockData() instanceof Farmland farmland) { + farmland.setMoisture(level); + } + else if (getBlockData() instanceof Levelled levelled) { + levelled.setLevel(level); + } + else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20) && getBlockData() instanceof Brushable brushable) { + brushable.setDusted(level); + } + else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21) && getBlockData() instanceof DriedGhast driedGhast) { + driedGhast.setHydration(level); + } } public static void register() { @@ -89,132 +130,34 @@ public static void register() { // This will return 0 for all valid materials aside from snow. // --> PropertyParser.registerStaticTag(MaterialLevel.class, ElementTag.class, "minimum_level", (attribute, material) -> { - return new ElementTag(material.getMin()); + return new ElementTag(material.getBlockData() instanceof Snow snow ? snow.getMinimumLayers() : 0); }); autoRegister("level", MaterialLevel.class, ElementTag.class, false); } - public Levelled getLevelled() { - return (Levelled) getBlockData(); - } - - public boolean isCake() { - return getBlockData() instanceof Cake; - } - - public Cake getCake() { - return (Cake) getBlockData(); - } - - public boolean isSnow() { - return getBlockData() instanceof Snow; - } - - public Snow getSnow() { - return (Snow) getBlockData(); - } - - public boolean isHive() { - return getBlockData() instanceof Beehive; - } - - public Beehive getHive() { - return (Beehive) getBlockData(); - } - - public boolean isFarmland() { - return getBlockData() instanceof Farmland; - } - - public Farmland getFarmland() { - return (Farmland) getBlockData(); - } - - public boolean isBrushable() { - return NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20) && getBlockData() instanceof Brushable; - } - - public boolean isDriedGhast() { - return NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21) && getBlockData() instanceof DriedGhast; - } - - public int getCurrent() { - if (isCake()) { - return getCake().getBites(); - } - else if (isSnow()) { - return getSnow().getLayers(); - } - else if (isHive()) { - return getHive().getHoneyLevel(); - } - else if (isFarmland()) { - return getFarmland().getMoisture(); - } - else if (isBrushable()) { - return ((Brushable) getBlockData()).getDusted(); - } - else if (isDriedGhast()) { - return ((DriedGhast) getBlockData()).getHydration(); - } - return getLevelled().getLevel(); - } - public int getMax() { - if (isCake()) { - return getCake().getMaximumBites(); - } - else if (isSnow()) { - return getSnow().getMaximumLayers(); + if (getBlockData() instanceof Cake cake) { + return cake.getMaximumBites(); } - else if (isHive()) { - return getHive().getMaximumHoneyLevel(); + else if (getBlockData() instanceof Snow snow) { + return snow.getMaximumLayers(); } - else if (isFarmland()) { - return getFarmland().getMaximumMoisture(); + else if (getBlockData() instanceof Beehive beehive) { + return beehive.getMaximumHoneyLevel(); } - else if (isBrushable()) { - return ((Brushable) getBlockData()).getMaximumDusted(); + else if (getBlockData() instanceof Farmland farmland) { + return farmland.getMaximumMoisture(); } - else if (isDriedGhast()) { - return ((DriedGhast) getBlockData()).getMaximumHydration(); + else if (getBlockData() instanceof Levelled levelled) { + return levelled.getMaximumLevel(); } - return getLevelled().getMaximumLevel(); - } - - public int getMin() { - if (isSnow()) { - return getSnow().getMinimumLayers(); - } - return 0; - } - - public void setCurrent(int level) { - if (isCake()) { - getCake().setBites(level); - return; - } - else if (isSnow()) { - getSnow().setLayers(level); - return; + else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20) && getBlockData() instanceof Brushable brushable) { + return brushable.getMaximumDusted(); } - else if (isHive()) { - getHive().setHoneyLevel(level); - return; - } - else if (isFarmland()) { - getFarmland().setMoisture(level); - return; - } - else if (isBrushable()) { - ((Brushable) getBlockData()).setDusted(level); - return; - } - else if (isDriedGhast()) { - ((DriedGhast) getBlockData()).setHydration(level); - return; + else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21) && getBlockData() instanceof DriedGhast driedGhast) { + return driedGhast.getMaximumHydration(); } - getLevelled().setLevel(level); + throw new UnsupportedOperationException(); } } From 47f5d16aec8be4aecab8ab6fc434a4c273aabbfa Mon Sep 17 00:00:00 2001 From: MCSamuel Date: Wed, 12 Nov 2025 17:16:34 -0800 Subject: [PATCH 4/6] getMin added back --- .../objects/properties/material/MaterialLevel.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java index 1cd7ea55bb..31417e9094 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java @@ -130,7 +130,7 @@ public static void register() { // This will return 0 for all valid materials aside from snow. // --> PropertyParser.registerStaticTag(MaterialLevel.class, ElementTag.class, "minimum_level", (attribute, material) -> { - return new ElementTag(material.getBlockData() instanceof Snow snow ? snow.getMinimumLayers() : 0); + return new ElementTag(material.getMin()); }); autoRegister("level", MaterialLevel.class, ElementTag.class, false); @@ -160,4 +160,11 @@ else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21) && getBlockData() i } throw new UnsupportedOperationException(); } + + public int getMin() { + if (getBlockData() instanceof Snow snow) { + return snow.getMinimumLayers(); + } + return 0; + } } From e7296e780544fb6721dc49dea974806442b8d3bb Mon Sep 17 00:00:00 2001 From: MCSamuel Date: Thu, 13 Nov 2025 11:16:24 -0800 Subject: [PATCH 5/6] whoops --- .../denizen/objects/properties/material/MaterialLevel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java index 31417e9094..6793b6338b 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java @@ -81,7 +81,7 @@ public void setPropertyValue(ElementTag value, Mechanism mechanism) { return; } int level = value.asInt(); - if (level < (getBlockData() instanceof Snow snow ? snow.getMinimumLayers() : 0) || level > getMax()) { + if (level < getMin() || level > getMax()) { mechanism.echoError("Level value '" + level + "' is not valid. Must be between " + (getBlockData() instanceof Snow snow ? snow.getMinimumLayers() : 0) + " and " + getMax() + " for material '" + getBlockData().getMaterial().name() + "'."); return; } From cc950357dfe6db4c4539f7b6f431ba950f42452e Mon Sep 17 00:00:00 2001 From: MCSamuel Date: Fri, 12 Dec 2025 16:02:46 -0800 Subject: [PATCH 6/6] last one --- .../denizen/objects/properties/material/MaterialLevel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java index 6793b6338b..08b3bff668 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/properties/material/MaterialLevel.java @@ -82,7 +82,7 @@ public void setPropertyValue(ElementTag value, Mechanism mechanism) { } int level = value.asInt(); if (level < getMin() || level > getMax()) { - mechanism.echoError("Level value '" + level + "' is not valid. Must be between " + (getBlockData() instanceof Snow snow ? snow.getMinimumLayers() : 0) + " and " + getMax() + " for material '" + getBlockData().getMaterial().name() + "'."); + mechanism.echoError("Level value '" + level + "' is not valid. Must be between " + getMin() + " and " + getMax() + " for material '" + getBlockData().getMaterial().name() + "'."); return; } if (getBlockData() instanceof Cake cake) {