Skip to content

Commit

Permalink
Simplify IF usage when dealing with ! and !=.
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed Apr 2, 2013
1 parent 9418c94 commit 03e65cc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 42 deletions.
Expand Up @@ -70,7 +70,12 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
// Set logic (Optional, default is REGULAR)
if (arg.startsWith("!")) {
comparables.get(index).logic = Logic.NEGATIVE;
arg = arg.substring(1);
if (arg.equals("!"))
continue;
if (arg.equals("!="))
arg = "==";
else
arg = arg.substring(1);
}
// Replace symbol-operators/bridges with ENUM value for matching
arg = arg.replace("==", "EQUALS").replace(">=", "ORMORE").replace("<=", "ORLESS")
Expand Down
Expand Up @@ -87,7 +87,6 @@ public void flagTag(ReplaceableTagEvent event) {
if (name == null) return;

if (denizen.flagManager().getPlayerFlag(name, flagName).get(index).isEmpty()) {

if (replaceType.toString() == "ISEXPIRED")
event.setReplaced("true");
else
Expand Down

This file was deleted.

Expand Up @@ -12,10 +12,9 @@
import java.util.List;

public class Scoreboard {
Scoreboard(String name, int priority, ScoreboardAPI plugin) {
Scoreboard(String name, int priority) {
this.name = name;
this.priority = priority;
this.plugin = plugin;
}

public enum Type {
Expand Down Expand Up @@ -102,7 +101,7 @@ public void showToPlayer(Player p, boolean show) {
if (show) {
if (!players.contains(p)) {
players.add(p);
plugin.updateForPlayer(p);
ScoreboardAPI.getInstance().updateForPlayer(p);
}
} else {
if (players.remove(p)) {
Expand All @@ -111,7 +110,7 @@ public void showToPlayer(Player p, boolean show) {
pack.b = "";
pack.c = 1;
((CraftPlayer) p).getHandle().playerConnection.sendPacket(pack);
plugin.updateForPlayer(p);
ScoreboardAPI.getInstance().updateForPlayer(p);
}
}
}
Expand Down Expand Up @@ -181,12 +180,12 @@ public void checkIfNeedsToBeEnabledForPlayer(Player p) {

private boolean isUnique(Player p) {
int myPos = 0;
for (int i = 0; i < plugin.getScoreboards().size(); i++) {
if (plugin.getScoreboards().get(i) == this) {
for (int i = 0; i < ScoreboardAPI.getInstance().getScoreboards().size(); i++) {
if (ScoreboardAPI.getInstance().getScoreboards().get(i) == this) {
myPos = i;
break;
}
Scoreboard s = plugin.getScoreboards().get(i);
Scoreboard s = ScoreboardAPI.getInstance().getScoreboards().get(i);
if (s != this && s.hasPlayerAdded(p) && s.getType() == type && (s.getPriority() > priority || (i > myPos && s.getPriority() == priority))) {
return false;
}
Expand All @@ -206,5 +205,4 @@ private boolean isUnique(Player p) {

private int priority = 10;

private ScoreboardAPI plugin;
}
Expand Up @@ -11,17 +11,11 @@

public class ScoreboardAPI {

//Global Definitions:
public static String PREFIX_COLOR = ChatColor.AQUA + "";
public static String CONFIG_NAME = "config.yml";
public static boolean ENABLE_METRICS = false;
//End

public static ScoreboardAPI api_instance;
public static ScoreboardAPI api_instance = null;

public static List<Scoreboard> scoreboards = new LinkedList<Scoreboard>();

public static List<Scoreboard> getScoreboards() {
public List<Scoreboard> getScoreboards() {
return scoreboards;
}

Expand All @@ -37,7 +31,7 @@ public Scoreboard createScoreboard(String name, int priority) {
return null;
}
}
Scoreboard s = new Scoreboard(name, priority, this);
Scoreboard s = new Scoreboard(name, priority);
scoreboards.add(s);
return s;
}
Expand Down

0 comments on commit 03e65cc

Please sign in to comment.