Skip to content

Commit

Permalink
Add /npc create --registry
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Feb 22, 2021
1 parent 4419231 commit 6c26f98
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions main/src/main/java/net/citizensnpcs/commands/NPCCommands.java
Expand Up @@ -449,7 +449,7 @@ public void copy(CommandContext args, CommandSender sender, NPC npc) throws Comm

@Command(
aliases = { "npc" },
usage = "create [name] ((-b(aby),u(nspawned),s(ilent)) --at [x:y:z:world] --type [type] --trait ['trait1, trait2...'] --b [behaviours])",
usage = "create [name] ((-b(aby),u(nspawned),s(ilent)) --at [x:y:z:world] --type [type] --trait ['trait1, trait2...'] --registry [registry name])",
desc = "Create a new NPC",
flags = "bus",
modifiers = { "create" },
Expand Down Expand Up @@ -480,8 +480,14 @@ public void create(CommandContext args, CommandSender sender, NPC npc) throws Co
if (!sender.hasPermission("citizens.npc.create.*") && !sender.hasPermission("citizens.npc.createall")
&& !sender.hasPermission("citizens.npc.create." + type.name().toLowerCase().replace("_", "")))
throw new NoPermissionsException();

npc = CitizensAPI.getNPCRegistry().createNPC(type, name);
NPCRegistry registry = CitizensAPI.getNPCRegistry();
if (args.hasValueFlag("registry")) {
registry = CitizensAPI.getNamedNPCRegistry(args.getFlag("registry"));
if (registry == null) {
throw new CommandException("Unknown NPC registry name");
}
}
npc = registry.createNPC(type, name);
String msg = "You created [[" + npc.getName() + "]] (ID [[" + npc.getId() + "]])";

int age = 0;
Expand Down

0 comments on commit 6c26f98

Please sign in to comment.