001 package org.bukkit; 002 003 import java.util.Map; 004 005 import com.google.common.collect.Maps; 006 007 /** 008 * Represents the different types of grass. 009 */ 010 public enum GrassSpecies { 011 012 /** 013 * Represents the dead looking grass. 014 */ 015 DEAD(0x0), 016 /** 017 * Represents the normal grass species. 018 */ 019 NORMAL(0x1), 020 /** 021 * Represents the fern-looking grass species. 022 */ 023 FERN_LIKE(0x2); 024 025 private final byte data; 026 private final static Map<Byte, GrassSpecies> BY_DATA = Maps.newHashMap(); 027 028 private GrassSpecies(final int data) { 029 this.data = (byte) data; 030 } 031 032 /** 033 * Gets the associated data value representing this species 034 * 035 * @return A byte containing the data value of this grass species 036 * @deprecated Magic value 037 */ 038 @Deprecated 039 public byte getData() { 040 return data; 041 } 042 043 /** 044 * Gets the GrassSpecies with the given data value 045 * 046 * @param data Data value to fetch 047 * @return The {@link GrassSpecies} representing the given value, or null 048 * if it doesn't exist 049 * @deprecated Magic value 050 */ 051 @Deprecated 052 public static GrassSpecies getByData(final byte data) { 053 return BY_DATA.get(data); 054 } 055 056 static { 057 for (GrassSpecies grassSpecies : values()) { 058 BY_DATA.put(grassSpecies.getData(), grassSpecies); 059 } 060 } 061 }