code reformat
This commit is contained in:
@@ -31,6 +31,14 @@ public class TerminatorPlus extends JavaPlugin {
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isCorrectVersion() {
|
||||||
|
return correctVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMcVersion() {
|
||||||
|
return mcVersion;
|
||||||
|
}
|
||||||
|
|
||||||
public BotManagerImpl getManager() {
|
public BotManagerImpl getManager() {
|
||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
@@ -81,12 +89,4 @@ public class TerminatorPlus extends JavaPlugin {
|
|||||||
private void registerEvents(Listener... listeners) {
|
private void registerEvents(Listener... listeners) {
|
||||||
Arrays.stream(listeners).forEach(li -> this.getServer().getPluginManager().registerEvents(li, this));
|
Arrays.stream(listeners).forEach(li -> this.getServer().getPluginManager().registerEvents(li, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCorrectVersion() {
|
|
||||||
return correctVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getMcVersion() {
|
|
||||||
return mcVersion;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,11 @@ 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;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
|
||||||
import net.minecraft.network.Connection;
|
import net.minecraft.network.Connection;
|
||||||
import net.minecraft.network.PacketSendListener;
|
import net.minecraft.network.PacketSendListener;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.PacketFlow;
|
import net.minecraft.network.protocol.PacketFlow;
|
||||||
import net.minecraft.network.protocol.game.*;
|
import net.minecraft.network.protocol.game.*;
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
@@ -52,7 +50,6 @@ import org.bukkit.util.BoundingBox;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class Bot extends ServerPlayer implements Terminator {
|
public class Bot extends ServerPlayer implements Terminator {
|
||||||
|
|||||||
@@ -24,13 +24,11 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public abstract class CommandInstance extends BukkitCommand {
|
public abstract class CommandInstance extends BukkitCommand {
|
||||||
|
|
||||||
|
private static final String MANAGE_PERMISSION = "terminatorplus.manage";
|
||||||
protected final CommandHandler commandHandler;
|
protected final CommandHandler commandHandler;
|
||||||
|
|
||||||
private final Map<String, CommandMethod> methods;
|
private final Map<String, CommandMethod> methods;
|
||||||
private final Map<String, String> aliasesToNames;
|
private final Map<String, String> aliasesToNames;
|
||||||
|
|
||||||
private static final String MANAGE_PERMISSION = "terminatorplus.manage";
|
|
||||||
|
|
||||||
public CommandInstance(CommandHandler handler, String name, String description, @Nullable String... aliases) {
|
public CommandInstance(CommandHandler handler, String name, String description, @Nullable String... aliases) {
|
||||||
super(name, description, "", aliases == null ? new ArrayList<>() : Arrays.asList(aliases));
|
super(name, description, "", aliases == null ? new ArrayList<>() : Arrays.asList(aliases));
|
||||||
|
|
||||||
@@ -39,6 +37,24 @@ public abstract class CommandInstance extends BukkitCommand {
|
|||||||
this.aliasesToNames = new HashMap<>();
|
this.aliasesToNames = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getArgumentName(Parameter parameter) {
|
||||||
|
if (parameter.isAnnotationPresent(OptArg.class)) {
|
||||||
|
OptArg arg = parameter.getAnnotation(OptArg.class);
|
||||||
|
|
||||||
|
if (!arg.value().isEmpty()) {
|
||||||
|
return "[" + ChatUtils.camelToDashed(arg.value()) + "]";
|
||||||
|
}
|
||||||
|
} else if (parameter.isAnnotationPresent(Arg.class)) {
|
||||||
|
Arg arg = parameter.getAnnotation(Arg.class);
|
||||||
|
|
||||||
|
if (!arg.value().isEmpty()) {
|
||||||
|
return "<" + ChatUtils.camelToDashed(arg.value()) + ">";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "<" + ChatUtils.camelToDashed(parameter.getName()) + ">";
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, CommandMethod> getMethods() {
|
public Map<String, CommandMethod> getMethods() {
|
||||||
return methods;
|
return methods;
|
||||||
}
|
}
|
||||||
@@ -104,9 +120,7 @@ public abstract class CommandInstance extends BukkitCommand {
|
|||||||
parsedArguments.add(sender);
|
parsedArguments.add(sender);
|
||||||
} else if (type == List.class) {
|
} else if (type == List.class) {
|
||||||
parsedArguments.add(arguments);
|
parsedArguments.add(arguments);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else {
|
|
||||||
if (parameter.isAnnotationPresent(TextArg.class)) {
|
if (parameter.isAnnotationPresent(TextArg.class)) {
|
||||||
if (index >= arguments.size()) {
|
if (index >= arguments.size()) {
|
||||||
parsedArguments.add("");
|
parsedArguments.add("");
|
||||||
@@ -182,21 +196,15 @@ public abstract class CommandInstance extends BukkitCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (NonPlayerException e) {
|
||||||
|
|
||||||
catch (NonPlayerException e) {
|
|
||||||
sender.sendMessage("This is a player-only command.");
|
sender.sendMessage("This is a player-only command.");
|
||||||
return true;
|
return true;
|
||||||
}
|
} catch (ArgParseException e) {
|
||||||
|
|
||||||
catch (ArgParseException e) {
|
|
||||||
Parameter parameter = e.getParameter();
|
Parameter parameter = e.getParameter();
|
||||||
String name = getArgumentName(parameter);
|
String name = getArgumentName(parameter);
|
||||||
sender.sendMessage("The parameter " + ChatColor.YELLOW + name + ChatColor.RESET + " must be of type " + ChatColor.YELLOW + parameter.getType().toString() + ChatColor.RESET + ".");
|
sender.sendMessage("The parameter " + ChatColor.YELLOW + name + ChatColor.RESET + " must be of type " + ChatColor.YELLOW + parameter.getType().toString() + ChatColor.RESET + ".");
|
||||||
return true;
|
return true;
|
||||||
}
|
} catch (ArgCountException e) {
|
||||||
|
|
||||||
catch (ArgCountException e) {
|
|
||||||
List<String> usageArgs = new ArrayList<>();
|
List<String> usageArgs = new ArrayList<>();
|
||||||
|
|
||||||
Arrays.stream(method.getMethod().getParameters()).forEach(parameter -> {
|
Arrays.stream(method.getMethod().getParameters()).forEach(parameter -> {
|
||||||
@@ -222,24 +230,6 @@ public abstract class CommandInstance extends BukkitCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getArgumentName(Parameter parameter) {
|
|
||||||
if (parameter.isAnnotationPresent(OptArg.class)) {
|
|
||||||
OptArg arg = parameter.getAnnotation(OptArg.class);
|
|
||||||
|
|
||||||
if (!arg.value().isEmpty()) {
|
|
||||||
return "[" + ChatUtils.camelToDashed(arg.value()) + "]";
|
|
||||||
}
|
|
||||||
} else if (parameter.isAnnotationPresent(Arg.class)) {
|
|
||||||
Arg arg = parameter.getAnnotation(Arg.class);
|
|
||||||
|
|
||||||
if (!arg.value().isEmpty()) {
|
|
||||||
return "<" + ChatUtils.camelToDashed(arg.value()) + ">";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "<" + ChatUtils.camelToDashed(parameter.getName()) + ">";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
@@ -349,8 +349,7 @@ public class BotCommand extends CommandInstance {
|
|||||||
sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "region" + ChatUtils.BULLET_FORMATTED + "Sets a region for the bots to prioritize entities inside.");
|
sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "region" + ChatUtils.BULLET_FORMATTED + "Sets a region for the bots to prioritize entities inside.");
|
||||||
sender.sendMessage(ChatUtils.LINE);
|
sender.sendMessage(ChatUtils.LINE);
|
||||||
return;
|
return;
|
||||||
}
|
} else if (arg1.equalsIgnoreCase("setgoal")) {
|
||||||
else if (arg1.equalsIgnoreCase("setgoal")) {
|
|
||||||
if (arg2 == null) {
|
if (arg2 == null) {
|
||||||
sender.sendMessage("The global bot goal is currently " + ChatColor.BLUE + agent.getTargetType() + ChatColor.RESET + ".");
|
sender.sendMessage("The global bot goal is currently " + ChatColor.BLUE + agent.getTargetType() + ChatColor.RESET + ".");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public class MainCommand extends CommandInstance {
|
|||||||
|
|
||||||
sender.spigot().sendMessage(rootInfo);
|
sender.spigot().sendMessage(rootInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "debuginfo",
|
name = "debuginfo",
|
||||||
desc = "Upload debug info to mclo.gs"
|
desc = "Upload debug info to mclo.gs"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class NMSUtils {
|
public class NMSUtils {
|
||||||
private static String itemsByIdFieldName;
|
private static String itemsByIdFieldName;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// find a private final field in SynchedEntityData that is an Int2ObjectMap<SynchedEntityData.DataItem>
|
// find a private final field in SynchedEntityData that is an Int2ObjectMap<SynchedEntityData.DataItem>
|
||||||
Class<SynchedEntityData> clazz = SynchedEntityData.class;
|
Class<SynchedEntityData> clazz = SynchedEntityData.class;
|
||||||
@@ -24,6 +25,7 @@ public class NMSUtils {
|
|||||||
throw new RuntimeException("Could not find itemsById field in SynchedEntityData");
|
throw new RuntimeException("Could not find itemsById field in SynchedEntityData");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<SynchedEntityData.DataValue<?>> getEntityData(SynchedEntityData synchedEntityData) {
|
public static List<SynchedEntityData.DataValue<?>> getEntityData(SynchedEntityData synchedEntityData) {
|
||||||
Int2ObjectMap<SynchedEntityData.DataItem> map = null;
|
Int2ObjectMap<SynchedEntityData.DataItem> map = null;
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user