001 package org.bukkit;
002
003 import java.util.Map;
004
005 import com.google.common.collect.Maps;
006
007 public enum Instrument {
008
009 /**
010 * Piano is the standard instrument for a note block.
011 */
012 PIANO(0x0),
013 /**
014 * Bass drum is normally played when a note block is on top of a
015 * stone-like block
016 */
017 BASS_DRUM(0x1),
018 /**
019 * Snare drum is normally played when a note block is on top of a sandy
020 * block.
021 */
022 SNARE_DRUM(0x2),
023 /**
024 * Sticks are normally played when a note block is on top of a glass
025 * block.
026 */
027 STICKS(0x3),
028 /**
029 * Bass guitar is normally played when a note block is on top of a wooden
030 * block.
031 */
032 BASS_GUITAR(0x4);
033
034 private final byte type;
035 private final static Map<Byte, Instrument> BY_DATA = Maps.newHashMap();
036
037 private Instrument(final int type) {
038 this.type = (byte) type;
039 }
040
041 /**
042 * @return The type ID of this instrument.
043 * @deprecated Magic value
044 */
045 @Deprecated
046 public byte getType() {
047 return this.type;
048 }
049
050 /**
051 * Get an instrument by its type ID.
052 *
053 * @param type The type ID
054 * @return The instrument
055 * @deprecated Magic value
056 */
057 @Deprecated
058 public static Instrument getByType(final byte type) {
059 return BY_DATA.get(type);
060 }
061
062 static {
063 for (Instrument instrument : Instrument.values()) {
064 BY_DATA.put(instrument.getType(), instrument);
065 }
066 }
067 }