diff --git a/paper-api/src/main/java/org/bukkit/Material.java b/paper-api/src/main/java/org/bukkit/Material.java index 492e93a06d..f15acb4073 100644 --- a/paper-api/src/main/java/org/bukkit/Material.java +++ b/paper-api/src/main/java/org/bukkit/Material.java @@ -71,7 +71,7 @@ public enum Material { RAILS(66), COBBLESTONE_STAIRS(67), WALL_SIGN(68), - LEVER(69), + LEVER(69, Lever.class), STONE_PLATE(70), IRON_DOOR_BLOCK(71), WOOD_PLATE(72), diff --git a/paper-api/src/main/java/org/bukkit/material/Lever.java b/paper-api/src/main/java/org/bukkit/material/Lever.java new file mode 100644 index 0000000000..85c27496b0 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/material/Lever.java @@ -0,0 +1,61 @@ + +package org.bukkit.material; + +import org.bukkit.BlockFace; +import org.bukkit.Material; + +/** + * Represents a lever + */ +public class Lever extends MaterialData implements Redstone, Attachable { + public Lever(final int type) { + super(type); + } + + public Lever(final Material type) { + super(type); + } + + public Lever(final int type, final byte data) { + super(type, data); + } + + public Lever(final Material type, final byte data) { + super(type, data); + } + + /** + * Gets the current state of this Material, indicating if it's powered or + * unpowered + * + * @return true if powered, otherwise false + */ + public boolean isPowered() { + return (getData() & 0x8) == 0x8; + } + + /** + * Gets the face that this block is attached on + * + * @return BlockFace attached to + */ + public BlockFace getAttachedFace() { + byte data = (byte) (getData() ^ 0x8); + + switch (data) { + case 0x1: + return BlockFace.NORTH; + case 0x2: + return BlockFace.SOUTH; + case 0x3: + return BlockFace.EAST; + case 0x4: + return BlockFace.WEST; + case 0x5: + case 0x6: + return BlockFace.DOWN; + } + + return null; + } +}