command text change stuff and also getting rid of unnecessary npc list in NPCManager
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<String> getUsage(Class<? extends CommandInstance> 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<Method> getSubCommands(Class<? extends CommandInstance> 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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 + "]");
|
||||
|
||||
@@ -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<NPC> npcs = new HashSet<>();
|
||||
private final Map<Integer, NPC> npcConnections = new HashMap<>();
|
||||
|
||||
public Set<NPC> 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
|
||||
|
||||
Reference in New Issue
Block a user