use of mc.dragons.core.gameobject.npc.NPCConditionalActions in project DragonsOnline by UniverseCraft.
the class NPCCommand method manageBehavior.
private void manageBehavior(CommandSender sender, String[] args) {
NPCClass npcClass = lookupNPCClass(sender, args[0]);
if (npcClass == null)
return;
if (args.length == 2) {
displayBehavior(sender, args);
return;
}
NPCTrigger trigger = NPCTrigger.valueOf(args[2]);
NPCConditionalActions behaviorsLocal = npcClass.getConditionalActions(trigger);
NPCConditionalActions parsedBehaviors = npcClass.getConditionalActions(trigger);
Document conditionals = npcClass.getStorageAccess().getDocument().get("conditionals", Document.class);
List<Document> behaviors = conditionals.getList(trigger.toString(), Document.class);
Document base = Document.parse(npcClass.getData().toJson());
boolean changed = false;
if (args[3].equalsIgnoreCase("add")) {
changed = addBehavior(sender, behaviors, conditionals, trigger, npcClass, parsedBehaviors);
} else if (args[3].equalsIgnoreCase("remove")) {
changed = removeBehavior(sender, args, behaviors, conditionals, trigger, npcClass, parsedBehaviors);
} else {
changed = manageBehavior(sender, args, behaviors, conditionals, trigger, npcClass, behaviorsLocal);
}
if (changed) {
AUDIT_LOG.saveEntry(npcClass, user(sender), base, "Updated behaviors");
}
}
Aggregations