Skip to content

Commit

Permalink
Improved scoreboard handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Bilbrey committed Apr 10, 2013
1 parent 8ea48d7 commit 98f76b8
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 87 deletions.
47 changes: 7 additions & 40 deletions src/main/java/com/laytonsmith/abstraction/enums/MCCriteria.java
@@ -1,57 +1,24 @@
package com.laytonsmith.abstraction.enums;

import java.util.ArrayList;
import java.util.List;

/**
* Criteria names which trigger an objective to be modified by actions in-game
*
* @author jb_aero
*/
public enum MCCriteria {
DEATH_COUNT("deathCount"),
DEATHCOUNT("deathCount"),
HEALTH("health"),
PLAYER_KILL_COUNT("playerKillCount"),
TOTAL_KILL_COUNT("totalKillCount"),
/**
* This is the exception, all user defined criteria use this.
*/
PLAYERKILLCOUNT("playerKillCount"),
TOTALKILLCOUNT("totalKillCount"),
DUMMY("dummy");

private String criteria;

MCCriteria(String crit) {
this.criteria = crit;
}

public String getValue() {
return this.criteria;
}

/**
* @return List of the criteria automatically incremented by the server
*/
public static List<String> auto() {
List<String> ret = new ArrayList<String>();
for (MCCriteria c : values()) {
if (c != MCCriteria.DUMMY) {
ret.add(c.name());
ret.add(c.getValue());
}
}
return ret;
private MCCriteria(String crit) {
criteria = crit;
}

public static MCCriteria convert(String value) {
MCCriteria ret = MCCriteria.DUMMY;
for (MCCriteria c : values()) {
if (c.getValue().equals(value)) {
ret = c;
}
if (c.name().equals(value.toUpperCase())) {
ret = c;
}
}
return ret;
public String getCriteria() {
return criteria;
}
}
Expand Up @@ -18,11 +18,11 @@
)
public class BukkitMCDisplaySlot extends EnumConvertor<MCDisplaySlot, DisplaySlot>{

private static BukkitMCDisplaySlot instance;
private static com.laytonsmith.abstraction.enums.bukkit.BukkitMCDisplaySlot instance;

public static BukkitMCDisplaySlot getConverter() {
public static com.laytonsmith.abstraction.enums.bukkit.BukkitMCDisplaySlot getConverter() {
if (instance == null) {
instance = new BukkitMCDisplaySlot();
instance = new com.laytonsmith.abstraction.enums.bukkit.BukkitMCDisplaySlot();
}
return instance;
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/laytonsmith/core/functions/Exceptions.java
Expand Up @@ -194,6 +194,14 @@ public enum ExceptionType implements Documentation {
* Thrown if a field was read only, but a write operation was attempted.
*/
ReadOnlyException("Thrown if a field was read only, but a write operation was attempted.", CHVersion.V3_3_1),
/**
* Thrown if a scoreboard error occurs, such as attempting to create a
* team or objective with a name that is already in use,
* or trying to access one that doesn't exist.
*/
ScoreboardException("Thrown if a scoreboard error occurs, such as attempting to create a"
+ " team or objective with a name that is already in use,"
+ " or trying to access one that doesn't exist.", CHVersion.V3_3_1),
;

private String docs;
Expand Down

0 comments on commit 98f76b8

Please sign in to comment.