diff --git a/src/main/java/net/aufdemrand/denizen/flags/FlagManager.java b/src/main/java/net/aufdemrand/denizen/flags/FlagManager.java index 70aa7a7f0f..06edf66ff4 100644 --- a/src/main/java/net/aufdemrand/denizen/flags/FlagManager.java +++ b/src/main/java/net/aufdemrand/denizen/flags/FlagManager.java @@ -522,6 +522,8 @@ public boolean isEmpty() { */ public void doAction(Action action, Element value, Integer index) { + String val = (value != null ? value.asString() : null); + if (index == null) index = -1; if (action == null) return; @@ -538,19 +540,19 @@ public void doAction(Action action, Element value, Integer index) { break; case SET_VALUE: - set(value, index); + set(val, index); break; case INSERT: - add(value); + add(val); break; case REMOVE: - remove(value, index); + remove(val, index); break; case SPLIT: - split(value); + split(val); break; case DELETE: diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/CommandExecuter.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/CommandExecuter.java index f6c75ade95..8ce067c0e6 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/CommandExecuter.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/CommandExecuter.java @@ -92,22 +92,19 @@ public boolean execute(ScriptEntry scriptEntry) { for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) { + + dB.log("arg " + arg.raw_value); + if (arg.getValue().equals("{")) nested_depth++; if (arg.getValue().equals("}")) nested_depth--; // If nested, continue. if (nested_depth > 0) { - newArgs.add(arg.getValue()); + newArgs.add(arg.raw_value); continue; } - // If using IF, check if we've reached the command + args - // so that we don't fill player: or npc: prematurely - if (command.getName().equalsIgnoreCase("if") - && DenizenAPI.getCurrentInstance().getCommandRegistry().get(arg.getValue()) != null) - if_ignore = true; - - m = definition_pattern.matcher(arg.getValue()); + m = definition_pattern.matcher(arg.raw_value); sb = new StringBuffer(); while (m.find()) { if (scriptEntry.getResidingQueue().hasContext(m.group(1).toLowerCase())) @@ -120,6 +117,12 @@ public boolean execute(ScriptEntry scriptEntry) { m.appendTail(sb); arg = aH.Argument.valueOf(sb.toString()); + // If using IF, check if we've reached the command + args + // so that we don't fill player: or npc: prematurely + if (command.getName().equalsIgnoreCase("if") + && DenizenAPI.getCurrentInstance().getCommandRegistry().get(arg.getValue()) != null) + if_ignore = true; + // Fill player/off-line player if (arg.matchesPrefix("player") && !if_ignore) { dB.echoDebug("...replacing the linked player."); @@ -144,7 +147,7 @@ else if (arg.matchesPrefix("npc, npcid") && !if_ignore) { scriptEntry.setNPC(npc); } - else newArgs.add(arg.getValue()); + else newArgs.add(arg.raw_value); } // Add the arguments back to the scriptEntry. diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/core/FlagCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/core/FlagCommand.java index 26c4631bd0..b6485ac068 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/core/FlagCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/core/FlagCommand.java @@ -28,6 +28,8 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) { + dB.log(arg.raw_value); + // A duration on a flag will set it to expire after the // specified amount of time if (!scriptEntry.hasObject("duration")