use of mc.dragons.core.gameobject.npc.NPCClass in project DragonsOnline by UniverseCraft.
the class NPCCommand method createClass.
private void createClass(CommandSender sender, String[] args) {
if (args.length < 6) {
sender.sendMessage(ChatColor.RED + "Insufficient arguments! /npc create <ClassName> <EntityType> <MaxHealth> <Level> <NPCType>");
return;
}
String npcClassName = args[1];
EntityType type = StringUtil.parseEntityType(sender, args[2]);
Double maxHealth = parseDouble(sender, args[3]);
Integer level = parseInt(sender, args[4]);
NPCType npcType = StringUtil.parseEnum(sender, NPCType.class, args[5]);
if (type == null || maxHealth == null || level == null || npcType == null)
return;
NPCClass npcClass = npcClassLoader.registerNew(npcClassName, "Unnamed Entity", type, maxHealth, level, npcType);
if (npcClass == null) {
sender.sendMessage(ChatColor.RED + "An error occurred! Does an NPC class by this name already exist?");
return;
}
// MetadataConstants.addBlankMetadata(npcClass, user(sender));
AUDIT_LOG.saveEntry(npcClass, user(sender), "Created");
sender.sendMessage(ChatColor.GREEN + "Successfully created NPC class " + npcClassName);
}
use of mc.dragons.core.gameobject.npc.NPCClass in project DragonsOnline by UniverseCraft.
the class NPCCommand method setType.
private void setType(CommandSender sender, String[] args) {
NPCClass npcClass = lookupNPCClass(sender, args[0]);
EntityType type = StringUtil.parseEntityType(sender, args[2]);
if (npcClass == null || type == null)
return;
Document base = Document.parse(npcClass.getData().toJson());
npcClass.setEntityType(type);
sender.sendMessage(ChatColor.GREEN + "Updated entity type successfully.");
AUDIT_LOG.saveEntry(npcClass, user(sender), base, "Set entity type to " + type);
propagateRevisions(npcClass);
}
use of mc.dragons.core.gameobject.npc.NPCClass in project DragonsOnline by UniverseCraft.
the class NPCCommand method setNPCType.
private void setNPCType(CommandSender sender, String[] args) {
NPCClass npcClass = lookupNPCClass(sender, args[0]);
NPCType npcType = StringUtil.parseEnum(sender, NPCType.class, args[2]);
Document base = Document.parse(npcClass.getData().toJson());
npcClass.setNPCType(npcType);
sender.sendMessage(ChatColor.GREEN + "Updated NPC type successfully.");
if (!npcClass.getNPCType().hasAIByDefault() && npcClass.hasAI()) {
npcClass.setAI(false);
sender.sendMessage(ChatColor.GREEN + "Automatically toggled off AI for this class based on the NPC type.");
}
AUDIT_LOG.saveEntry(npcClass, user(sender), base, "Set NPC type to " + npcType);
propagateRevisions(npcClass);
}
use of mc.dragons.core.gameobject.npc.NPCClass in project DragonsOnline by UniverseCraft.
the class NPCCommand method listClasses.
private void listClasses(CommandSender sender, String[] args) {
String startingWith = "";
if (args.length > 1) {
startingWith = args[1];
}
sender.sendMessage(ChatColor.GREEN + "Listing all NPC classes" + (startingWith.length() > 0 ? (" starting with \"" + startingWith + "\"") : "") + ":");
for (GameObject gameObject : dragons.getGameObjectRegistry().getRegisteredObjects(GameObjectType.NPC_CLASS)) {
NPCClass npcClass = (NPCClass) gameObject;
if (!npcClass.getClassName().startsWith(startingWith))
continue;
sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + "- " + npcClass.getClassName() + " [Lv " + npcClass.getLevel() + "]", "/npc spawn " + npcClass.getClassName(), true, "Click to Spawn"));
}
}
use of mc.dragons.core.gameobject.npc.NPCClass in project DragonsOnline by UniverseCraft.
the class NPCCommand method displayBehavior.
private void displayBehavior(CommandSender sender, String[] args) {
NPCClass npcClass = lookupNPCClass(sender, args[0]);
if (npcClass == null)
return;
sender.sendMessage(ChatColor.GREEN + "NPC Behaviors:");
for (NPCTrigger trigger : NPCTrigger.values()) {
sender.sendMessage(ChatColor.GRAY + "- Trigger: " + trigger);
int i = 0;
for (Entry<List<NPCCondition>, List<NPCAction>> entry : npcClass.getConditionalActions(trigger).getConditionals().entrySet()) {
sender.sendMessage(ChatColor.GRAY + " - Behavior " + ChatColor.DARK_GREEN + "#" + i + ChatColor.GRAY + ":");
sender.sendMessage(ChatColor.GRAY + " - Conditions:");
int j = 0;
for (NPCCondition condition : entry.getKey()) {
sender.sendMessage(ChatColor.DARK_GREEN + " #" + j + ": " + ChatColor.GRAY + displayNPCCondition(condition));
j++;
}
sender.sendMessage(ChatColor.GRAY + " - Actions:");
j = 0;
for (NPCAction action : entry.getValue()) {
sender.sendMessage(ChatColor.DARK_GREEN + " #" + j + ": " + ChatColor.GRAY + displayNPCAction(action));
j++;
}
i++;
}
}
}
Aggregations