Search in sources :

Example 6 with NPCClass

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);
}
Also used : EntityType(org.bukkit.entity.EntityType) NPCClass(mc.dragons.core.gameobject.npc.NPCClass) NPCType(mc.dragons.core.gameobject.npc.NPC.NPCType)

Example 7 with NPCClass

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);
}
Also used : EntityType(org.bukkit.entity.EntityType) NPCClass(mc.dragons.core.gameobject.npc.NPCClass) Document(org.bson.Document)

Example 8 with 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);
}
Also used : NPCClass(mc.dragons.core.gameobject.npc.NPCClass) NPCType(mc.dragons.core.gameobject.npc.NPC.NPCType) Document(org.bson.Document)

Example 9 with 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"));
    }
}
Also used : NPCClass(mc.dragons.core.gameobject.npc.NPCClass) GameObject(mc.dragons.core.gameobject.GameObject)

Example 10 with NPCClass

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++;
        }
    }
}
Also used : NPCClass(mc.dragons.core.gameobject.npc.NPCClass) NPCCondition(mc.dragons.core.gameobject.npc.NPCCondition) NPCTrigger(mc.dragons.core.gameobject.npc.NPCConditionalActions.NPCTrigger) ArrayList(java.util.ArrayList) List(java.util.List) NPCAction(mc.dragons.core.gameobject.npc.NPCAction)

Aggregations

NPCClass (mc.dragons.core.gameobject.npc.NPCClass)19 Document (org.bson.Document)14 NPCType (mc.dragons.core.gameobject.npc.NPC.NPCType)3 NPCTrigger (mc.dragons.core.gameobject.npc.NPCConditionalActions.NPCTrigger)3 User (mc.dragons.core.gameobject.user.User)3 Material (org.bukkit.Material)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Addon (mc.dragons.core.addon.Addon)2 NPCAddon (mc.dragons.core.addon.NPCAddon)2 GameObject (mc.dragons.core.gameobject.GameObject)2 NPCAction (mc.dragons.core.gameobject.npc.NPCAction)2 NPCCondition (mc.dragons.core.gameobject.npc.NPCCondition)2 NPCConditionalActions (mc.dragons.core.gameobject.npc.NPCConditionalActions)2 Attribute (org.bukkit.attribute.Attribute)2 EntityType (org.bukkit.entity.EntityType)2 Arrays (java.util.Arrays)1 Entry (java.util.Map.Entry)1 Pattern (java.util.regex.Pattern)1