Merge branch 'HorseNuggets:master' into master

This commit is contained in:
Legit4K
2021-08-25 01:58:21 +01:00
committed by GitHub
49 changed files with 646 additions and 323 deletions

View File

@@ -60,12 +60,6 @@
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version> <version>1.16.4-R0.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.jonahseguin</groupId>
<artifactId>drink</artifactId>
<version>1.0.2</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -1,88 +0,0 @@
package net.nuggetmc.ai.command;
import com.jonahseguin.drink.Drink;
import com.jonahseguin.drink.annotation.Command;
import com.jonahseguin.drink.command.DrinkCommandService;
import com.jonahseguin.drink.utils.ChatUtils;
import net.nuggetmc.ai.TerminatorPlus;
import net.nuggetmc.ai.command.commands.AICommand;
import net.nuggetmc.ai.command.commands.BotCommand;
import net.nuggetmc.ai.command.commands.MainCommand;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class CommandHandler {
private final TerminatorPlus plugin;
private static final String MANAGE_PERMISSION = "terminatorplus.manage";
private final DrinkCommandService drink;
private final Map<Class<? extends CommandInstance>, List<String>> help;
private final Map<String, CommandInstance> commandMap;
public CommandHandler(TerminatorPlus plugin) {
this.plugin = plugin;
this.drink = (DrinkCommandService) Drink.get(plugin);
this.help = new HashMap<>();
this.commandMap = new HashMap<>();
this.registerCommands();
this.drink.registerCommands();
this.commandMap.values().forEach(CommandInstance::onLoad);
}
private void registerCommands() {
registerCommand(new MainCommand(this, drink), "terminatorplus");
registerCommand(new BotCommand(this), "bot", "npc");
registerCommand(new AICommand(this), "ai");
}
private void registerCommand(@Nonnull CommandInstance handler, @Nonnull String name, @Nullable String... aliases) {
handler.setName(name);
commandMap.put(name, handler);
drink.register(handler, MANAGE_PERMISSION, name, aliases);
setHelp(handler.getClass());
}
public CommandInstance getCommand(String name) {
return commandMap.get(name);
}
public void sendRootInfo(CommandInstance commandInstance, CommandSender sender) {
sender.sendMessage(ChatUtils.LINE);
sender.sendMessage(ChatColor.GOLD + plugin.getName() + ChatUtils.BULLET_FORMATTED + ChatColor.GRAY
+ "[" + ChatColor.YELLOW + "/" + commandInstance.getName() + ChatColor.GRAY + "]");
help.get(commandInstance.getClass()).forEach(sender::sendMessage);
sender.sendMessage(ChatUtils.LINE);
}
private void setHelp(Class<? extends CommandInstance> cls) {
help.put(cls, getUsage(cls));
}
private List<String> getUsage(Class<? extends CommandInstance> cls) {
String rootName = getRootName(cls);
return getSubCommands(cls).stream().map(c -> c.getAnnotation(Command.class)).filter(Command::visible).map(c ->
ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "/" + rootName + " " + c.name() + ChatUtils.BULLET_FORMATTED
+ ChatColor.RESET + c.desc()).sorted().collect(Collectors.toList());
}
private String getRootName(Class<? extends CommandInstance> cls) {
return drink.getCommands().entrySet().stream()
.filter(c -> c.getValue().getObject().getClass().isAssignableFrom(cls)).map(Map.Entry::getKey).findFirst().orElse(null);
}
private List<Method> getSubCommands(Class<? extends CommandInstance> cls) {
return Arrays.stream(cls.getDeclaredMethods()).filter(m -> m.isAnnotationPresent(Command.class) && !m.getAnnotation(Command.class).name().isEmpty()).collect(Collectors.toList());
}
}

View File

@@ -1,26 +0,0 @@
package net.nuggetmc.ai.command;
public abstract class CommandInstance {
private String name;
protected final CommandHandler commandHandler;
public CommandInstance(CommandHandler commandHandler) {
this.commandHandler = commandHandler;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public CommandHandler getCommandHandler() {
return commandHandler;
}
protected void onLoad() { }
}

View File

@@ -1,7 +1,7 @@
package net.nuggetmc.ai; package net.nuggetmc.tplus;
import net.nuggetmc.ai.bot.BotManager; import net.nuggetmc.tplus.bot.BotManager;
import net.nuggetmc.ai.command.CommandHandler; import net.nuggetmc.tplus.command.CommandHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.bot; package net.nuggetmc.tplus.bot;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.datafixers.util.Pair; import com.mojang.datafixers.util.Pair;
@@ -6,13 +6,13 @@ import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener; import io.netty.util.concurrent.GenericFutureListener;
import net.minecraft.server.v1_16_R3.Chunk; import net.minecraft.server.v1_16_R3.Chunk;
import net.minecraft.server.v1_16_R3.*; import net.minecraft.server.v1_16_R3.*;
import net.nuggetmc.ai.TerminatorPlus; import net.nuggetmc.tplus.TerminatorPlus;
import net.nuggetmc.ai.bot.agent.Agent; import net.nuggetmc.tplus.bot.agent.Agent;
import net.nuggetmc.ai.bot.agent.legacyagent.ai.NeuralNetwork; import net.nuggetmc.tplus.bot.agent.legacyagent.ai.NeuralNetwork;
import net.nuggetmc.ai.bot.event.BotDamageByPlayerEvent; import net.nuggetmc.tplus.bot.event.BotDamageByPlayerEvent;
import net.nuggetmc.ai.bot.event.BotFallDamageEvent; import net.nuggetmc.tplus.bot.event.BotFallDamageEvent;
import net.nuggetmc.ai.bot.event.BotKilledByPlayerEvent; import net.nuggetmc.tplus.bot.event.BotKilledByPlayerEvent;
import net.nuggetmc.ai.utils.*; import net.nuggetmc.tplus.utils.*;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.SoundCategory; import org.bukkit.SoundCategory;
import org.bukkit.World; import org.bukkit.World;
@@ -103,7 +103,7 @@ public class Bot extends EntityPlayer {
UUID uuid = BotUtils.randomSteveUUID(); UUID uuid = BotUtils.randomSteveUUID();
CustomGameProfile profile = new CustomGameProfile(uuid, StringUtilities.trim16(name), skin); CustomGameProfile profile = new CustomGameProfile(uuid, ChatUtils.trim16(name), skin);
PlayerInteractManager interactManager = new PlayerInteractManager(nmsWorld); PlayerInteractManager interactManager = new PlayerInteractManager(nmsWorld);
Bot bot = new Bot(nmsServer, nmsWorld, profile, interactManager); Bot bot = new Bot(nmsServer, nmsWorld, profile, interactManager);

View File

@@ -1,11 +1,11 @@
package net.nuggetmc.ai.bot; package net.nuggetmc.tplus.bot;
import net.minecraft.server.v1_16_R3.PlayerConnection; import net.minecraft.server.v1_16_R3.PlayerConnection;
import net.nuggetmc.ai.bot.agent.Agent; import net.nuggetmc.tplus.bot.agent.Agent;
import net.nuggetmc.ai.bot.agent.legacyagent.LegacyAgent; import net.nuggetmc.tplus.bot.agent.legacyagent.LegacyAgent;
import net.nuggetmc.ai.bot.agent.legacyagent.ai.NeuralNetwork; import net.nuggetmc.tplus.bot.agent.legacyagent.ai.NeuralNetwork;
import net.nuggetmc.ai.bot.event.BotDeathEvent; import net.nuggetmc.tplus.bot.event.BotDeathEvent;
import net.nuggetmc.ai.utils.MojangAPI; import net.nuggetmc.tplus.utils.MojangAPI;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@@ -1,8 +1,8 @@
package net.nuggetmc.ai.bot; package net.nuggetmc.tplus.bot;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import net.nuggetmc.ai.utils.MojangAPI; import net.nuggetmc.tplus.utils.MojangAPI;
import java.util.UUID; import java.util.UUID;

View File

@@ -1,12 +1,12 @@
package net.nuggetmc.ai.bot.agent; package net.nuggetmc.tplus.bot.agent;
import net.nuggetmc.ai.TerminatorPlus; import net.nuggetmc.tplus.TerminatorPlus;
import net.nuggetmc.ai.bot.Bot; import net.nuggetmc.tplus.bot.Bot;
import net.nuggetmc.ai.bot.BotManager; import net.nuggetmc.tplus.bot.BotManager;
import net.nuggetmc.ai.bot.event.BotDamageByPlayerEvent; import net.nuggetmc.tplus.bot.event.BotDamageByPlayerEvent;
import net.nuggetmc.ai.bot.event.BotDeathEvent; import net.nuggetmc.tplus.bot.event.BotDeathEvent;
import net.nuggetmc.ai.bot.event.BotFallDamageEvent; import net.nuggetmc.tplus.bot.event.BotFallDamageEvent;
import net.nuggetmc.ai.bot.event.BotKilledByPlayerEvent; import net.nuggetmc.tplus.bot.event.BotKilledByPlayerEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;

View File

@@ -1,10 +1,10 @@
package net.nuggetmc.ai.bot.agent.botagent; package net.nuggetmc.tplus.bot.agent.botagent;
import net.nuggetmc.ai.bot.Bot; import net.nuggetmc.tplus.bot.Bot;
import net.nuggetmc.ai.bot.BotManager; import net.nuggetmc.tplus.bot.BotManager;
import net.nuggetmc.ai.bot.agent.Agent; import net.nuggetmc.tplus.bot.agent.Agent;
import net.nuggetmc.ai.utils.MathUtils; import net.nuggetmc.tplus.utils.MathUtils;
import net.nuggetmc.ai.utils.PlayerUtils; import net.nuggetmc.tplus.utils.PlayerUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@@ -1,6 +1,6 @@
package net.nuggetmc.ai.bot.agent.botagent; package net.nuggetmc.tplus.bot.agent.botagent;
import net.nuggetmc.ai.bot.Bot; import net.nuggetmc.tplus.bot.Bot;
import org.bukkit.Location; import org.bukkit.Location;
public class BotSituation { public class BotSituation {

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.bot.agent.botagent; package net.nuggetmc.tplus.bot.agent.botagent;
public enum VerticalDisplacement { public enum VerticalDisplacement {
AT, AT,

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.bot.agent.legacyagent; package net.nuggetmc.tplus.bot.agent.legacyagent;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View File

@@ -1,18 +1,18 @@
package net.nuggetmc.ai.bot.agent.legacyagent; package net.nuggetmc.tplus.bot.agent.legacyagent;
import net.minecraft.server.v1_16_R3.BlockPosition; import net.minecraft.server.v1_16_R3.BlockPosition;
import net.minecraft.server.v1_16_R3.PacketPlayOutBlockBreakAnimation; import net.minecraft.server.v1_16_R3.PacketPlayOutBlockBreakAnimation;
import net.nuggetmc.ai.bot.Bot; import net.nuggetmc.tplus.bot.Bot;
import net.nuggetmc.ai.bot.BotManager; import net.nuggetmc.tplus.bot.BotManager;
import net.nuggetmc.ai.bot.agent.Agent; import net.nuggetmc.tplus.bot.agent.Agent;
import net.nuggetmc.ai.bot.agent.legacyagent.ai.BotData; import net.nuggetmc.tplus.bot.agent.legacyagent.ai.BotData;
import net.nuggetmc.ai.bot.agent.legacyagent.ai.BotNode; import net.nuggetmc.tplus.bot.agent.legacyagent.ai.BotNode;
import net.nuggetmc.ai.bot.agent.legacyagent.ai.NeuralNetwork; import net.nuggetmc.tplus.bot.agent.legacyagent.ai.NeuralNetwork;
import net.nuggetmc.ai.bot.event.BotDamageByPlayerEvent; import net.nuggetmc.tplus.bot.event.BotDamageByPlayerEvent;
import net.nuggetmc.ai.bot.event.BotDeathEvent; import net.nuggetmc.tplus.bot.event.BotDeathEvent;
import net.nuggetmc.ai.bot.event.BotFallDamageEvent; import net.nuggetmc.tplus.bot.event.BotFallDamageEvent;
import net.nuggetmc.ai.utils.MathUtils; import net.nuggetmc.tplus.utils.MathUtils;
import net.nuggetmc.ai.utils.PlayerUtils; import net.nuggetmc.tplus.utils.PlayerUtils;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;

View File

@@ -1,8 +1,7 @@
package net.nuggetmc.ai.bot.agent.legacyagent; package net.nuggetmc.tplus.bot.agent.legacyagent;
import net.nuggetmc.ai.TerminatorPlus; import net.nuggetmc.tplus.TerminatorPlus;
import net.nuggetmc.ai.bot.Bot; import net.nuggetmc.tplus.bot.Bot;
import net.nuggetmc.ai.utils.Debugger;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.bot.agent.legacyagent; package net.nuggetmc.tplus.bot.agent.legacyagent;
import org.bukkit.Material; import org.bukkit.Material;

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.bot.agent.legacyagent; package net.nuggetmc.tplus.bot.agent.legacyagent;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.bot.agent.legacyagent; package net.nuggetmc.tplus.bot.agent.legacyagent;
import org.bukkit.Material; import org.bukkit.Material;

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.bot.agent.legacyagent; package net.nuggetmc.tplus.bot.agent.legacyagent;
import net.minecraft.server.v1_16_R3.*; import net.minecraft.server.v1_16_R3.*;
import org.bukkit.Location; import org.bukkit.Location;

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.bot.agent.legacyagent; package net.nuggetmc.tplus.bot.agent.legacyagent;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.bot.agent.legacyagent.ai; package net.nuggetmc.tplus.bot.agent.legacyagent.ai;
public enum ActivationType { public enum ActivationType {
TANH, TANH,

View File

@@ -1,7 +1,7 @@
package net.nuggetmc.ai.bot.agent.legacyagent.ai; package net.nuggetmc.tplus.bot.agent.legacyagent.ai;
import net.nuggetmc.ai.bot.Bot; import net.nuggetmc.tplus.bot.Bot;
import net.nuggetmc.ai.utils.MathUtils; import net.nuggetmc.tplus.utils.MathUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.bot.agent.legacyagent.ai; package net.nuggetmc.tplus.bot.agent.legacyagent.ai;
public enum BotDataType { public enum BotDataType {
CRITICAL_HEALTH("h"), CRITICAL_HEALTH("h"),

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.bot.agent.legacyagent.ai; package net.nuggetmc.tplus.bot.agent.legacyagent.ai;
public enum BotNode { public enum BotNode {
BLOCK, // block (can't attack while blocking) BLOCK, // block (can't attack while blocking)

View File

@@ -1,16 +1,16 @@
package net.nuggetmc.ai.bot.agent.legacyagent.ai; package net.nuggetmc.tplus.bot.agent.legacyagent.ai;
import com.jonahseguin.drink.utils.ChatUtils;
import net.minecraft.server.v1_16_R3.EntityLiving; import net.minecraft.server.v1_16_R3.EntityLiving;
import net.nuggetmc.ai.TerminatorPlus; import net.nuggetmc.tplus.TerminatorPlus;
import net.nuggetmc.ai.bot.Bot; import net.nuggetmc.tplus.bot.Bot;
import net.nuggetmc.ai.bot.BotManager; import net.nuggetmc.tplus.bot.BotManager;
import net.nuggetmc.ai.bot.agent.legacyagent.EnumTargetGoal; import net.nuggetmc.tplus.bot.agent.legacyagent.EnumTargetGoal;
import net.nuggetmc.ai.bot.agent.legacyagent.LegacyAgent; import net.nuggetmc.tplus.bot.agent.legacyagent.LegacyAgent;
import net.nuggetmc.ai.command.commands.AICommand; import net.nuggetmc.tplus.command.commands.AICommand;
import net.nuggetmc.ai.utils.MathUtils; import net.nuggetmc.tplus.utils.ChatUtils;
import net.nuggetmc.ai.utils.MojangAPI; import net.nuggetmc.tplus.utils.MathUtils;
import net.nuggetmc.ai.utils.PlayerUtils; import net.nuggetmc.tplus.utils.MojangAPI;
import net.nuggetmc.tplus.utils.PlayerUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;

View File

@@ -1,8 +1,8 @@
package net.nuggetmc.ai.bot.agent.legacyagent.ai; package net.nuggetmc.tplus.bot.agent.legacyagent.ai;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import net.nuggetmc.ai.utils.MathUtils; import net.nuggetmc.tplus.utils.MathUtils;
import net.nuggetmc.ai.utils.StringUtilities; import net.nuggetmc.tplus.utils.ChatUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import java.util.*; import java.util.*;
@@ -73,7 +73,7 @@ public class NeuralNetwork {
public String output() { public String output() {
List<String> strings = new ArrayList<>(); List<String> strings = new ArrayList<>();
nodes.forEach((type, node) -> strings.add(type.name().toLowerCase() + "=" + (node.check() ? StringUtilities.ON + "1" : StringUtilities.OFF + "0") + ChatColor.RESET)); nodes.forEach((type, node) -> strings.add(type.name().toLowerCase() + "=" + (node.check() ? ChatUtils.ON + "1" : ChatUtils.OFF + "0") + ChatColor.RESET));
Collections.sort(strings); Collections.sort(strings);
return "[" + StringUtils.join(strings, ", ") + "]"; return "[" + StringUtils.join(strings, ", ") + "]";
} }

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.bot.agent.legacyagent.ai; package net.nuggetmc.tplus.bot.agent.legacyagent.ai;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;

View File

@@ -1,6 +1,6 @@
package net.nuggetmc.ai.bot.event; package net.nuggetmc.tplus.bot.event;
import net.nuggetmc.ai.bot.Bot; import net.nuggetmc.tplus.bot.Bot;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class BotDamageByPlayerEvent { public class BotDamageByPlayerEvent {

View File

@@ -1,6 +1,6 @@
package net.nuggetmc.ai.bot.event; package net.nuggetmc.tplus.bot.event;
import net.nuggetmc.ai.bot.Bot; import net.nuggetmc.tplus.bot.Bot;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
public class BotDeathEvent extends PlayerDeathEvent { public class BotDeathEvent extends PlayerDeathEvent {

View File

@@ -1,6 +1,6 @@
package net.nuggetmc.ai.bot.event; package net.nuggetmc.tplus.bot.event;
import net.nuggetmc.ai.bot.Bot; import net.nuggetmc.tplus.bot.Bot;
public class BotFallDamageEvent { public class BotFallDamageEvent {

View File

@@ -1,6 +1,6 @@
package net.nuggetmc.ai.bot.event; package net.nuggetmc.tplus.bot.event;
import net.nuggetmc.ai.bot.Bot; import net.nuggetmc.tplus.bot.Bot;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class BotKilledByPlayerEvent { public class BotKilledByPlayerEvent {

View File

@@ -0,0 +1,139 @@
package net.nuggetmc.tplus.command;
import com.google.common.collect.Sets;
import net.nuggetmc.tplus.TerminatorPlus;
import net.nuggetmc.tplus.command.annotation.Command;
import net.nuggetmc.tplus.command.annotation.Require;
import net.nuggetmc.tplus.command.commands.AICommand;
import net.nuggetmc.tplus.command.commands.BotCommand;
import net.nuggetmc.tplus.command.commands.MainCommand;
import net.nuggetmc.tplus.utils.ChatUtils;
import net.nuggetmc.tplus.utils.Debugger;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class CommandHandler {
private final TerminatorPlus plugin;
private final Map<String, List<String>> help;
private final Map<String, CommandInstance> commandMap;
public CommandHandler(TerminatorPlus plugin) {
this.plugin = plugin;
this.help = new HashMap<>();
this.commandMap = new HashMap<>();
this.registerCommands();
}
public Map<String, CommandInstance> getCommands() {
return commandMap;
}
private void registerCommands() {
registerCommands(
new MainCommand(this, "terminatorplus", "The TerminatorPlus main command.", "tplus"),
new BotCommand(this, "bot", "The root command for bot management.", "npc"),
new AICommand(this, "ai", "The root command for bot AI training.")
);
}
private void registerCommands(CommandInstance... commands) {
String fallback = plugin.getName().toLowerCase();
SimpleCommandMap bukkitCommandMap = ((CraftServer) plugin.getServer()).getCommandMap();
for (CommandInstance command : commands) {
commandMap.put(command.getName(), command);
bukkitCommandMap.register(fallback, command);
Method[] methods = command.getClass().getDeclaredMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(Command.class)) {
try {
method.setAccessible(true);
} catch (SecurityException e) {
Debugger.log("Failed to access method " + method.getName() + ".");
continue;
}
Command cmd = method.getAnnotation(Command.class);
String perm = "";
if (method.isAnnotationPresent(Require.class)) {
Require require = method.getAnnotation(Require.class);
perm = require.value();
}
String autofillName = cmd.autofill();
Method autofiller = null;
if (!autofillName.isEmpty()) {
for (Method m : methods) {
if (m.getName().equals(autofillName)) {
autofiller = m;
}
}
}
String methodName = cmd.name();
CommandMethod commandMethod = new CommandMethod(methodName, Sets.newHashSet(cmd.aliases()), cmd.desc(), cmd.usage(), perm, command, method, autofiller);
command.addMethod(methodName, commandMethod);
}
}
setHelp(command);
}
}
public CommandInstance getCommand(String name) {
return commandMap.get(name);
}
public void sendRootInfo(CommandInstance commandInstance, CommandSender sender) {
sender.sendMessage(ChatUtils.LINE);
sender.sendMessage(ChatColor.GOLD + plugin.getName() + ChatUtils.BULLET_FORMATTED + ChatColor.GRAY
+ "[" + ChatColor.YELLOW + "/" + commandInstance.getName() + ChatColor.GRAY + "]");
help.get(commandInstance.getName()).forEach(sender::sendMessage);
sender.sendMessage(ChatUtils.LINE);
}
private void setHelp(CommandInstance commandInstance) {
help.put(commandInstance.getName(), getCommandInfo(commandInstance));
}
/*
* TODO
* Eventually, this will be a LOT better, basically not having to have this method
* at all (kind of like Drink), and even better, we won't even need a "usage" field
* in the @Command annotation, and can create the usage message from the method parameters.
*/
public void sendUsage(CommandSender sender, CommandInstance command, String usage) {
sender.sendMessage("Command Usage: " + ChatColor.YELLOW + "/" + command.getName() + " " + usage);
}
private List<String> getCommandInfo(CommandInstance commandInstance) {
List<String> output = new ArrayList<>();
for (CommandMethod method : commandInstance.getMethods().values()) {
if (!method.getMethod().getAnnotation(Command.class).visible() || method.getName().isEmpty()) {
continue;
}
output.add(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "/" + commandInstance.getName() + " " + method.getName()
+ ChatUtils.BULLET_FORMATTED + method.getDescription());
}
return output.stream().sorted().collect(Collectors.toList());
}
}

View File

@@ -0,0 +1,97 @@
package net.nuggetmc.tplus.command;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.defaults.BukkitCommand;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import java.util.stream.Collectors;
public abstract class CommandInstance extends BukkitCommand {
protected final CommandHandler commandHandler;
private final Map<String, CommandMethod> methods;
private static final String MANAGE_PERMISSION = "terminatorplus.manage";
public CommandInstance(CommandHandler handler, String name, String description, @Nullable String... aliases) {
super(name, description, "", aliases == null ? new ArrayList<>() : Arrays.asList(aliases));
this.commandHandler = handler;
this.methods = new HashMap<>();
}
public Map<String, CommandMethod> getMethods() {
return methods;
}
protected void addMethod(String name, CommandMethod method) {
methods.put(name, method);
}
@Override
public boolean execute(@Nonnull CommandSender sender, @Nonnull String label, @Nonnull String[] args) {
if (!sender.hasPermission(MANAGE_PERMISSION)) {
return false;
}
CommandMethod method;
if (args.length == 0) {
method = methods.get("");
} else if (methods.containsKey(args[0])) {
method = methods.get(args[0]);
} else {
method = methods.get("");
}
if (method == null) {
sender.sendMessage(ChatColor.RED + "There is no root command present for the " + ChatColor.YELLOW + getName() + ChatColor.RED + " command.");
return true;
}
List<String> arguments = new ArrayList<>(Arrays.asList(args));
if (arguments.size() > 0) {
arguments.remove(0);
}
try {
method.getMethod().invoke(method.getHandler(), sender, arguments);
} catch (InvocationTargetException | IllegalAccessException e) {
sender.sendMessage(ChatColor.RED + "Failed to perform command.");
e.printStackTrace();
}
return true;
}
@Override
@Nonnull
@SuppressWarnings("unchecked")
public List<String> tabComplete(@Nonnull CommandSender sender, @Nonnull String label, @Nonnull String[] args) {
if (args.length == 1) {
return methods.keySet().stream().filter(c -> !c.isEmpty()).collect(Collectors.toList());
}
if (args.length > 1) {
CommandMethod commandMethod = methods.get(args[0]);
Method autofiller = commandMethod.getAutofiller();
if (autofiller != null) {
try {
return (List<String>) autofiller.invoke(commandMethod.getHandler(), sender, args);
} catch (InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
}
}
return new ArrayList<>();
}
}

View File

@@ -0,0 +1,66 @@
package net.nuggetmc.tplus.command;
import java.lang.reflect.Method;
import java.util.Set;
public class CommandMethod {
private final String name;
private final Set<String> aliases;
private final String description;
private final String usage;
private final String permission;
private final CommandInstance handler;
private final Method method;
private final Method autofiller;
public CommandMethod(String name, Set<String> aliases, String description, String usage, String permission, CommandInstance handler, Method method, Method autofiller) {
this.name = name;
this.aliases = aliases;
this.description = description;
this.usage = usage;
this.permission = permission;
this.handler = handler;
this.method = method;
this.autofiller = autofiller;
}
public String getName() {
return name;
}
public Set<String> getAliases() {
return aliases;
}
public String getDescription() {
return description;
}
public String getUsage() {
return usage;
}
public String getPermission() {
return permission;
}
public CommandInstance getHandler() {
return handler;
}
public Method getMethod() {
return method;
}
public Method getAutofiller() {
return autofiller;
}
@Override
public String toString() {
return getClass().getSimpleName() + "{name=\"" + name + "\",aliases=" + aliases + ",description=\"" + description + "\",usage=\"" + usage + "\",permission=\"" + permission + "\",method=" + method + ",autofiller=" + autofiller + "}";
}
}

View File

@@ -0,0 +1,4 @@
package net.nuggetmc.tplus.command.annotation;
public @interface Autofill {
}

View File

@@ -0,0 +1,22 @@
package net.nuggetmc.tplus.command.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface Command {
String name() default "";
String[] aliases() default {};
String desc() default "Blank description.";
String usage() default "";
String autofill() default "";
boolean visible() default true;
}

View File

@@ -0,0 +1,12 @@
package net.nuggetmc.tplus.command.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface Require {
String value();
}

View File

@@ -1,18 +1,16 @@
package net.nuggetmc.ai.command.commands; package net.nuggetmc.tplus.command.commands;
import com.jonahseguin.drink.annotation.Autofill; import net.nuggetmc.tplus.TerminatorPlus;
import com.jonahseguin.drink.annotation.Command; import net.nuggetmc.tplus.bot.Bot;
import com.jonahseguin.drink.annotation.OptArg; import net.nuggetmc.tplus.bot.BotManager;
import com.jonahseguin.drink.annotation.Sender; import net.nuggetmc.tplus.bot.agent.legacyagent.ai.IntelligenceAgent;
import com.jonahseguin.drink.utils.ChatUtils; import net.nuggetmc.tplus.bot.agent.legacyagent.ai.NeuralNetwork;
import net.nuggetmc.ai.TerminatorPlus; import net.nuggetmc.tplus.command.CommandHandler;
import net.nuggetmc.ai.bot.Bot; import net.nuggetmc.tplus.command.CommandInstance;
import net.nuggetmc.ai.bot.BotManager; import net.nuggetmc.tplus.command.annotation.Autofill;
import net.nuggetmc.ai.bot.agent.legacyagent.ai.IntelligenceAgent; import net.nuggetmc.tplus.command.annotation.Command;
import net.nuggetmc.ai.bot.agent.legacyagent.ai.NeuralNetwork; import net.nuggetmc.tplus.utils.ChatUtils;
import net.nuggetmc.ai.command.CommandHandler; import net.nuggetmc.tplus.utils.MathUtils;
import net.nuggetmc.ai.command.CommandInstance;
import net.nuggetmc.ai.utils.MathUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@@ -36,18 +34,16 @@ public class AICommand extends CommandInstance {
private IntelligenceAgent agent; private IntelligenceAgent agent;
public AICommand(CommandHandler commandHandler) { public AICommand(CommandHandler handler, String name, String description, String... aliases) {
super(commandHandler); super(handler, name, description, aliases);
this.plugin = TerminatorPlus.getInstance(); this.plugin = TerminatorPlus.getInstance();
this.manager = plugin.getManager(); this.manager = plugin.getManager();
this.scheduler = Bukkit.getScheduler(); this.scheduler = Bukkit.getScheduler();
} }
@Command( @Command
desc = "The root command for bot AI training." public void root(CommandSender sender, List<String> args) {
)
public void root(@Sender CommandSender sender) {
commandHandler.sendRootInfo(this, sender); commandHandler.sendRootInfo(this, sender);
} }
@@ -56,8 +52,34 @@ public class AICommand extends CommandInstance {
desc = "Create bots with random neural networks, collecting feed data.", desc = "Create bots with random neural networks, collecting feed data.",
usage = "<amount> <name> [skin]" usage = "<amount> <name> [skin]"
) )
public void random(@Sender Player sender, int n, String name, @OptArg String skin) { public void random(CommandSender sender, List<String> args) {
manager.createBots(sender, name, skin, n, NeuralNetwork.RANDOM); if (!(sender instanceof Player)) {
return;
}
if (args.size() < 2) {
commandHandler.sendUsage(sender, this, "random <amount> <name> [skin]");
return;
}
String skin;
if (args.size() < 3) {
skin = null;
} else {
skin = args.get(2);
}
int n;
try {
n = Integer.parseInt(args.get(0));
} catch (NumberFormatException e) {
sender.sendMessage("The amount must be an integer!");
return;
}
manager.createBots((Player) sender, args.get(1), skin, n, NeuralNetwork.RANDOM);
} }
@Command( @Command(
@@ -65,22 +87,44 @@ public class AICommand extends CommandInstance {
desc = "Begin an AI training session.", desc = "Begin an AI training session.",
usage = "<population-size> <name> [skin]" usage = "<population-size> <name> [skin]"
) )
public void reinforcement(@Sender Player sender, int populationSize, String name, @OptArg String skin) { public void reinforcement(CommandSender sender, List<String> args) {
// automatically do the -% thing, store values in map if (!(sender instanceof Player)) {
// for now only 1 session at a time, have a set of commandsenders to see output, including console
// automatically reset all existing bots at the start, set targets towards each other
// also in the future make this a subcommand, with /ai reinforcement defaults, /ai reinforcement begin/start
// or just make /ai defaults with reinforcement options
if (agent != null) {
sender.sendMessage("A session is already active.");
return; return;
} }
sender.sendMessage("Starting a new session..."); Player player = (Player) sender;
agent = new IntelligenceAgent(this, populationSize, name, skin); if (args.size() < 2) {
agent.addUser(sender); commandHandler.sendUsage(player, this, "reinforcement <amount> <name> [skin]");
return;
}
String skin;
if (args.size() < 3) {
skin = null;
} else {
skin = args.get(2);
}
int populationSize;
try {
populationSize = Integer.parseInt(args.get(0));
} catch (NumberFormatException e) {
player.sendMessage("The population size must be an integer!");
return;
}
if (agent != null) {
player.sendMessage("A session is already active.");
return;
}
player.sendMessage("Starting a new session...");
agent = new IntelligenceAgent(this, populationSize, args.get(1), skin);
agent.addUser(player);
} }
public IntelligenceAgent getSession() { public IntelligenceAgent getSession() {
@@ -91,7 +135,7 @@ public class AICommand extends CommandInstance {
name = "stop", name = "stop",
desc = "End a currently running AI training session." desc = "End a currently running AI training session."
) )
public void stop(@Sender CommandSender sender) { public void stop(CommandSender sender, List<String> args) {
if (agent == null) { if (agent == null) {
sender.sendMessage("No session is currently active."); sender.sendMessage("No session is currently active.");
return; return;
@@ -121,7 +165,14 @@ public class AICommand extends CommandInstance {
usage = "<name>", usage = "<name>",
autofill = "infoAutofill" autofill = "infoAutofill"
) )
public void info(@Sender CommandSender sender, String name) { public void info(CommandSender sender, List<String> args) {
if (args.isEmpty()) {
commandHandler.sendUsage(sender, this, "info <name>");
return;
}
String name = args.get(0);
sender.sendMessage("Processing request..."); sender.sendMessage("Processing request...");
scheduler.runTaskAsynchronously(plugin, () -> { scheduler.runTaskAsynchronously(plugin, () -> {

View File

@@ -1,16 +1,16 @@
package net.nuggetmc.ai.command.commands; package net.nuggetmc.tplus.command.commands;
import com.jonahseguin.drink.annotation.*; import net.nuggetmc.tplus.TerminatorPlus;
import com.jonahseguin.drink.utils.ChatUtils; import net.nuggetmc.tplus.bot.Bot;
import net.nuggetmc.ai.TerminatorPlus; import net.nuggetmc.tplus.bot.BotManager;
import net.nuggetmc.ai.bot.Bot; import net.nuggetmc.tplus.bot.agent.legacyagent.EnumTargetGoal;
import net.nuggetmc.ai.bot.BotManager; import net.nuggetmc.tplus.bot.agent.legacyagent.LegacyAgent;
import net.nuggetmc.ai.bot.agent.legacyagent.EnumTargetGoal; import net.nuggetmc.tplus.command.CommandHandler;
import net.nuggetmc.ai.bot.agent.legacyagent.LegacyAgent; import net.nuggetmc.tplus.command.CommandInstance;
import net.nuggetmc.ai.command.CommandHandler; import net.nuggetmc.tplus.command.annotation.Autofill;
import net.nuggetmc.ai.command.CommandInstance; import net.nuggetmc.tplus.command.annotation.Command;
import net.nuggetmc.ai.utils.Debugger; import net.nuggetmc.tplus.utils.ChatUtils;
import net.nuggetmc.ai.utils.StringUtilities; import net.nuggetmc.tplus.utils.Debugger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
@@ -35,8 +35,8 @@ public class BotCommand extends CommandInstance {
private AICommand aiManager; private AICommand aiManager;
public BotCommand(CommandHandler commandHandler) { public BotCommand(CommandHandler handler, String name, String description, String... aliases) {
super(commandHandler); super(handler, name, description, aliases);
this.handler = commandHandler; this.handler = commandHandler;
this.plugin = TerminatorPlus.getInstance(); this.plugin = TerminatorPlus.getInstance();
@@ -46,15 +46,8 @@ public class BotCommand extends CommandInstance {
this.formatter = new DecimalFormat("0.##"); this.formatter = new DecimalFormat("0.##");
} }
@Override @Command
public void onLoad() { public void root(CommandSender sender, List<String> args) {
this.aiManager = (AICommand) handler.getCommand("ai");
}
@Command(
desc = "The root command for bot management."
)
public void root(@Sender CommandSender sender) {
commandHandler.sendRootInfo(this, sender); commandHandler.sendRootInfo(this, sender);
} }
@@ -63,8 +56,25 @@ public class BotCommand extends CommandInstance {
desc = "Create a bot.", desc = "Create a bot.",
usage = "<name> [skin]" usage = "<name> [skin]"
) )
public void create(@Sender Player sender, String name, @OptArg String skin) { public void create(CommandSender sender, List<String> args) {
manager.createBots(sender, name, skin, 1); if (!(sender instanceof Player)) {
return;
}
if (args.isEmpty()) {
commandHandler.sendUsage(sender, this, "create <name> [skin]");
return;
}
String skin;
if (args.size() < 2) {
skin = null;
} else {
skin = args.get(1);
}
manager.createBots((Player) sender, args.get(0), skin, 1);
} }
@Command( @Command(
@@ -72,8 +82,34 @@ public class BotCommand extends CommandInstance {
desc = "Create multiple bots at once.", desc = "Create multiple bots at once.",
usage = "<amount> <name> [skin]" usage = "<amount> <name> [skin]"
) )
public void multi(@Sender Player sender, int n, String name, @OptArg String skin) { public void multi(CommandSender sender, List<String> args) {
manager.createBots(sender, name, skin, n); if (!(sender instanceof Player)) {
return;
}
if (args.size() < 2) {
commandHandler.sendUsage(sender, this, "multi <amount> <name> [skin]");
return;
}
String skin;
if (args.size() < 3) {
skin = null;
} else {
skin = args.get(2);
}
int n;
try {
n = Integer.parseInt(args.get(0));
} catch (NumberFormatException e) {
sender.sendMessage("The amount must be an integer!");
return;
}
manager.createBots((Player) sender, args.get(1), skin, n);
} }
@Command( @Command(
@@ -82,7 +118,14 @@ public class BotCommand extends CommandInstance {
usage = "[name]", usage = "[name]",
autofill = "infoAutofill" autofill = "infoAutofill"
) )
public void info(@Sender CommandSender sender, @OptArg String name) { public void info(CommandSender sender, List<String> args) {
if (args.isEmpty()) {
commandHandler.sendUsage(sender, this, "info <name>");
return;
}
String name = args.get(0);
if (name == null) { if (name == null) {
sender.sendMessage(ChatColor.YELLOW + "Bot GUI coming soon!"); sender.sendMessage(ChatColor.YELLOW + "Bot GUI coming soon!");
return; return;
@@ -140,13 +183,17 @@ public class BotCommand extends CommandInstance {
name = "reset", name = "reset",
desc = "Remove all loaded bots." desc = "Remove all loaded bots."
) )
public void reset(@Sender CommandSender sender) { public void reset(CommandSender sender, List<String> args) {
sender.sendMessage("Removing every bot..."); sender.sendMessage("Removing every bot...");
int size = manager.fetch().size(); int size = manager.fetch().size();
manager.reset(); manager.reset();
sender.sendMessage("Removed " + ChatColor.RED + StringUtilities.NUMBER_FORMAT.format(size) + ChatColor.RESET + " entit" + (size == 1 ? "y" : "ies") + "."); sender.sendMessage("Removed " + ChatColor.RED + ChatUtils.NUMBER_FORMAT.format(size) + ChatColor.RESET + " entit" + (size == 1 ? "y" : "ies") + ".");
if (aiManager.hasActiveSession()) { if (aiManager == null) {
this.aiManager = (AICommand) handler.getCommand("ai");
}
if (aiManager != null && aiManager.hasActiveSession()) {
Bukkit.dispatchCommand(sender, "ai stop"); Bukkit.dispatchCommand(sender, "ai stop");
} }
} }
@@ -157,7 +204,10 @@ public class BotCommand extends CommandInstance {
aliases = "options", aliases = "options",
autofill = "settingsAutofill" autofill = "settingsAutofill"
) )
public void settings(@Sender CommandSender sender, @OptArg String arg1, @OptArg String arg2) { public void settings(CommandSender sender, List<String> args) {
String arg1 = args.isEmpty() ? null : args.get(0);
String arg2 = args.size() < 2 ? null : args.get(1);
String extra = ChatColor.GRAY + " [" + ChatColor.YELLOW + "/bot settings" + ChatColor.GRAY + "]"; String extra = ChatColor.GRAY + " [" + ChatColor.YELLOW + "/bot settings" + ChatColor.GRAY + "]";
if (arg1 == null || !arg1.equals("setgoal")) { if (arg1 == null || !arg1.equals("setgoal")) {
@@ -215,7 +265,12 @@ public class BotCommand extends CommandInstance {
usage = "<expression>", usage = "<expression>",
visible = false visible = false
) )
public void debug(@Sender CommandSender sender, @Text String cmd) { public void debug(CommandSender sender, List<String> args) {
new Debugger(sender).execute(cmd); if (args.isEmpty()) {
commandHandler.sendUsage(sender, this, "debug <expression>");
return;
}
new Debugger(sender).execute(args.get(0));
} }
} }

View File

@@ -1,39 +1,30 @@
package net.nuggetmc.ai.command.commands; package net.nuggetmc.tplus.command.commands;
import com.jonahseguin.drink.annotation.Command;
import com.jonahseguin.drink.annotation.Sender;
import com.jonahseguin.drink.command.DrinkCommandService;
import com.jonahseguin.drink.utils.ChatUtils;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.hover.content.Text; import net.md_5.bungee.api.chat.hover.content.Text;
import net.nuggetmc.ai.TerminatorPlus; import net.nuggetmc.tplus.TerminatorPlus;
import net.nuggetmc.ai.command.CommandHandler; import net.nuggetmc.tplus.command.CommandHandler;
import net.nuggetmc.ai.command.CommandInstance; import net.nuggetmc.tplus.command.CommandInstance;
import org.bukkit.Bukkit; import net.nuggetmc.tplus.command.annotation.Command;
import net.nuggetmc.tplus.utils.ChatUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class MainCommand extends CommandInstance { import java.util.List;
private final DrinkCommandService drink; public class MainCommand extends CommandInstance {
private BaseComponent[] rootInfo; private BaseComponent[] rootInfo;
public MainCommand(CommandHandler commandHandler, DrinkCommandService drink) { public MainCommand(CommandHandler handler, String name, String description, String... aliases) {
super(commandHandler); super(handler, name, description, aliases);
this.drink = drink;
Bukkit.getScheduler().runTask(TerminatorPlus.getInstance(), this::rootInfoSetup);
} }
@Command( @Command
desc = "The TerminatorPlus main command." public void root(CommandSender sender, List<String> args) {
)
public void root(@Sender CommandSender sender) {
if (rootInfo == null) { if (rootInfo == null) {
rootInfoSetup(); rootInfoSetup();
} }
@@ -51,7 +42,7 @@ public class MainCommand extends CommandInstance {
message.append(ChatUtils.BULLET_FORMATTED + "Author" + ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "HorseNuggets\n"); message.append(ChatUtils.BULLET_FORMATTED + "Author" + ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "HorseNuggets\n");
message.append(ChatUtils.BULLET_FORMATTED + "Links" + ChatUtils.BULLET_FORMATTED); message.append(ChatUtils.BULLET_FORMATTED + "Links" + ChatUtils.BULLET_FORMATTED);
message.append(ChatColor.RED + "YouTube"); message.append(ChatColor.RED + "YouTube");
message.event(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.youtube.com/horsenuggets")); message.event(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://youtube.com/horsenuggets"));
message.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("Click to visit HorseNuggets' " + ChatColor.RED + "YouTube" + ChatColor.RESET + "!"))); message.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("Click to visit HorseNuggets' " + ChatColor.RED + "YouTube" + ChatColor.RESET + "!")));
message.append(", "); message.append(", ");
message.event((ClickEvent) null); message.event((ClickEvent) null);
@@ -64,7 +55,7 @@ public class MainCommand extends CommandInstance {
message.event((HoverEvent) null); message.event((HoverEvent) null);
message.append("\nPlugin Commands:\n"); message.append("\nPlugin Commands:\n");
drink.getCommands().forEach((name, command) -> { commandHandler.getCommands().forEach((name, command) -> {
if (!name.equalsIgnoreCase(pluginName)) { if (!name.equalsIgnoreCase(pluginName)) {
message.append(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "/" + name + ChatUtils.BULLET_FORMATTED + command.getDescription() + "\n"); message.append(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "/" + name + ChatUtils.BULLET_FORMATTED + command.getDescription() + "\n");
} }

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.command.nms; package net.nuggetmc.tplus.command.nms;
public class TPCommand { public class TPCommand {
// this class (as well as some others like "give", "effect", etc.) will listen into the PlayerCommandPreProcessEvent // this class (as well as some others like "give", "effect", etc.) will listen into the PlayerCommandPreProcessEvent

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.utils; package net.nuggetmc.tplus.utils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;

View File

@@ -1,11 +1,15 @@
package net.nuggetmc.ai.utils; package net.nuggetmc.tplus.utils;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.Locale; import java.util.Locale;
public class StringUtilities { public class ChatUtils {
public static final String LINE = ChatColor.GRAY + "------------------------------------------------";
public static final String BULLET = "";
public static final String BULLET_FORMATTED = ChatColor.GRAY + "" + ChatColor.RESET;
public static final String EXCEPTION_MESSAGE = ChatColor.RED + "An exception has occured. Please try again.";
public static final NumberFormat NUMBER_FORMAT = NumberFormat.getNumberInstance(Locale.US); public static final NumberFormat NUMBER_FORMAT = NumberFormat.getNumberInstance(Locale.US);

View File

@@ -1,13 +1,13 @@
package net.nuggetmc.ai.utils; package net.nuggetmc.tplus.utils;
import net.minecraft.server.v1_16_R3.EntityLiving; import net.minecraft.server.v1_16_R3.EntityLiving;
import net.nuggetmc.ai.TerminatorPlus; import net.nuggetmc.tplus.TerminatorPlus;
import net.nuggetmc.ai.bot.Bot; import net.nuggetmc.tplus.bot.Bot;
import net.nuggetmc.ai.bot.agent.Agent; import net.nuggetmc.tplus.bot.agent.Agent;
import net.nuggetmc.ai.bot.agent.legacyagent.LegacyAgent; import net.nuggetmc.tplus.bot.agent.legacyagent.LegacyAgent;
import net.nuggetmc.ai.bot.agent.legacyagent.ai.IntelligenceAgent; import net.nuggetmc.tplus.bot.agent.legacyagent.ai.IntelligenceAgent;
import net.nuggetmc.ai.bot.agent.legacyagent.ai.NeuralNetwork; import net.nuggetmc.tplus.bot.agent.legacyagent.ai.NeuralNetwork;
import net.nuggetmc.ai.command.commands.AICommand; import net.nuggetmc.tplus.command.commands.AICommand;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
@@ -33,7 +33,10 @@ public class Debugger {
public static void log(Object... objects) { public static void log(Object... objects) {
String[] values = formStringArray(objects); String[] values = formStringArray(objects);
Bukkit.getOnlinePlayers().stream().filter(ServerOperator::isOp).forEach(p -> p.sendMessage(PREFIX + String.join(" ", values))); String message = PREFIX + String.join(" ", values);
Bukkit.getConsoleSender().sendMessage(message);
Bukkit.getOnlinePlayers().stream().filter(ServerOperator::isOp).forEach(p -> p.sendMessage(message));
} }
private static String[] formStringArray(Object[] objects) { private static String[] formStringArray(Object[] objects) {

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.utils; package net.nuggetmc.tplus.utils;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;

View File

@@ -1,6 +1,6 @@
package net.nuggetmc.ai.utils; package net.nuggetmc.tplus.utils;
import net.nuggetmc.ai.bot.Bot; import net.nuggetmc.tplus.bot.Bot;
import org.bukkit.util.NumberConversions; import org.bukkit.util.NumberConversions;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.utils; package net.nuggetmc.tplus.utils;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;

View File

@@ -1,6 +1,6 @@
package net.nuggetmc.ai.utils; package net.nuggetmc.tplus.utils;
import net.nuggetmc.ai.TerminatorPlus; import net.nuggetmc.tplus.TerminatorPlus;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.json.simple.JSONArray; import org.json.simple.JSONArray;

View File

@@ -1,4 +1,4 @@
package net.nuggetmc.ai.utils; package net.nuggetmc.tplus.utils;
public class Singularity { public class Singularity {

View File

@@ -1,5 +1,5 @@
name: TerminatorPlus name: TerminatorPlus
main: net.nuggetmc.ai.TerminatorPlus main: net.nuggetmc.tplus.TerminatorPlus
version: 3.0-BETA version: 3.0-BETA
api-version: 1.16 api-version: 1.16
author: HorseNuggets author: HorseNuggets