Better bot creation, faceLocation() improved, Mojang API fetching cache added.

This commit is contained in:
batchprogrammer314
2021-06-28 13:18:49 -05:00
parent 70490d55bb
commit 79add1b78d
6 changed files with 130 additions and 27 deletions

View File

@@ -11,15 +11,24 @@ import net.nuggetmc.ai.commands.CommandHandler;
import net.nuggetmc.ai.commands.CommandInstance;
import net.nuggetmc.ai.utils.ChatUtils;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.text.NumberFormat;
import java.util.Locale;
public class PlayerAICommand extends CommandInstance {
private BotManager manager;
public PlayerAICommand(CommandHandler commandHandler) {
super(commandHandler);
this.manager = PlayerAI.getInstance().getManager();
}
@Command(name = "", desc = "The PlayerAI main command.")
@@ -38,25 +47,36 @@ public class PlayerAICommand extends CommandInstance {
@Command(name = "create", desc = "Create bots.", usage = "<name> [skin]")
@Require("playerai.manage")
public void createBotCommand(@Sender Player sender, String name, @OptArg String skin) {
// make 16 character limit on name
Bot.createBot(name, sender.getLocation(), skin == null ? name : skin);
manager.createBots(sender, name, skin, 1);
}
@Command(name = "multi", desc = "Create multiple bots at once.", usage = "<amount> <name> [skin]")
@Require("playerai.manage")
public void multiBotCommand(@Sender Player sender, int n, String name, @OptArg String skin) {
manager.createBots(sender, name, skin, n);
}
@Command(name = "debug", desc = "Debug bot stats.")
@Require("playerai.manage")
public void debugCommand(@Sender Player sender) {
// This will be used for miscellaneous code for testing as the plugin is worked on
Location loc = sender.getLocation();
for (Bot bot : PlayerAI.getInstance().getManager().fetch()) {
bot.faceLocation(loc);
}
}
@Command(name = "info", desc = "Information about loaded bots.")
@Require("playerai.manage")
public void infoCommand(@Sender Player sender) {
public void infoCommand(@Sender Player player) {
// This will be the future GUI where players can view information about every loaded bot
}
@Command(name = "reset", desc = "Remove all loaded bots.")
@Require("playerai.manage")
public void resetCommand(@Sender Player sender) {
public void resetCommand(@Sender CommandSender sender) {
sender.sendMessage("Removing every bot...");
BotManager manager = PlayerAI.getInstance().getManager();