diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/commands/CreateCommand.java b/plugin/src/main/java/lol/pyr/znpcsplus/commands/CreateCommand.java index 1c3c1e9..341edca 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/commands/CreateCommand.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/commands/CreateCommand.java @@ -26,12 +26,18 @@ public class CreateCommand implements CommandHandler { @Override public void run(CommandContext context) throws CommandExecutionException { - context.setUsage(context.getLabel() + " create <id> <type>"); + context.setUsage(context.getLabel() + " create <id> [<type>]"); Player player = context.ensureSenderIsPlayer(); String id = context.popString(); if (npcRegistry.getById(id) != null) context.halt(Component.text("NPC with that ID already exists.", NamedTextColor.RED)); - NpcTypeImpl type = context.parse(NpcTypeImpl.class); + + NpcTypeImpl type; + if (context.argSize() == 1) { + type = context.parse(NpcTypeImpl.class); + } else { + type = typeRegistry.getByName("player"); + } NpcEntryImpl entry = npcRegistry.create(id, player.getWorld(), type, new NpcLocation(player.getLocation())); entry.enableEverything(); diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/commands/ToggleCommand.java b/plugin/src/main/java/lol/pyr/znpcsplus/commands/ToggleCommand.java index c6d1c06..60a09c8 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/commands/ToggleCommand.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/commands/ToggleCommand.java @@ -21,9 +21,14 @@ public class ToggleCommand implements CommandHandler { @Override public void run(CommandContext context) throws CommandExecutionException { - context.setUsage(context.getLabel() + " toggle <id>"); + context.setUsage(context.getLabel() + " toggle <id> [<enable/disable>]"); NpcImpl npc = context.parse(NpcEntryImpl.class).getNpc(); - boolean enabled = !npc.isEnabled(); + boolean enabled; + if (context.argSize() == 1) { + enabled = context.popString().equalsIgnoreCase("enable"); + } else { + enabled = !npc.isEnabled(); + } npc.setEnabled(enabled); context.send(Component.text("NPC has been " + (enabled ? "enabled" : "disabled"), NamedTextColor.GREEN)); } @@ -31,6 +36,7 @@ public class ToggleCommand implements CommandHandler { @Override public List<String> suggest(CommandContext context) throws CommandExecutionException { if (context.argSize() == 1) return context.suggestCollection(npcRegistry.getModifiableIds()); + if (context.argSize() == 2) return context.suggestLiteral("enable", "disable"); return Collections.emptyList(); } }