2011-06-17 09:00:49 +02:00
|
|
|
package org.bukkit;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
2012-01-29 11:10:40 +01:00
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
2011-06-17 09:00:49 +02:00
|
|
|
public enum Instrument {
|
|
|
|
|
2012-02-26 18:13:30 +01:00
|
|
|
/**
|
|
|
|
* Piano is the standard instrument for a note block.
|
|
|
|
*/
|
|
|
|
PIANO(0x0),
|
|
|
|
/**
|
|
|
|
* Bass drum is normally played when a note block is on top of a stone-like block
|
|
|
|
*/
|
|
|
|
BASS_DRUM(0x1),
|
|
|
|
/**
|
|
|
|
* Snare drum is normally played when a note block is on top of a sandy block.
|
|
|
|
*/
|
|
|
|
SNARE_DRUM(0x2),
|
|
|
|
/**
|
|
|
|
* Sticks are normally played when a note block is on top of a glass block.
|
|
|
|
*/
|
|
|
|
STICKS(0x3),
|
|
|
|
/**
|
|
|
|
* Bass guitar is normally played when a note block is on top of a wooden block.
|
|
|
|
*/
|
|
|
|
BASS_GUITAR(0x4);
|
2011-06-17 09:00:49 +02:00
|
|
|
|
|
|
|
private final byte type;
|
2012-01-29 11:10:40 +01:00
|
|
|
private final static Map<Byte, Instrument> BY_DATA = Maps.newHashMap();
|
2011-06-17 09:00:49 +02:00
|
|
|
|
2012-01-29 11:10:40 +01:00
|
|
|
private Instrument(final int type) {
|
|
|
|
this.type = (byte) type;
|
2011-06-17 09:00:49 +02:00
|
|
|
}
|
|
|
|
|
2012-02-26 18:13:30 +01:00
|
|
|
/**
|
|
|
|
* @return The type ID of this instrument.
|
|
|
|
*/
|
2011-06-17 09:00:49 +02:00
|
|
|
public byte getType() {
|
|
|
|
return this.type;
|
|
|
|
}
|
|
|
|
|
2012-02-26 18:13:30 +01:00
|
|
|
/**
|
|
|
|
* Get an instrument by its type ID.
|
2013-08-04 03:46:30 +02:00
|
|
|
*
|
2012-02-26 18:13:30 +01:00
|
|
|
* @param type The type ID
|
|
|
|
* @return The instrument
|
|
|
|
*/
|
2011-06-17 09:00:49 +02:00
|
|
|
public static Instrument getByType(final byte type) {
|
2012-01-29 11:10:40 +01:00
|
|
|
return BY_DATA.get(type);
|
2011-06-17 09:00:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static {
|
|
|
|
for (Instrument instrument : Instrument.values()) {
|
2012-01-29 11:10:40 +01:00
|
|
|
BY_DATA.put(instrument.getType(), instrument);
|
2011-06-17 09:00:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|