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