@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {
if (scriptEntry.getArguments().size() > 4)
throw new InvalidArgumentsException("Too many arguments! Did you forget a 'quote'?");
// Iterate through arguments
for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) {
if (!scriptEntry.hasObject("format")
&& arg.matchesPrefix("format", "f")) {
FormatScriptContainer format = null;
String formatStr = arg.getValue();
format = ScriptRegistry.getScriptContainer(formatStr);
if (format == null) dB.echoError("Could not find format script matching '" + formatStr + '\'');
scriptEntry.addObject("format", format);
}
// Add players to target list
else if (!scriptEntry.hasObject("targets")
&& arg.matchesPrefix("target", "targets", "t")) {
scriptEntry.addObject("targets", arg.asType(dList.class).filter(dPlayer.class));
}
// Use raw_value as to not accidentally strip a value before any :'s.
else if (!scriptEntry.hasObject("text"))
scriptEntry.addObject("text", new Element(TagManager.cleanOutputFully(arg.raw_value)));
else
arg.reportUnhandled();
}
// If there are no targets, check if you can add this player
// to the targets
if (!scriptEntry.hasObject("targets"))
scriptEntry.addObject("targets",
(((BukkitScriptEntryData)scriptEntry.entryData).hasPlayer() ? Arrays.asList(((BukkitScriptEntryData)scriptEntry.entryData).getPlayer()) : null));
if (!scriptEntry.hasObject("text"))
throw new InvalidArgumentsException("Missing any text!");
}