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);
}
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");
}
}
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);
}
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);
}
Aggregations