mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-04 22:22:18 -07:00
Added Achievement and Statistics
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
84
paper-api/src/main/java/org/bukkit/Statistic.java
Normal file
84
paper-api/src/main/java/org/bukkit/Statistic.java
Normal file
@@ -0,0 +1,84 @@
|
||||
|
||||
package org.bukkit;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents a countable statistic, which is collected by the client
|
||||
*/
|
||||
public enum Statistic {
|
||||
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);
|
||||
|
||||
private final static Map<Integer, Statistic> statistics = new HashMap<Integer, Statistic>();
|
||||
private final int id;
|
||||
private final boolean isSubstat;
|
||||
private final boolean isBlock;
|
||||
|
||||
private Statistic(int id) {
|
||||
this(id, false, false);
|
||||
}
|
||||
|
||||
private Statistic(int id, boolean isBlock) {
|
||||
this(id, true, isBlock);
|
||||
}
|
||||
|
||||
private Statistic(int id, boolean isSubstat, boolean isBlock) {
|
||||
this.id = id;
|
||||
this.isSubstat = isSubstat;
|
||||
this.isBlock = isBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ID for this statistic.
|
||||
*
|
||||
* @return ID of this statistic
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this is a substatistic.
|
||||
*
|
||||
* A substatistic exists in mass for each block or item, depending on {@link #isBlock()}
|
||||
*
|
||||
* @return true if this is a substatistic
|
||||
*/
|
||||
public boolean isSubstatistic() {
|
||||
return isSubstat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this is a substatistic dealing with blocks (As opposed to items)
|
||||
*
|
||||
* @return true if this deals with blocks, false if with items
|
||||
*/
|
||||
public boolean isBlock() {
|
||||
return isSubstat && isBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the statistic associated with the given ID.
|
||||
*
|
||||
* @param id ID of the statistic to return
|
||||
* @return statistic with the given ID
|
||||
*/
|
||||
public static Statistic getStatistic(int id) {
|
||||
return statistics.get(id);
|
||||
}
|
||||
|
||||
static {
|
||||
for (Statistic stat : values()) {
|
||||
statistics.put(stat.getId(), stat);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user