From e5cfb54f7b8da46630822b3511f0f9da84751731 Mon Sep 17 00:00:00 2001 From: NK Date: Tue, 27 Dec 2022 16:00:07 +0000 Subject: [PATCH] npc command --- .../nullvalkyrie/commands/CommandManager.java | 1 + .../nullvalkyrie/commands/NPCCommand.java | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/main/java/me/night/nullvalkyrie/commands/NPCCommand.java diff --git a/src/main/java/me/night/nullvalkyrie/commands/CommandManager.java b/src/main/java/me/night/nullvalkyrie/commands/CommandManager.java index 11f14b4..1524fd5 100644 --- a/src/main/java/me/night/nullvalkyrie/commands/CommandManager.java +++ b/src/main/java/me/night/nullvalkyrie/commands/CommandManager.java @@ -18,5 +18,6 @@ public class CommandManager { new BetaCommand(); new MinerCommand(); new LuckyDrawCommand(); + new NPCCommand(); } } diff --git a/src/main/java/me/night/nullvalkyrie/commands/NPCCommand.java b/src/main/java/me/night/nullvalkyrie/commands/NPCCommand.java new file mode 100644 index 0000000..0aba081 --- /dev/null +++ b/src/main/java/me/night/nullvalkyrie/commands/NPCCommand.java @@ -0,0 +1,39 @@ +package me.night.nullvalkyrie.commands; + +import me.night.nullvalkyrie.entities.npcs.NPCManager; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.util.StringUtil; + +import java.util.ArrayList; +import java.util.List; + +public class NPCCommand extends Command { + public NPCCommand() { + super("npc", new String[]{}, "NPCs", ""); + } + + @Override + public void onCommand(CommandSender sender, String[] args) { + if (sender instanceof Player player) { + if (args.length == 0) { + player.sendMessage(ChatColor.RED + "Invalid command"); + return; + } + if (args[0].equalsIgnoreCase("new")) { + NPCManager.createNPC(player, args[1]); + } + } + + } + + @Override + public List onTabComplete(CommandSender sender, String[] args) { + if (args.length == 1) { + List cc = List.of("new", "list"); + return StringUtil.copyPartialMatches(args[0], cc, new ArrayList<>()); + } + return new ArrayList<>(); + } +}