2011-04-21 20:56:19 +01:00
|
|
|
package org.bukkit;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
2012-01-29 11:10:40 +01:00
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
2011-04-21 20:56:19 +01:00
|
|
|
/**
|
|
|
|
* Represents an achievement, which may be given to players
|
|
|
|
*/
|
|
|
|
public enum Achievement {
|
|
|
|
OPEN_INVENTORY(0),
|
|
|
|
MINE_WOOD(1),
|
|
|
|
BUILD_WORKBENCH(2),
|
|
|
|
BUILD_PICKAXE(3),
|
|
|
|
BUILD_FURNACE(4),
|
|
|
|
ACQUIRE_IRON(5),
|
|
|
|
BUILD_HOE(6),
|
|
|
|
MAKE_BREAD(7),
|
|
|
|
BAKE_CAKE(8),
|
|
|
|
BUILD_BETTER_PICKAXE(9),
|
|
|
|
COOK_FISH(10),
|
|
|
|
ON_A_RAIL(11),
|
|
|
|
BUILD_SWORD(12),
|
|
|
|
KILL_ENEMY(13),
|
|
|
|
KILL_COW(14),
|
2012-02-26 12:25:27 -05:00
|
|
|
FLY_PIG(15),
|
|
|
|
SNIPE_SKELETON(16),
|
|
|
|
GET_DIAMONDS(17),
|
|
|
|
NETHER_PORTAL(18),
|
|
|
|
GHAST_RETURN(19),
|
|
|
|
GET_BLAZE_ROD(20),
|
|
|
|
BREW_POTION(21),
|
|
|
|
END_PORTAL(22),
|
|
|
|
THE_END(23),
|
|
|
|
ENCHANTMENTS(24),
|
|
|
|
OVERKILL(25),
|
|
|
|
BOOKCASE(26);
|
2011-04-21 20:56:19 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The offset used to distinguish Achievements and Statistics
|
|
|
|
*/
|
2012-01-29 11:10:40 +01:00
|
|
|
public final static int STATISTIC_OFFSET = 0x500000;
|
|
|
|
private final static Map<Integer, Achievement> BY_ID = Maps.newHashMap();
|
2011-04-21 20:56:19 +01:00
|
|
|
private final int id;
|
2011-05-14 23:22:54 +02:00
|
|
|
|
2011-04-21 20:56:19 +01:00
|
|
|
private Achievement(int id) {
|
2011-05-14 23:22:54 +02:00
|
|
|
this.id = STATISTIC_OFFSET + id;
|
2011-04-21 20:56:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the ID for this achievement.
|
2013-04-02 00:11:22 -04:00
|
|
|
* <p>
|
2011-04-21 20:56:19 +01:00
|
|
|
* Note that this is offset using {@link #STATISTIC_OFFSET}
|
|
|
|
*
|
|
|
|
* @return ID of this achievement
|
2013-08-19 13:32:18 -05:00
|
|
|
* @deprecated Magic value
|
2011-04-21 20:56:19 +01:00
|
|
|
*/
|
2013-08-19 13:32:18 -05:00
|
|
|
@Deprecated
|
2011-04-21 20:56:19 +01:00
|
|
|
public int getId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2012-01-29 11:10:40 +01:00
|
|
|
/**
|
|
|
|
* Gets the achievement associated with the given ID.
|
2013-04-02 00:11:22 -04:00
|
|
|
* <p>
|
2012-01-29 11:10:40 +01:00
|
|
|
* Note that the ID must already be offset using {@link #STATISTIC_OFFSET}
|
|
|
|
*
|
|
|
|
* @param id ID of the achievement to return
|
|
|
|
* @return Achievement with the given ID
|
2013-08-19 13:32:18 -05:00
|
|
|
* @deprecated Magic value
|
2012-01-29 11:10:40 +01:00
|
|
|
*/
|
2013-08-19 13:32:18 -05:00
|
|
|
@Deprecated
|
2012-01-29 11:10:40 +01:00
|
|
|
public static Achievement getById(int id) {
|
|
|
|
return BY_ID.get(id);
|
2011-04-21 20:56:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static {
|
2012-01-29 11:10:40 +01:00
|
|
|
for (Achievement achievement : values()) {
|
|
|
|
BY_ID.put(achievement.id, achievement);
|
2011-04-21 20:56:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|