Skip to content

Commit

Permalink
Fix premature prefix stripping.
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed Aug 17, 2013
1 parent 62c908c commit d09ef84
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
10 changes: 6 additions & 4 deletions src/main/java/net/aufdemrand/denizen/flags/FlagManager.java
Expand Up @@ -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;
Expand All @@ -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:
Expand Down
Expand Up @@ -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()))
Expand All @@ -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.");
Expand All @@ -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.
Expand Down
Expand Up @@ -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")
Expand Down

0 comments on commit d09ef84

Please sign in to comment.