Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package org.bukkit;
2
3import java.util.HashMap;
4import java.util.Map;
5
6/**
7 * Represents an achievement, which may be given to players
8 */
9public enum Achievement {
10 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), FLY_PIG(15);
11
12 /**
13 * The offset used to distinguish Achievements and Statistics
14 */
15 public final static int STATISTIC_OFFSET = 5242880;
16 private final static Map<Integer, Achievement> achievements = new HashMap<Integer, Achievement>();
17 private final int id;
18
19 private Achievement(int id) {
20 this.id = STATISTIC_OFFSET + id;
21 }
22
23 /**
24 * Gets the ID for this achievement.
25 * <p>
26 * Note that this is offset using {@link #STATISTIC_OFFSET}
27 *
28 * @return ID of this achievement
29 */
30 public int getId() {
31 return id;
32 }
33
34 /**
35 * Gets the achievement associated with the given ID.
36 * <p>
37 * Note that the ID must already be offset using {@link #STATISTIC_OFFSET}
38 *
39 * @param id ID of the achievement to return
40 * @return Achievement with the given ID
41 */
42 public static Achievement getAchievement(int id) {
43 return achievements.get(id);
44 }
45
46 static {
47 for (Achievement ach : values()) {
48 achievements.put(ach.getId(), ach);
49 }
50 }
51}