Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 75 lines 2.0 kB view raw
1package org.bukkit; 2 3import java.util.HashMap; 4import java.util.Map; 5 6/** 7 * Represents a countable statistic, which is collected by the client 8 */ 9public enum Statistic { 10 DAMAGE_DEALT(2020), DAMAGE_TAKEN(2021), DEATHS(2022), MOB_KILLS(2023), PLAYER_KILLS(2024), FISH_CAUGHT(2025), MINE_BLOCK(16777216, true), USE_ITEM(6908288, false), BREAK_ITEM(16973824, true); 11 12 private final static Map<Integer, Statistic> statistics = new HashMap<Integer, Statistic>(); 13 private final int id; 14 private final boolean isSubstat; 15 private final boolean isBlock; 16 17 private Statistic(int id) { 18 this(id, false, false); 19 } 20 21 private Statistic(int id, boolean isBlock) { 22 this(id, true, isBlock); 23 } 24 25 private Statistic(int id, boolean isSubstat, boolean isBlock) { 26 this.id = id; 27 this.isSubstat = isSubstat; 28 this.isBlock = isBlock; 29 } 30 31 /** 32 * Gets the ID for this statistic. 33 * 34 * @return ID of this statistic 35 */ 36 public int getId() { 37 return id; 38 } 39 40 /** 41 * Checks if this is a substatistic. 42 * <p> 43 * A substatistic exists in mass for each block or item, depending on {@link #isBlock()} 44 * 45 * @return true if this is a substatistic 46 */ 47 public boolean isSubstatistic() { 48 return isSubstat; 49 } 50 51 /** 52 * Checks if this is a substatistic dealing with blocks (As opposed to items) 53 * 54 * @return true if this deals with blocks, false if with items 55 */ 56 public boolean isBlock() { 57 return isSubstat && isBlock; 58 } 59 60 /** 61 * Gets the statistic associated with the given ID. 62 * 63 * @param id ID of the statistic to return 64 * @return statistic with the given ID 65 */ 66 public static Statistic getStatistic(int id) { 67 return statistics.get(id); 68 } 69 70 static { 71 for (Statistic stat : values()) { 72 statistics.put(stat.getId(), stat); 73 } 74 } 75}