Search in sources :

Example 16 with NPCClass

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

the class NPCCommand method setHolding.

private void setHolding(CommandSender sender, String[] args) {
    NPCClass npcClass = lookupNPCClass(sender, args[0]);
    if (npcClass == null)
        return;
    Document base = Document.parse(npcClass.getData().toJson());
    if (args[2].equalsIgnoreCase("none")) {
        npcClass.setHeldItemType(null);
        sender.sendMessage(ChatColor.GREEN + "Removed held item successfully.");
        AUDIT_LOG.saveEntry(npcClass, user(sender), base, "Removed held item");
        propagateRevisions(npcClass);
    }
    Material type = StringUtil.parseMaterialType(sender, args[2]);
    if (type == null)
        return;
    npcClass.setHeldItemType(type);
    sender.sendMessage(ChatColor.GREEN + "Set held item successfully.");
    AUDIT_LOG.saveEntry(npcClass, user(sender), base, "Set entity held item to " + type);
    propagateRevisions(npcClass);
}
Also used : NPCClass(mc.dragons.core.gameobject.npc.NPCClass) Material(org.bukkit.Material) Document(org.bson.Document)

Example 17 with NPCClass

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

the class NPCCommand method manageLoot.

private void manageLoot(CommandSender sender, String[] args) {
    NPCClass npcClass = lookupNPCClass(sender, args[0]);
    if (npcClass == null)
        return;
    User user = user(sender);
    Document base = Document.parse(npcClass.getData().toJson());
    if (args.length == 2) {
        sender.sendMessage(ChatColor.GREEN + "Loot Table:");
        for (Entry<String, Map<String, Double>> regionLoot : npcClass.getLootTable().asMap().entrySet()) {
            sender.sendMessage(ChatColor.GRAY + "- Region: " + regionLoot.getKey());
            for (Entry<String, Double> itemLoot : regionLoot.getValue().entrySet()) {
                sender.sendMessage(ChatColor.GRAY + "   - " + itemLoot.getKey() + ": " + itemLoot.getValue() + "%");
            }
        }
    } else if (args.length < 5) {
        sender.sendMessage(ChatColor.RED + "Invalid arguments! /npc <ClassName> loot [<RegionShortName> <ItemClassShortName> <Chance%|DEL>]");
    } else if (args[4].equalsIgnoreCase("del")) {
        npcClass.deleteFromLootTable(args[2], args[3]);
        sender.sendMessage(ChatColor.GREEN + "Removed from entity loot table successfully.");
        AUDIT_LOG.saveEntry(npcClass, user, base, "Removed entry from loot table");
    } else {
        Double chance = parseDouble(sender, args[4]);
        if (chance == null)
            return;
        npcClass.updateLootTable(args[2], args[3], chance);
        sender.sendMessage(ChatColor.GREEN + "Updated entity loot table successfully.");
        AUDIT_LOG.saveEntry(npcClass, user, base, "Added entry to loot table");
    }
}
Also used : NPCClass(mc.dragons.core.gameobject.npc.NPCClass) User(mc.dragons.core.gameobject.user.User) Document(org.bson.Document) Map(java.util.Map)

Example 18 with NPCClass

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

the class NPCCommand method setSkin.

private void setSkin(CommandSender sender, String[] args) {
    NPCClass npcClass = lookupNPCClass(sender, args[0]);
    if (npcClass == null)
        return;
    if (args.length == 2) {
        sender.sendMessage(ChatColor.RED + "/npc <ClassName> skin <SkinDataURL>");
        sender.sendMessage(ChatColor.RED + "The URL should be a raw text file with the first line being the texture and the second being the signature. E.g. https://pastebin.com/raw/wgNpXfvH");
        return;
    }
    Document base = Document.parse(npcClass.getData().toJson());
    String data = HttpUtil.get(args[2]);
    String[] parts = data.split("\n");
    String texture = parts[0];
    String signature = parts[1];
    npcClass.setSkinTexture(texture);
    npcClass.setSkinSignature(signature);
    sender.sendMessage(ChatColor.GREEN + "Updated entity skin data successfully.");
    AUDIT_LOG.saveEntry(npcClass, user(sender), base, "Set entity skin data");
    propagateRevisions(npcClass);
}
Also used : NPCClass(mc.dragons.core.gameobject.npc.NPCClass) Document(org.bson.Document)

Example 19 with NPCClass

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

the class NPCCommand method setName.

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

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