for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) {
if (arg.matches("ASPLAYER", "AS_PLAYER", "PLAYER")
&& !scriptEntry.hasObject("type")) {
if (!((BukkitScriptEntryData)scriptEntry.entryData).hasPlayer())
throw new InvalidArgumentsException("Must have a Player link when using AS_PLAYER.");
scriptEntry.addObject("type", new Element("AS_PLAYER"));
}
else if (arg.matches("ASOPPLAYER", "ASOP", "AS_OP", "AS_OP_PLAYER", "OP")
&& !scriptEntry.hasObject("type")) {
if (!((BukkitScriptEntryData)scriptEntry.entryData).hasPlayer())
throw new InvalidArgumentsException("Must have a Player link when using AS_OP.");
scriptEntry.addObject("type", new Element("AS_OP"));
}
else if (arg.matches("ASNPC", "AS_NPC", "NPC")
&& !scriptEntry.hasObject("type")) {
if (!((BukkitScriptEntryData)scriptEntry.entryData).hasNPC())
throw new InvalidArgumentsException("Must have a NPC link when using AS_NPC.");
scriptEntry.addObject("type", new Element("AS_NPC"));
}
else if (arg.matches("ASSERVER", "AS_SERVER", "SERVER")
&& !scriptEntry.hasObject("type"))
scriptEntry.addObject("type", new Element("AS_SERVER"));
else if (!scriptEntry.hasObject("silent")
&& arg.matches("silent"))
scriptEntry.addObject("silent", new Element("true"));
else if (!scriptEntry.hasObject("command"))
scriptEntry.addObject("command", new Element(arg.raw_value));
else
arg.reportUnhandled();
}
if (!scriptEntry.hasObject("type"))
throw new InvalidArgumentsException("Missing execution type!");
if (!scriptEntry.hasObject("command"))
throw new InvalidArgumentsException("Missing command text!");
scriptEntry.defaultObject("silent", new Element("false"));
}