use of mc.dragons.core.gameobject.npc.NPCClass in project DragonsOnline by UniverseCraft.
the class NPCCommand method manageAttributes.
private void manageAttributes(CommandSender sender, String[] args) {
NPCClass npcClass = lookupNPCClass(sender, args[0]);
if (npcClass == null)
return;
if (args.length == 2) {
sender.sendMessage(ChatColor.GREEN + "Listing custom base attributes for NPC class " + npcClass.getClassName() + ":");
for (Entry<Attribute, Double> attribute : npcClass.getCustomAttributes().entrySet()) {
sender.sendMessage(ChatColor.GRAY + "- " + attribute.getKey() + ": " + attribute.getValue());
}
return;
} else if (args.length < 4) {
sender.sendMessage(ChatColor.RED + "Insufficient arguments! /npc <ClassName> attribute <Attribute> <Value|DEL>");
sender.sendMessage(ChatColor.RED + "Valid attributes are: " + StringUtil.parseList(Attribute.values()));
return;
}
Document base = Document.parse(npcClass.getData().toJson());
Attribute att = StringUtil.parseEnum(sender, Attribute.class, args[2]);
if (att == null)
return;
if (args[3].equalsIgnoreCase("DEL")) {
npcClass.removeCustomAttribute(att);
} else {
Double value = parseDouble(sender, args[3]);
if (value == null)
return;
npcClass.setCustomAttribute(att, value);
}
AUDIT_LOG.saveEntry(npcClass, user(sender), base, "Updated attributes");
sender.sendMessage(ChatColor.GREEN + "Updated attributes successfully.");
}
use of mc.dragons.core.gameobject.npc.NPCClass in project DragonsOnline by UniverseCraft.
the class NPCCommand method displayClass.
private void displayClass(CommandSender sender, String[] args) {
NPCClass npcClass = lookupNPCClass(sender, args[0]);
if (npcClass == null)
return;
sender.sendMessage(ChatColor.GREEN + "=== NPC Class: " + npcClass.getClassName() + " ===");
sender.sendMessage(ChatColor.GRAY + "Database identifier: " + ChatColor.GREEN + npcClass.getIdentifier().toString());
sender.sendMessage(ChatColor.GRAY + "Display name: " + ChatColor.GREEN + npcClass.getName());
sender.sendMessage(ChatColor.GRAY + "Entity type: " + ChatColor.GREEN + npcClass.getEntityType().toString());
sender.sendMessage(ChatColor.GRAY + "Max health: " + ChatColor.GREEN + npcClass.getMaxHealth());
sender.sendMessage(ChatColor.GRAY + "Level: " + ChatColor.GREEN + npcClass.getLevel());
sender.sendMessage(ChatColor.GRAY + "NPC type: " + ChatColor.GREEN + npcClass.getNPCType().toString());
sender.sendMessage(ChatColor.GRAY + "AI: " + ChatColor.GREEN + npcClass.hasAI());
sender.sendMessage(ChatColor.GRAY + "Immortal: " + ChatColor.GREEN + npcClass.isImmortal());
Material heldItemType = npcClass.getHeldItemType();
String heldItemTypeName = "Nothing";
if (heldItemType != null) {
heldItemTypeName = heldItemType.toString();
}
sender.sendMessage(ChatColor.GRAY + "Holding: " + ChatColor.GREEN + heldItemTypeName);
if (!npcClass.verifyAddons()) {
sender.sendMessage(ChatColor.RED + "NPC class add-on verification failed!");
}
sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + "[Spawn] ", "/npc spawn " + npcClass.getClassName(), true, "Click to Spawn"), ObjectMetadataCommand.getClickableMetadataLink(GameObjectType.NPC_CLASS, npcClass.getUUID()));
sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + "/npc " + npcClass.getClassName() + " loot" + ChatColor.YELLOW + " to view loot table", "/npc " + npcClass.getClassName() + " loot", "Click to view loot table"));
sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + "/npc " + npcClass.getClassName() + " behavior" + ChatColor.YELLOW + " to view behaviors", "/npc " + npcClass.getClassName() + " behavior", "Click to view behaviors"));
sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + "/npc " + npcClass.getClassName() + " addon" + ChatColor.YELLOW + " to view addons", "/npc " + npcClass.getClassName() + " addon", "Click to view addons"));
sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + "/npc " + npcClass.getClassName() + " attribute" + ChatColor.YELLOW + " to view attributes", "/npc " + npcClass.getClassName() + " attribute", "Click to view attributes"));
}
use of mc.dragons.core.gameobject.npc.NPCClass in project DragonsOnline by UniverseCraft.
the class NPCCommand method locate.
private void locate(CommandSender sender, String[] args) {
NPCClass npcClass = lookupNPCClass(sender, args[0]);
if (npcClass == null)
return;
if (!npcClass.getNPCType().isPersistent()) {
sender.sendMessage(ChatColor.RED + "Can only locate persistent NPCs!");
return;
}
List<NPC> result = gameObjectRegistry.getRegisteredObjects(GameObjectType.NPC).stream().map(o -> (NPC) o).filter(npc -> npc.getNPCClass().equals(npcClass)).collect(Collectors.toList());
sender.sendMessage(ChatColor.GREEN + "" + result.size() + " results for class " + npcClass.getClassName() + ":");
for (NPC npc : result) {
sender.sendMessage(ChatColor.GRAY + StringUtil.locToString(npc.getEntity().getLocation()) + ", " + npc.getEntity().getWorld().getName());
}
}
use of mc.dragons.core.gameobject.npc.NPCClass in project DragonsOnline by UniverseCraft.
the class NPCCommand method setAI.
private void setAI(CommandSender sender, String[] args) {
NPCClass npcClass = lookupNPCClass(sender, args[0]);
Boolean ai = parseBoolean(sender, args[2]);
if (npcClass == null || ai == null)
return;
Document base = Document.parse(npcClass.getData().toJson());
npcClass.setAI(ai);
sender.sendMessage(ChatColor.GREEN + "Updated entity AI successfully.");
AUDIT_LOG.saveEntry(npcClass, user(sender), base, "Set entity AI to " + ai);
propagateRevisions(npcClass);
}
use of mc.dragons.core.gameobject.npc.NPCClass 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