command adjustments

This commit is contained in:
batchprogrammer314
2021-07-21 17:18:36 -05:00
parent 9b9f1d70a3
commit aa12ea0e71
5 changed files with 79 additions and 32 deletions

View File

@@ -3,11 +3,11 @@ 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.utils.ChatUtils;
import net.nuggetmc.ai.TerminatorPlus;
import net.nuggetmc.ai.bot.BotManager;
import net.nuggetmc.ai.command.CommandHandler;
import net.nuggetmc.ai.command.CommandInstance;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class AICommand extends CommandInstance {
@@ -23,10 +23,8 @@ public class AICommand extends CommandInstance {
@Command(
desc = "The root command for bot AI training."
)
public void root(@Sender Player sender) {
sender.sendMessage(ChatUtils.LINE);
commandHandler.getHelp(getClass()).forEach(sender::sendMessage);
sender.sendMessage(ChatUtils.LINE);
public void root(@Sender CommandSender sender) {
commandHandler.sendRootInfo(this, sender);
}
@Command(

View File

@@ -11,6 +11,7 @@ import net.nuggetmc.ai.bot.BotManager;
import net.nuggetmc.ai.command.CommandHandler;
import net.nuggetmc.ai.command.CommandInstance;
import net.nuggetmc.ai.utils.Debugger;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@@ -21,6 +22,8 @@ import org.bukkit.util.Vector;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class BotCommand extends CommandInstance {
@@ -42,10 +45,8 @@ public class BotCommand extends CommandInstance {
@Command(
desc = "The root command for bot management."
)
public void root(@Sender Player sender) {
sender.sendMessage(ChatUtils.LINE);
commandHandler.getHelp(getClass()).forEach(sender::sendMessage);
sender.sendMessage(ChatUtils.LINE);
public void root(@Sender CommandSender sender) {
commandHandler.sendRootInfo(this, sender);
}
@Command(
@@ -66,15 +67,6 @@ public class BotCommand extends CommandInstance {
manager.createBots(sender, name, skin, n);
}
@Command(
name = "debug",
desc = "Debug plugin code.",
usage = "<expression>"
)
public void debug(@Sender CommandSender sender, @Text String cmd) {
new Debugger(sender).execute(cmd);
}
@Command(
name = "info",
desc = "Information about loaded bots.",
@@ -142,4 +134,40 @@ public class BotCommand extends CommandInstance {
String formatted = NumberFormat.getNumberInstance(Locale.US).format(size);
sender.sendMessage("Removed " + ChatColor.RED + formatted + ChatColor.RESET + " entit" + (size == 1 ? "y" : "ies") + ".");
}
@Command(
name = "options",
desc = "Make changes to the global configuration file and bot-specific settings.",
aliases = "settings",
autofill = "optionsAutofill"
)
public void options(@Sender CommandSender sender) {
sender.sendMessage(ChatColor.YELLOW + "This feature is coming soon!");
}
public List<String> optionsAutofill(CommandSender sender, String[] args) {
List<String> output = new ArrayList<>();
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");
}
return output;
}
@Command(
name = "debug",
desc = "Debug plugin code.",
usage = "<expression>",
visible = false
)
public void debug(@Sender CommandSender sender, @Text String cmd) {
new Debugger(sender).execute(cmd);
}
}

View File

@@ -14,7 +14,7 @@ import net.nuggetmc.ai.command.CommandHandler;
import net.nuggetmc.ai.command.CommandInstance;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.command.CommandSender;
public class MainCommand extends CommandInstance {
@@ -33,7 +33,11 @@ public class MainCommand extends CommandInstance {
@Command(
desc = "The TerminatorPlus main command."
)
public void root(@Sender Player sender) {
public void root(@Sender CommandSender sender) {
if (rootInfo == null) {
rootInfoSetup();
}
sender.spigot().sendMessage(rootInfo);
}