Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 94 lines 2.1 kB view raw
1package org.bukkit.material; 2 3import org.bukkit.Material; 4 5import java.util.HashSet; 6 7/** 8 * Represents the different types of steps. 9 */ 10public class Step extends MaterialData { 11 private static HashSet<Material> stepTypes = new HashSet<Material>(); 12 13 static { 14 stepTypes.add(Material.SANDSTONE); 15 stepTypes.add(Material.WOOD); 16 stepTypes.add(Material.COBBLESTONE); 17 stepTypes.add(Material.STONE); 18 } 19 20 public Step() { 21 super(Material.STEP); 22 } 23 24 public Step(final int type) { 25 super(type); 26 } 27 28 public Step(final Material type) { 29 super((stepTypes.contains(type)) ? Material.STEP : type); 30 if (stepTypes.contains(type)) { 31 setMaterial(type); 32 } 33 } 34 35 public Step(final int type, final byte data) { 36 super(type, data); 37 } 38 39 public Step(final Material type, final byte data) { 40 super(type, data); 41 } 42 43 /** 44 * Gets the current Material this step is made of 45 * 46 * @return Material of this step 47 */ 48 public Material getMaterial() { 49 switch ((int) getData()) { 50 case 1: 51 return Material.SANDSTONE; 52 53 case 2: 54 return Material.WOOD; 55 56 case 3: 57 return Material.COBBLESTONE; 58 59 case 0: 60 default: 61 return Material.STONE; 62 } 63 } 64 65 /** 66 * Sets the material this step is made of 67 * 68 * @param material New material of this step 69 */ 70 public void setMaterial(Material material) { 71 switch (material) { 72 case SANDSTONE: 73 setData((byte) 0x1); 74 break; 75 76 case WOOD: 77 setData((byte) 0x2); 78 break; 79 80 case COBBLESTONE: 81 setData((byte) 0x3); 82 break; 83 84 case STONE: 85 default: 86 setData((byte) 0x0); 87 } 88 } 89 90 @Override 91 public String toString() { 92 return getMaterial() + " " + super.toString(); 93 } 94}