diff --git a/paper-api/src/main/java/org/bukkit/Material.java b/paper-api/src/main/java/org/bukkit/Material.java index 92a3395254..efc5a219a8 100644 --- a/paper-api/src/main/java/org/bukkit/Material.java +++ b/paper-api/src/main/java/org/bukkit/Material.java @@ -29,6 +29,7 @@ import org.bukkit.material.LongGrass; import org.bukkit.material.MaterialData; import org.bukkit.material.MonsterEggs; import org.bukkit.material.Mushroom; +import org.bukkit.material.NetherWarts; import org.bukkit.material.PistonBaseMaterial; import org.bukkit.material.PistonExtensionMaterial; import org.bukkit.material.PoweredRail; @@ -176,7 +177,7 @@ public enum Material { NETHER_BRICK(112), NETHER_FENCE(113), NETHER_BRICK_STAIRS(114, Stairs.class), - NETHER_WARTS(115, MaterialData.class), + NETHER_WARTS(115, NetherWarts.class), ENCHANTMENT_TABLE(116), BREWING_STAND(117, MaterialData.class), CAULDRON(118, Cauldron.class), diff --git a/paper-api/src/main/java/org/bukkit/NetherWartsState.java b/paper-api/src/main/java/org/bukkit/NetherWartsState.java new file mode 100644 index 0000000000..ae557e80e8 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/NetherWartsState.java @@ -0,0 +1,20 @@ +package org.bukkit; + +public enum NetherWartsState { + /** + * State when first seeded + */ + SEEDED, + /** + * First growth stage + */ + STAGE_ONE, + /** + * Second growth stage + */ + STAGE_TWO, + /** + * Ready to harvest + */ + RIPE; +} diff --git a/paper-api/src/main/java/org/bukkit/material/NetherWarts.java b/paper-api/src/main/java/org/bukkit/material/NetherWarts.java new file mode 100644 index 0000000000..b8caad5302 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/material/NetherWarts.java @@ -0,0 +1,84 @@ +package org.bukkit.material; + +import org.bukkit.Material; +import org.bukkit.NetherWartsState; + +/** + * Represents nether wart + */ +public class NetherWarts extends MaterialData { + public NetherWarts() { + super(Material.NETHER_WARTS); + } + + public NetherWarts(NetherWartsState state) { + this(); + setState(state); + } + + public NetherWarts(final int type) { + super(type); + } + + public NetherWarts(final Material type) { + super (type); + } + + public NetherWarts(final int type, final byte data) { + super(type, data); + } + + public NetherWarts(final Material type, final byte data) { + super(type, data); + } + + /** + * Gets the current growth state of this nether wart + * + * @return NetherWartsState of this nether wart + */ + public NetherWartsState getState() { + switch (getData()) { + case 0: + return NetherWartsState.SEEDED; + case 1: + return NetherWartsState.STAGE_ONE; + case 2: + return NetherWartsState.STAGE_TWO; + default: + return NetherWartsState.RIPE; + } + } + + /** + * Sets the growth state of this nether wart + * + * @param state New growth state of this nether wart + */ + public void setState(NetherWartsState state) { + switch (state) { + case SEEDED: + setData((byte) 0x0); + return; + case STAGE_ONE: + setData((byte) 0x1); + return; + case STAGE_TWO: + setData((byte) 0x2); + return; + case RIPE: + setData((byte) 0x3); + return; + } + } + + @Override + public String toString() { + return getState() + " " + super.toString(); + } + + @Override + public NetherWarts clone() { + return (NetherWarts) super.clone(); + } +}