npc command

This commit is contained in:
NK 2022-12-27 16:00:07 +00:00
parent baf34db7ae
commit e5cfb54f7b
2 changed files with 40 additions and 0 deletions

View file

@ -18,5 +18,6 @@ public class CommandManager {
new BetaCommand();
new MinerCommand();
new LuckyDrawCommand();
new NPCCommand();
}
}

View file

@ -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<String> onTabComplete(CommandSender sender, String[] args) {
if (args.length == 1) {
List<String> cc = List.of("new", "list");
return StringUtil.copyPartialMatches(args[0], cc, new ArrayList<>());
}
return new ArrayList<>();
}
}