// is being process to make sure the objects don't accidently get set
// as the name of the flag..
else if (!scriptEntry.hasObject("flag_target")
&& arg.startsWith("n@") && !arg.hasPrefix()) {
if (dNPC.valueOf(arg.getValue()) == null)
throw new InvalidArgumentsException("Invalid NPC target.");
specified_target = true;
scriptEntry.addObject("flag_target", arg.asType(dNPC.class));
} else if (!scriptEntry.hasObject("flag_target")
&& arg.startsWith("p@") && !arg.hasPrefix()) {
if (dPlayer.valueOf(arg.getValue()) == null)
throw new InvalidArgumentsException("Invalid Player target.");
specified_target = true;
scriptEntry.addObject("flag_target", arg.asType(dPlayer.class));
}
// Check if setting a boolean
else if (arg.raw_value.split(":", 3).length == 1) {
scriptEntry.addObject("action", FlagManager.Action.SET_BOOLEAN);
scriptEntry.addObject("value", Element.TRUE);
scriptEntry.addObject("flag_name", arg.asElement());
}
// Check for flag_name:value/action
else if (arg.raw_value.split(":", 3).length == 2) {
String[] flagArgs = arg.raw_value.split(":", 2);
scriptEntry.addObject("flag_name", new Element(flagArgs[0].toUpperCase()));
if (flagArgs[1].equals("++") || flagArgs[1].equals("+")) {
scriptEntry.addObject("action", FlagManager.Action.INCREASE);
scriptEntry.addObject("value", new Element(1));
}
else if (flagArgs[1].equals("--") || flagArgs[1].equals("-")) {
scriptEntry.addObject("action", FlagManager.Action.DECREASE);
scriptEntry.addObject("value", new Element(1));
}
else if (flagArgs[1].equals("!")) {
scriptEntry.addObject("action", FlagManager.Action.DELETE);
scriptEntry.addObject("value", Element.FALSE);
}
else if (flagArgs[1].equals("<-")) {
scriptEntry.addObject("action", FlagManager.Action.REMOVE);
scriptEntry.addObject("value", Element.FALSE);
}
else {
// No ACTION, we're just setting a value...
scriptEntry.addObject("action", FlagManager.Action.SET_VALUE);
scriptEntry.addObject("value", new Element(flagArgs[1]));
}
}
// Check for flag_name:action:value
else if (arg.raw_value.split(":", 3).length == 3) {
String[] flagArgs = arg.raw_value.split(":", 3);
scriptEntry.addObject("flag_name", new Element(flagArgs[0].toUpperCase()));
if (flagArgs[1].equals("->"))
scriptEntry.addObject("action", FlagManager.Action.INSERT);
else if (flagArgs[1].equals("<-"))
scriptEntry.addObject("action", FlagManager.Action.REMOVE);
else if (flagArgs[1].equals("||") || flagArgs[1].equals("|"))
scriptEntry.addObject("action", FlagManager.Action.SPLIT);
else if (flagArgs[1].equals("++") || flagArgs[1].equals("+"))
scriptEntry.addObject("action", FlagManager.Action.INCREASE);
else if (flagArgs[1].equals("--") || flagArgs[1].equals("-"))
scriptEntry.addObject("action", FlagManager.Action.DECREASE);
else if (flagArgs[1].equals("**") || flagArgs[1].equals("*"))
scriptEntry.addObject("action", FlagManager.Action.MULTIPLY);
else if (flagArgs[1].equals("//") || flagArgs[1].equals("/"))
scriptEntry.addObject("action", FlagManager.Action.DIVIDE);
else {
scriptEntry.addObject("action", FlagManager.Action.SET_VALUE);
scriptEntry.addObject("value", new Element(arg.raw_value.split(":", 2)[1]));
continue;
}
scriptEntry.addObject("value", new Element(flagArgs[2]));
}
else arg.reportUnhandled();
}
// Set defaults
if (!specified_target)
scriptEntry.defaultObject("flag_target", ((BukkitScriptEntryData)scriptEntry.entryData).getPlayer());
// Check required arguments
if (!scriptEntry.hasObject("action"))
throw new InvalidArgumentsException("Must specify a flag action or value.");
if (!scriptEntry.hasObject("flag_target"))
throw new InvalidArgumentsException("Must specify a flag target!");
}