From 5ab92de6d7fc2291d9a98454192183baea0d1591 Mon Sep 17 00:00:00 2001 From: batchprogrammer314 Date: Sat, 26 Jun 2021 23:44:07 -0500 Subject: [PATCH] command text change stuff and also getting rid of unnecessary npc list in NPCManager --- PlayerAI.iml | 13 +++++++++---- pom.xml | 2 +- src/main/java/net/nuggetmc/ai/PlayerAI.java | 4 +--- .../net/nuggetmc/ai/commands/CommandHandler.java | 14 ++++++-------- .../ai/commands/commands/PlayerAICommand.java | 3 +-- src/main/java/net/nuggetmc/ai/npc/NPCManager.java | 9 --------- 6 files changed, 18 insertions(+), 27 deletions(-) diff --git a/PlayerAI.iml b/PlayerAI.iml index 8b10cdd..d0e0bf3 100644 --- a/PlayerAI.iml +++ b/PlayerAI.iml @@ -1,12 +1,17 @@ - - - + + + + - + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 51daab7..57a7775 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,7 @@ com.jonahseguin drink - 1.0.0 + 1.0.2 compile diff --git a/src/main/java/net/nuggetmc/ai/PlayerAI.java b/src/main/java/net/nuggetmc/ai/PlayerAI.java index 2ad058f..6f14983 100644 --- a/src/main/java/net/nuggetmc/ai/PlayerAI.java +++ b/src/main/java/net/nuggetmc/ai/PlayerAI.java @@ -2,7 +2,6 @@ package net.nuggetmc.ai; import net.nuggetmc.ai.commands.CommandHandler; import net.nuggetmc.ai.npc.NPCManager; -import org.bukkit.command.PluginCommand; import org.bukkit.plugin.java.JavaPlugin; public class PlayerAI extends JavaPlugin { @@ -31,7 +30,7 @@ public class PlayerAI extends JavaPlugin { instance = this; // Create Instances - this.handler = new CommandHandler(); + this.handler = new CommandHandler(this); this.manager = new NPCManager(this); // Register all the things @@ -46,5 +45,4 @@ public class PlayerAI extends JavaPlugin { private void registerEvents() { getServer().getPluginManager().registerEvents(manager, this); } - } diff --git a/src/main/java/net/nuggetmc/ai/commands/CommandHandler.java b/src/main/java/net/nuggetmc/ai/commands/CommandHandler.java index 3b69a3a..a7257a4 100644 --- a/src/main/java/net/nuggetmc/ai/commands/CommandHandler.java +++ b/src/main/java/net/nuggetmc/ai/commands/CommandHandler.java @@ -1,9 +1,7 @@ package net.nuggetmc.ai.commands; -import com.jonahseguin.drink.CommandService; import com.jonahseguin.drink.Drink; import com.jonahseguin.drink.annotation.Command; -import com.jonahseguin.drink.command.DrinkCommandContainer; import com.jonahseguin.drink.command.DrinkCommandService; import net.nuggetmc.ai.PlayerAI; import net.nuggetmc.ai.commands.commands.PlayerAICommand; @@ -19,16 +17,17 @@ public class CommandHandler { private final DrinkCommandService drink; - public CommandHandler() { - drink = (DrinkCommandService) Drink.get(PlayerAI.getInstance()); - drink.register(new PlayerAICommand(this), "playerai", "pai"); + public CommandHandler(PlayerAI plugin) { + drink = (DrinkCommandService) Drink.get(plugin); + drink.register(new PlayerAICommand(this), "bot", "playerai", "pai", "ai", "npc"); drink.registerCommands(); } public List getUsage(Class clazz) { + String rootName = getRootName(clazz); return getSubCommands(clazz).stream().map(c -> { Command command = c.getAnnotation(Command.class); - return ChatColor.GRAY + " ▪ " + ChatColor.YELLOW + "/" + getRootName(clazz) + (command.name().isEmpty() ? "" : " " + command.name()) + ChatColor.GRAY + " ▪ " + return ChatColor.GRAY + " ▪ " + ChatColor.YELLOW + "/" + rootName + " " + command.name() + ChatColor.GRAY + " ▪ " + ChatColor.RESET + command.desc(); }).collect(Collectors.toList()); } @@ -39,7 +38,6 @@ public class CommandHandler { } private List getSubCommands(Class clazz) { - return Arrays.stream(clazz.getDeclaredMethods()).filter(m -> m.isAnnotationPresent(Command.class)).collect(Collectors.toList()); + return Arrays.stream(clazz.getDeclaredMethods()).filter(m -> m.isAnnotationPresent(Command.class) && !m.getAnnotation(Command.class).name().isEmpty()).collect(Collectors.toList()); } - } diff --git a/src/main/java/net/nuggetmc/ai/commands/commands/PlayerAICommand.java b/src/main/java/net/nuggetmc/ai/commands/commands/PlayerAICommand.java index 1e59a52..90c3224 100644 --- a/src/main/java/net/nuggetmc/ai/commands/commands/PlayerAICommand.java +++ b/src/main/java/net/nuggetmc/ai/commands/commands/PlayerAICommand.java @@ -3,7 +3,6 @@ package net.nuggetmc.ai.commands.commands; import com.jonahseguin.drink.annotation.Command; import com.jonahseguin.drink.annotation.OptArg; import com.jonahseguin.drink.annotation.Sender; -import com.jonahseguin.drink.annotation.Text; import net.nuggetmc.ai.PlayerAI; import net.nuggetmc.ai.commands.CommandHandler; import net.nuggetmc.ai.commands.CommandInstance; @@ -22,7 +21,7 @@ public class PlayerAICommand extends CommandInstance { super(commandHandler); } - @Command(name = "", desc = "Test Description") + @Command(name = "", desc = "The PlayerAI main command.") public void rootCommand(@Sender Player sender) { sender.sendMessage(ChatUtils.LINE); sender.sendMessage(ChatColor.GOLD + "PlayerAI" + ChatColor.GRAY + " [" + ChatColor.RED + "v" + PlayerAI.VERSION + ChatColor.GRAY + "]"); diff --git a/src/main/java/net/nuggetmc/ai/npc/NPCManager.java b/src/main/java/net/nuggetmc/ai/npc/NPCManager.java index 85c226a..1f44199 100644 --- a/src/main/java/net/nuggetmc/ai/npc/NPCManager.java +++ b/src/main/java/net/nuggetmc/ai/npc/NPCManager.java @@ -2,15 +2,12 @@ package net.nuggetmc.ai.npc; import net.minecraft.server.v1_16_R3.PlayerConnection; import net.nuggetmc.ai.PlayerAI; -import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; -import java.util.HashMap; import java.util.HashSet; -import java.util.Map; import java.util.Set; public class NPCManager implements Listener { @@ -18,7 +15,6 @@ public class NPCManager implements Listener { private final PlayerAI plugin; private final Set npcs = new HashSet<>(); - private final Map npcConnections = new HashMap<>(); public Set fetch() { return npcs; @@ -26,10 +22,6 @@ public class NPCManager implements Listener { public void add(NPC npc) { npcs.add(npc); - - Bukkit.getScheduler().runTaskLater(plugin, () -> { - npcConnections.put(npc.getId(), npc); - }, 10); } public NPCManager(PlayerAI plugin) { @@ -42,7 +34,6 @@ public class NPCManager implements Listener { } npcs.clear(); - npcConnections.clear(); } @EventHandler