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