Search in sources :

Example 1 with NPCClass

use of mc.dragons.core.gameobject.npc.NPCClass in project DragonsOnline by UniverseCraft.

the class NPCCommand method manageAddons.

private void manageAddons(CommandSender sender, String[] args) {
    NPCClass npcClass = lookupNPCClass(sender, args[0]);
    if (npcClass == null)
        return;
    User user = user(sender);
    if (args.length == 2) {
        sender.sendMessage(ChatColor.GREEN + "Listing addons for NPC class " + npcClass.getClassName() + ":");
        for (NPCAddon addon : npcClass.getAddons()) {
            sender.sendMessage(ChatColor.GRAY + "- " + addon.getName());
        }
        return;
    } else if (args.length == 3) {
        sender.sendMessage(ChatColor.RED + "Specify an addon name! For a list of addons, do /addon -l");
        return;
    }
    Document base = Document.parse(npcClass.getData().toJson());
    Addon addon = addonRegistry.getAddonByName(args[3]);
    if (addon == null) {
        sender.sendMessage(ChatColor.RED + "Invalid addon name! For a list of addons, do /addon -l");
    } else if (addon.getType() != AddonType.NPC) {
        sender.sendMessage(ChatColor.RED + "Invalid addon type! Only NPC Addons can be applied to NPCs.");
    } else if (args[2].equalsIgnoreCase("add")) {
        npcClass.addAddon((NPCAddon) addon);
        sender.sendMessage(ChatColor.GREEN + "Added addon " + addon.getName() + " to NPC class " + npcClass.getClassName() + ".");
        AUDIT_LOG.saveEntry(npcClass, user, base, "Added addon " + addon.getName());
    } else if (args[2].equalsIgnoreCase("remove")) {
        npcClass.removeAddon((NPCAddon) addon);
        sender.sendMessage(ChatColor.GREEN + "Removed addon " + addon.getName() + " from NPC class " + npcClass.getClassName() + ".");
        AUDIT_LOG.saveEntry(npcClass, user, base, "Removed addon " + addon.getName());
    } else {
        sender.sendMessage(ChatColor.RED + "Invalid arguments! /npc <ClassName> addon [<add|remove> <AddonName>]");
    }
}
Also used : NPCClass(mc.dragons.core.gameobject.npc.NPCClass) Addon(mc.dragons.core.addon.Addon) NPCAddon(mc.dragons.core.addon.NPCAddon) User(mc.dragons.core.gameobject.user.User) NPCAddon(mc.dragons.core.addon.NPCAddon) Document(org.bson.Document)

Example 2 with NPCClass

use of mc.dragons.core.gameobject.npc.NPCClass in project DragonsOnline by UniverseCraft.

the class NPCCommand method setImmortal.

private void setImmortal(CommandSender sender, String[] args) {
    NPCClass npcClass = lookupNPCClass(sender, args[0]);
    Boolean immortal = parseBoolean(sender, args[2]);
    if (npcClass == null || immortal == null)
        return;
    Document base = Document.parse(npcClass.getData().toJson());
    npcClass.setImmortal(immortal);
    sender.sendMessage(ChatColor.GREEN + "Updated entity immortality successfully.");
    AUDIT_LOG.saveEntry(npcClass, user(sender), base, "Set entity immortality to " + immortal);
    propagateRevisions(npcClass);
}
Also used : NPCClass(mc.dragons.core.gameobject.npc.NPCClass) Document(org.bson.Document)

Example 3 with NPCClass

use of mc.dragons.core.gameobject.npc.NPCClass in project DragonsOnline by UniverseCraft.

the class NPCCommand method setLevel.

private void setLevel(CommandSender sender, String[] args) {
    NPCClass npcClass = lookupNPCClass(sender, args[0]);
    Integer level = parseInt(sender, args[2]);
    if (npcClass == null || level == null)
        return;
    Document base = Document.parse(npcClass.getData().toJson());
    npcClass.setLevel(level);
    sender.sendMessage(ChatColor.GREEN + "Updated entity level successfully.");
    AUDIT_LOG.saveEntry(npcClass, user(sender), base, "Set entity level to " + level);
    propagateRevisions(npcClass);
}
Also used : NPCClass(mc.dragons.core.gameobject.npc.NPCClass) Document(org.bson.Document)

Example 4 with NPCClass

use of mc.dragons.core.gameobject.npc.NPCClass in project DragonsOnline by UniverseCraft.

the class NPCCommand method setMaxHealth.

private void setMaxHealth(CommandSender sender, String[] args) {
    NPCClass npcClass = lookupNPCClass(sender, args[0]);
    Double maxHealth = parseDouble(sender, args[2]);
    if (npcClass == null || maxHealth == null)
        return;
    Document base = Document.parse(npcClass.getData().toJson());
    npcClass.setMaxHealth(maxHealth);
    sender.sendMessage(ChatColor.GREEN + "Updated entity max health successfully.");
    AUDIT_LOG.saveEntry(npcClass, user(sender), base, "Set entity max health to " + maxHealth);
    propagateRevisions(npcClass);
}
Also used : NPCClass(mc.dragons.core.gameobject.npc.NPCClass) Document(org.bson.Document)

Example 5 with NPCClass

use of mc.dragons.core.gameobject.npc.NPCClass in project DragonsOnline by UniverseCraft.

the class NPCCommand method deleteClass.

private void deleteClass(CommandSender sender, String[] args) {
    if (!requirePermission(sender, SystemProfileFlag.GM_DELETE))
        return;
    if (args.length == 1) {
        sender.sendMessage(ChatColor.RED + "Specify a class name to delete! /npc delete <ClassName>");
        return;
    }
    NPCClass npcClass = lookupNPCClass(sender, args[1]);
    if (npcClass == null)
        return;
    gameObjectRegistry.removeFromDatabase(npcClass);
    AUDIT_LOG.saveEntry(npcClass, user(sender), "Deleted");
    sender.sendMessage(ChatColor.GREEN + "Successfully deleted NPC class.");
}
Also used : NPCClass(mc.dragons.core.gameobject.npc.NPCClass)

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