command text change stuff and also getting rid of unnecessary npc list in NPCManager
This commit is contained in:
13
PlayerAI.iml
13
PlayerAI.iml
@@ -1,12 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module type="JAVA_MODULE" version="4">
|
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||||
<exclude-output />
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="spigot" level="project" />
|
<orderEntry type="library" name="spigot" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.spigotmc:spigot:1.16.4-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.jonahseguin:drink:1.0.2" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
2
pom.xml
2
pom.xml
@@ -55,7 +55,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jonahseguin</groupId>
|
<groupId>com.jonahseguin</groupId>
|
||||||
<artifactId>drink</artifactId>
|
<artifactId>drink</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.2</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package net.nuggetmc.ai;
|
|||||||
|
|
||||||
import net.nuggetmc.ai.commands.CommandHandler;
|
import net.nuggetmc.ai.commands.CommandHandler;
|
||||||
import net.nuggetmc.ai.npc.NPCManager;
|
import net.nuggetmc.ai.npc.NPCManager;
|
||||||
import org.bukkit.command.PluginCommand;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class PlayerAI extends JavaPlugin {
|
public class PlayerAI extends JavaPlugin {
|
||||||
@@ -31,7 +30,7 @@ public class PlayerAI extends JavaPlugin {
|
|||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
// Create Instances
|
// Create Instances
|
||||||
this.handler = new CommandHandler();
|
this.handler = new CommandHandler(this);
|
||||||
this.manager = new NPCManager(this);
|
this.manager = new NPCManager(this);
|
||||||
|
|
||||||
// Register all the things
|
// Register all the things
|
||||||
@@ -46,5 +45,4 @@ public class PlayerAI extends JavaPlugin {
|
|||||||
private void registerEvents() {
|
private void registerEvents() {
|
||||||
getServer().getPluginManager().registerEvents(manager, this);
|
getServer().getPluginManager().registerEvents(manager, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package net.nuggetmc.ai.commands;
|
package net.nuggetmc.ai.commands;
|
||||||
|
|
||||||
import com.jonahseguin.drink.CommandService;
|
|
||||||
import com.jonahseguin.drink.Drink;
|
import com.jonahseguin.drink.Drink;
|
||||||
import com.jonahseguin.drink.annotation.Command;
|
import com.jonahseguin.drink.annotation.Command;
|
||||||
import com.jonahseguin.drink.command.DrinkCommandContainer;
|
|
||||||
import com.jonahseguin.drink.command.DrinkCommandService;
|
import com.jonahseguin.drink.command.DrinkCommandService;
|
||||||
import net.nuggetmc.ai.PlayerAI;
|
import net.nuggetmc.ai.PlayerAI;
|
||||||
import net.nuggetmc.ai.commands.commands.PlayerAICommand;
|
import net.nuggetmc.ai.commands.commands.PlayerAICommand;
|
||||||
@@ -19,16 +17,17 @@ public class CommandHandler {
|
|||||||
|
|
||||||
private final DrinkCommandService drink;
|
private final DrinkCommandService drink;
|
||||||
|
|
||||||
public CommandHandler() {
|
public CommandHandler(PlayerAI plugin) {
|
||||||
drink = (DrinkCommandService) Drink.get(PlayerAI.getInstance());
|
drink = (DrinkCommandService) Drink.get(plugin);
|
||||||
drink.register(new PlayerAICommand(this), "playerai", "pai");
|
drink.register(new PlayerAICommand(this), "bot", "playerai", "pai", "ai", "npc");
|
||||||
drink.registerCommands();
|
drink.registerCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getUsage(Class<? extends CommandInstance> clazz) {
|
public List<String> getUsage(Class<? extends CommandInstance> clazz) {
|
||||||
|
String rootName = getRootName(clazz);
|
||||||
return getSubCommands(clazz).stream().map(c -> {
|
return getSubCommands(clazz).stream().map(c -> {
|
||||||
Command command = c.getAnnotation(Command.class);
|
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();
|
+ ChatColor.RESET + command.desc();
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@@ -39,7 +38,6 @@ public class CommandHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<Method> getSubCommands(Class<? extends CommandInstance> clazz) {
|
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.Command;
|
||||||
import com.jonahseguin.drink.annotation.OptArg;
|
import com.jonahseguin.drink.annotation.OptArg;
|
||||||
import com.jonahseguin.drink.annotation.Sender;
|
import com.jonahseguin.drink.annotation.Sender;
|
||||||
import com.jonahseguin.drink.annotation.Text;
|
|
||||||
import net.nuggetmc.ai.PlayerAI;
|
import net.nuggetmc.ai.PlayerAI;
|
||||||
import net.nuggetmc.ai.commands.CommandHandler;
|
import net.nuggetmc.ai.commands.CommandHandler;
|
||||||
import net.nuggetmc.ai.commands.CommandInstance;
|
import net.nuggetmc.ai.commands.CommandInstance;
|
||||||
@@ -22,7 +21,7 @@ public class PlayerAICommand extends CommandInstance {
|
|||||||
super(commandHandler);
|
super(commandHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(name = "", desc = "Test Description")
|
@Command(name = "", desc = "The PlayerAI main command.")
|
||||||
public void rootCommand(@Sender Player sender) {
|
public void rootCommand(@Sender Player sender) {
|
||||||
sender.sendMessage(ChatUtils.LINE);
|
sender.sendMessage(ChatUtils.LINE);
|
||||||
sender.sendMessage(ChatColor.GOLD + "PlayerAI" + ChatColor.GRAY + " [" + ChatColor.RED + "v" + PlayerAI.VERSION + ChatColor.GRAY + "]");
|
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.minecraft.server.v1_16_R3.PlayerConnection;
|
||||||
import net.nuggetmc.ai.PlayerAI;
|
import net.nuggetmc.ai.PlayerAI;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class NPCManager implements Listener {
|
public class NPCManager implements Listener {
|
||||||
@@ -18,7 +15,6 @@ public class NPCManager implements Listener {
|
|||||||
private final PlayerAI plugin;
|
private final PlayerAI plugin;
|
||||||
|
|
||||||
private final Set<NPC> npcs = new HashSet<>();
|
private final Set<NPC> npcs = new HashSet<>();
|
||||||
private final Map<Integer, NPC> npcConnections = new HashMap<>();
|
|
||||||
|
|
||||||
public Set<NPC> fetch() {
|
public Set<NPC> fetch() {
|
||||||
return npcs;
|
return npcs;
|
||||||
@@ -26,10 +22,6 @@ public class NPCManager implements Listener {
|
|||||||
|
|
||||||
public void add(NPC npc) {
|
public void add(NPC npc) {
|
||||||
npcs.add(npc);
|
npcs.add(npc);
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
|
||||||
npcConnections.put(npc.getId(), npc);
|
|
||||||
}, 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NPCManager(PlayerAI plugin) {
|
public NPCManager(PlayerAI plugin) {
|
||||||
@@ -42,7 +34,6 @@ public class NPCManager implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
npcs.clear();
|
npcs.clear();
|
||||||
npcConnections.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|||||||
Reference in New Issue
Block a user