ooops
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
package net.nuggetmc.ai.command.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 com.jonahseguin.drink.annotation.*;
|
||||
import com.jonahseguin.drink.utils.ChatUtils;
|
||||
import net.nuggetmc.ai.TerminatorPlus;
|
||||
import net.nuggetmc.ai.bot.Bot;
|
||||
import net.nuggetmc.ai.bot.BotManager;
|
||||
import net.nuggetmc.ai.bot.agent.legacyagent.EnumTargetGoal;
|
||||
import net.nuggetmc.ai.bot.agent.legacyagent.LegacyAgent;
|
||||
import net.nuggetmc.ai.command.CommandHandler;
|
||||
import net.nuggetmc.ai.command.CommandInstance;
|
||||
import net.nuggetmc.ai.utils.Debugger;
|
||||
import net.nuggetmc.ai.utils.StringUtilities;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@@ -20,15 +20,16 @@ import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class BotCommand extends CommandInstance {
|
||||
|
||||
private final TerminatorPlus plugin;
|
||||
private final CommandHandler handler;
|
||||
private final BotManager manager;
|
||||
private final LegacyAgent agent;
|
||||
private final BukkitScheduler scheduler;
|
||||
private final DecimalFormat formatter;
|
||||
|
||||
@@ -37,12 +38,17 @@ public class BotCommand extends CommandInstance {
|
||||
public BotCommand(CommandHandler commandHandler) {
|
||||
super(commandHandler);
|
||||
|
||||
this.handler = commandHandler;
|
||||
this.plugin = TerminatorPlus.getInstance();
|
||||
this.manager = plugin.getManager();
|
||||
this.agent = (LegacyAgent) manager.getAgent();
|
||||
this.scheduler = Bukkit.getScheduler();
|
||||
this.formatter = new DecimalFormat("0.##");
|
||||
}
|
||||
|
||||
scheduler.runTask(plugin, () -> aiManager = (AICommand) plugin.getHandler().getComand("ai"));
|
||||
@Override
|
||||
public void onLoad() {
|
||||
this.aiManager = (AICommand) handler.getCommand("ai");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@@ -101,7 +107,7 @@ public class BotCommand extends CommandInstance {
|
||||
* current target
|
||||
* current kills
|
||||
* skin
|
||||
* neural network values
|
||||
* neural network values (network name if loaded, otherwise RANDOM)
|
||||
*/
|
||||
|
||||
String botName = bot.getName();
|
||||
@@ -125,12 +131,9 @@ public class BotCommand extends CommandInstance {
|
||||
});
|
||||
}
|
||||
|
||||
@Autofill
|
||||
public List<String> infoAutofill(CommandSender sender, String[] args) {
|
||||
if (args.length == 2) {
|
||||
return manager.fetchNames();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return args.length == 2 ? manager.fetchNames() : null;
|
||||
}
|
||||
|
||||
@Command(
|
||||
@@ -139,12 +142,9 @@ public class BotCommand extends CommandInstance {
|
||||
)
|
||||
public void reset(@Sender CommandSender sender) {
|
||||
sender.sendMessage("Removing every bot...");
|
||||
|
||||
int size = manager.fetch().size();
|
||||
manager.reset();
|
||||
|
||||
String formatted = NumberFormat.getNumberInstance(Locale.US).format(size);
|
||||
sender.sendMessage("Removed " + ChatColor.RED + formatted + ChatColor.RESET + " entit" + (size == 1 ? "y" : "ies") + ".");
|
||||
sender.sendMessage("Removed " + ChatColor.RED + StringUtilities.NUMBER_FORMAT.format(size) + ChatColor.RESET + " entit" + (size == 1 ? "y" : "ies") + ".");
|
||||
|
||||
if (aiManager.hasActiveSession()) {
|
||||
Bukkit.dispatchCommand(sender, "ai stop");
|
||||
@@ -152,26 +152,58 @@ public class BotCommand extends CommandInstance {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "options",
|
||||
name = "settings",
|
||||
desc = "Make changes to the global configuration file and bot-specific settings.",
|
||||
aliases = "settings",
|
||||
autofill = "optionsAutofill"
|
||||
aliases = "options",
|
||||
autofill = "settingsAutofill"
|
||||
)
|
||||
public void options(@Sender CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "This feature is coming soon!");
|
||||
public void settings(@Sender CommandSender sender, @OptArg String arg1, @OptArg String arg2) {
|
||||
String extra = ChatColor.GRAY + " [" + ChatColor.YELLOW + "/bot settings" + ChatColor.GRAY + "]";
|
||||
|
||||
if (arg1 == null || !arg1.equals("setgoal")) {
|
||||
sender.sendMessage(ChatUtils.LINE);
|
||||
sender.sendMessage(ChatColor.GOLD + "Bot Settings" + extra);
|
||||
sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "setgoal" + ChatUtils.BULLET_FORMATTED + "Set the global bot target selection method.");
|
||||
sender.sendMessage(ChatUtils.LINE);
|
||||
return;
|
||||
}
|
||||
|
||||
EnumTargetGoal goal = EnumTargetGoal.from(arg2 == null ? "" : arg2);
|
||||
|
||||
if (goal == null) {
|
||||
sender.sendMessage(ChatUtils.LINE);
|
||||
sender.sendMessage(ChatColor.GOLD + "Goal Selection Types" + extra);
|
||||
Arrays.stream(EnumTargetGoal.values()).forEach(g -> sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + g.name().replace("_", "").toLowerCase()
|
||||
+ ChatUtils.BULLET_FORMATTED + g.description()));
|
||||
sender.sendMessage(ChatUtils.LINE);
|
||||
return;
|
||||
}
|
||||
|
||||
agent.setTargetType(goal);
|
||||
|
||||
sender.sendMessage("The global bot goal has been set to " + ChatColor.BLUE + goal.name() + ChatColor.RESET + ".");
|
||||
}
|
||||
|
||||
public List<String> optionsAutofill(CommandSender sender, String[] args) {
|
||||
@Autofill
|
||||
public List<String> settingsAutofill(CommandSender sender, String[] args) {
|
||||
List<String> output = new ArrayList<>();
|
||||
|
||||
// More settings:
|
||||
// setitem
|
||||
// tpall
|
||||
// tprandom
|
||||
// hidenametags or nametags <show/hide>
|
||||
// sitall
|
||||
// lookall
|
||||
|
||||
if (args.length == 2) {
|
||||
output.add("setgoal");
|
||||
output.add("setitem");
|
||||
output.add("tpall");
|
||||
output.add("tprandom");
|
||||
output.add("hidenametags");
|
||||
output.add("sitall");
|
||||
output.add("lookall");
|
||||
}
|
||||
|
||||
else if (args.length == 3) {
|
||||
if (args[1].equalsIgnoreCase("setgoal")) {
|
||||
Arrays.stream(EnumTargetGoal.values()).forEach(goal -> output.add(goal.name().replace("_", "").toLowerCase()));
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
Reference in New Issue
Block a user