2011-03-14 18:08:57 -07:00
|
|
|
package org.bukkit;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
2012-01-29 11:10:40 +01:00
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
2011-03-14 18:08:57 -07:00
|
|
|
/**
|
|
|
|
* Represents the different growth states of crops
|
|
|
|
*/
|
|
|
|
public enum CropState {
|
2011-05-14 23:22:54 +02:00
|
|
|
|
2011-03-14 18:08:57 -07:00
|
|
|
/**
|
|
|
|
* State when first seeded
|
|
|
|
*/
|
2012-01-29 11:10:40 +01:00
|
|
|
SEEDED(0x0),
|
2011-03-14 18:08:57 -07:00
|
|
|
/**
|
|
|
|
* First growth stage
|
|
|
|
*/
|
2012-01-29 11:10:40 +01:00
|
|
|
GERMINATED(0x1),
|
2011-03-14 18:08:57 -07:00
|
|
|
/**
|
|
|
|
* Second growth stage
|
|
|
|
*/
|
2012-01-29 11:10:40 +01:00
|
|
|
VERY_SMALL(0x2),
|
2011-03-14 18:08:57 -07:00
|
|
|
/**
|
|
|
|
* Third growth stage
|
|
|
|
*/
|
2012-01-29 11:10:40 +01:00
|
|
|
SMALL(0x3),
|
2011-03-14 18:08:57 -07:00
|
|
|
/**
|
|
|
|
* Fourth growth stage
|
|
|
|
*/
|
2012-01-29 11:10:40 +01:00
|
|
|
MEDIUM(0x4),
|
2011-03-14 18:08:57 -07:00
|
|
|
/**
|
|
|
|
* Fifth growth stage
|
|
|
|
*/
|
2012-01-29 11:10:40 +01:00
|
|
|
TALL(0x5),
|
2011-03-14 18:08:57 -07:00
|
|
|
/**
|
|
|
|
* Almost ripe stage
|
|
|
|
*/
|
2012-01-29 11:10:40 +01:00
|
|
|
VERY_TALL(0x6),
|
2011-03-14 18:08:57 -07:00
|
|
|
/**
|
|
|
|
* Ripe stage
|
|
|
|
*/
|
2012-01-29 11:10:40 +01:00
|
|
|
RIPE(0x7);
|
2011-03-14 18:08:57 -07:00
|
|
|
|
|
|
|
private final byte data;
|
2012-01-29 11:10:40 +01:00
|
|
|
private final static Map<Byte, CropState> BY_DATA = Maps.newHashMap();
|
2011-03-14 18:08:57 -07:00
|
|
|
|
2012-01-29 11:10:40 +01:00
|
|
|
private CropState(final int data) {
|
|
|
|
this.data = (byte) data;
|
2011-03-14 18:08:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the associated data value representing this growth state
|
|
|
|
*
|
|
|
|
* @return A byte containing the data value of this growth state
|
|
|
|
*/
|
|
|
|
public byte getData() {
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the CropState with the given data value
|
|
|
|
*
|
|
|
|
* @param data
|
|
|
|
* Data value to fetch
|
|
|
|
* @return The {@link CropState} representing the given value, or null if
|
|
|
|
* it doesn't exist
|
|
|
|
*/
|
|
|
|
public static CropState getByData(final byte data) {
|
2012-01-29 11:10:40 +01:00
|
|
|
return BY_DATA.get(data);
|
2011-03-14 18:08:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static {
|
2012-01-29 11:10:40 +01:00
|
|
|
for (CropState cropState : values()) {
|
|
|
|
BY_DATA.put(cropState.getData(), cropState);
|
2011-03-14 18:08:57 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|