Skip to content

Commit

Permalink
sidebar command general cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 16, 2015
1 parent 7a9b60a commit 16faf62
Showing 1 changed file with 21 additions and 9 deletions.
Expand Up @@ -100,8 +100,8 @@ else if (!scriptEntry.hasObject("per_player")
scriptEntry.addObject("action", new Element(action.name()));

BukkitScriptEntryData entryData = (BukkitScriptEntryData) scriptEntry.entryData;
scriptEntry.defaultObject("per_player", new Element(false)).defaultObject("players",
new Element(entryData.hasPlayer() ? entryData.getPlayer().identify() : "li@"));
scriptEntry.defaultObject("per_player", new Element(false))
.defaultObject("players", new Element(entryData.hasPlayer() ? entryData.getPlayer().identify() : "li@"));
}

@Override
Expand Down Expand Up @@ -158,7 +158,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
players.debug();
}
else {
BukkitTagContext context = new BukkitTagContext(scriptEntry, false);
BukkitTagContext context = (BukkitTagContext) DenizenAPI.getCurrentInstance().getTagContextFor(scriptEntry, false);
if (elTitle != null) {
title = new Element(TagManager.tag(elTitle.asString(), context));
}
Expand Down Expand Up @@ -189,14 +189,18 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

case ADD:
for (dPlayer player : players.filter(dPlayer.class)) {
if (player == null || !player.isValid()) {
dB.echoError("Invalid player!");
continue;
}
Sidebar sidebar = createSidebar(player);
if (sidebar == null) {
continue;
}
List<String> current = sidebar.getLines();
if (per_player) {
TagContext context = new BukkitTagContext(player, null, false, scriptEntry,
scriptEntry.shouldDebug(), scriptEntry.getScript());
TagContext context = new BukkitTagContext(player, ((BukkitScriptEntryData) scriptEntry.entryData).getNPC(),
false, scriptEntry, scriptEntry.shouldDebug(), scriptEntry.getScript());
value = dList.valueOf(TagManager.tag(perValue, context));
if (perLines != null) {
lines = dList.valueOf(TagManager.tag(perLines, context));
Expand Down Expand Up @@ -225,14 +229,18 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

case REMOVE:
for (dPlayer player : players.filter(dPlayer.class)) {
if (player == null || !player.isValid()) {
dB.echoError("Invalid player!");
continue;
}
Sidebar sidebar = createSidebar(player);
if (sidebar == null) {
continue;
}
List<String> current = sidebar.getLines();
if (per_player) {
TagContext context = new BukkitTagContext(player, null, false, scriptEntry,
scriptEntry.shouldDebug(), scriptEntry.getScript());
TagContext context = new BukkitTagContext(player, ((BukkitScriptEntryData) scriptEntry.entryData).getNPC(),
false, scriptEntry, scriptEntry.shouldDebug(), scriptEntry.getScript());
if (perValue != null) {
value = dList.valueOf(TagManager.tag(perValue, context));
}
Expand Down Expand Up @@ -290,15 +298,19 @@ else if (value != null) {

case SET:
for (dPlayer player : players.filter(dPlayer.class)) {
if (player == null || !player.isValid()) {
dB.echoError("Invalid player!");
continue;
}
Sidebar sidebar = createSidebar(player);
if (sidebar == null) {
continue;
}
List<String> current = sidebar.getLines();
boolean currEdited = false;
if (per_player) {
TagContext context = new BukkitTagContext(player, null, false, scriptEntry,
scriptEntry.shouldDebug(), scriptEntry.getScript());
TagContext context = new BukkitTagContext(player, ((BukkitScriptEntryData) scriptEntry.entryData).getNPC(),
false, scriptEntry, scriptEntry.shouldDebug(), scriptEntry.getScript());
if (perValue != null) {
value = dList.valueOf(TagManager.tag(perValue, context));
}
Expand Down

0 comments on commit 16faf62

Please sign in to comment.