Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 78 lines 1.5 kB view raw
1package org.bukkit; 2 3import java.util.HashMap; 4import java.util.Map; 5 6/** 7 * Represents the different growth states of crops 8 * 9 * @author sunkid 10 */ 11public enum CropState { 12 13 /** 14 * State when first seeded 15 */ 16 SEEDED((byte) 0x0), 17 /** 18 * First growth stage 19 */ 20 GERMINATED((byte) 0x1), 21 /** 22 * Second growth stage 23 */ 24 VERY_SMALL((byte) 0x2), 25 /** 26 * Third growth stage 27 */ 28 SMALL((byte) 0x3), 29 /** 30 * Fourth growth stage 31 */ 32 MEDIUM((byte) 0x4), 33 /** 34 * Fifth growth stage 35 */ 36 TALL((byte) 0x5), 37 /** 38 * Almost ripe stage 39 */ 40 VERY_TALL((byte) 0x6), 41 /** 42 * Ripe stage 43 */ 44 RIPE((byte) 0x7); 45 46 private final byte data; 47 private final static Map<Byte, CropState> states = new HashMap<Byte, CropState>(); 48 49 private CropState(final byte data) { 50 this.data = data; 51 } 52 53 /** 54 * Gets the associated data value representing this growth state 55 * 56 * @return A byte containing the data value of this growth state 57 */ 58 public byte getData() { 59 return data; 60 } 61 62 /** 63 * Gets the CropState with the given data value 64 * 65 * @param data Data value to fetch 66 * @return The {@link CropState} representing the given value, or null if 67 * it doesn't exist 68 */ 69 public static CropState getByData(final byte data) { 70 return states.get(data); 71 } 72 73 static { 74 for (CropState s : CropState.values()) { 75 states.put(s.getData(), s); 76 } 77 } 78}