Added another follow pattern

This commit is contained in:
TheTrouper
2024-05-09 16:59:16 -05:00
parent 9d56f035f2
commit 18202b4d92
2 changed files with 80 additions and 41 deletions

View File

@@ -1,11 +1,9 @@
package me.trouper.butler.commands; package me.trouper.butler.commands;
import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.arguments.DoubleArgumentType; import com.mojang.brigadier.arguments.DoubleArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import io.netty.util.concurrent.CompleteFuture;
import me.trouper.butler.modules.SwarmPlusMaster; import me.trouper.butler.modules.SwarmPlusMaster;
import me.trouper.butler.server.Connection; import me.trouper.butler.server.Connection;
import me.trouper.butler.utils.MathUtils; import me.trouper.butler.utils.MathUtils;
@@ -15,28 +13,29 @@ import meteordevelopment.meteorclient.commands.arguments.ModuleArgumentType;
import meteordevelopment.meteorclient.commands.arguments.PlayerArgumentType; import meteordevelopment.meteorclient.commands.arguments.PlayerArgumentType;
import meteordevelopment.meteorclient.commands.arguments.SettingArgumentType; import meteordevelopment.meteorclient.commands.arguments.SettingArgumentType;
import meteordevelopment.meteorclient.commands.arguments.SettingValueArgumentType; import meteordevelopment.meteorclient.commands.arguments.SettingValueArgumentType;
import meteordevelopment.meteorclient.pathing.PathManagers;
import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.systems.modules.Module;
import net.minecraft.client.MinecraftClient;
import net.minecraft.command.CommandSource; import net.minecraft.command.CommandSource;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.util.List; import java.util.List;
import java.util.Random;
import java.util.concurrent.*;
import static com.mojang.brigadier.Command.SINGLE_SUCCESS; import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
public class SwarmManager extends Command { public class SwarmManager extends Command {
public SwarmManager() { public SwarmManager() {
super("manager", "Sends a message."); super("manager", "Control your Hive");
} }
private static boolean circling = false; private static boolean circling = false;
/*
Welcome to the tree-of-hell (Supported by ImproperIssues, this 350+ line nested tree is supposedly "perfectly fine" and the proper way to code this)
The easiest way to navigate it is to Ctrl+f the branch you want to go to.
Scrolling through this is NOT fun.
*/
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("chat") builder.then(literal("chat")
@@ -52,6 +51,10 @@ public class SwarmManager extends Command {
})) }))
) )
.then(literal("list").executes(context -> { .then(literal("list").executes(context -> {
if (SwarmPlusMaster.swarmServer == null) {
error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!");
return SINGLE_SUCCESS;
}
List<Connection> connections = SwarmPlusMaster.swarmServer.getConnections().stream().toList(); List<Connection> connections = SwarmPlusMaster.swarmServer.getConnections().stream().toList();
StringBuilder connectionList = new StringBuilder(); StringBuilder connectionList = new StringBuilder();
int pointer = 0; int pointer = 0;
@@ -59,22 +62,19 @@ public class SwarmManager extends Command {
pointer++; pointer++;
connectionList.append("\n%s: %s on %s".formatted(pointer, connection.getClientSideName(),connection.getAddress())); connectionList.append("\n%s: %s on %s".formatted(pointer, connection.getClientSideName(),connection.getAddress()));
} }
info("Swarm connections: " + connectionList.toString()); info("Swarm connections: " + connectionList);
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
})) }))
.then(literal("kick").then(argument("target",StringArgumentType.string()) .then(literal("kick").then(argument("target",StringArgumentType.string())
.executes(context -> { .executes(context -> {
String target = context.getArgument("target", String.class);
if (SwarmPlusMaster.swarmServer == null) { if (SwarmPlusMaster.swarmServer == null) {
error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!"); error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!");
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
} }
//info("Looping %s connections".formatted(SwarmPlusMaster.swarmServer.connectionCount()));
String target = context.getArgument("target", String.class);
for (Connection connection : SwarmPlusMaster.swarmServer.getConnections()) { for (Connection connection : SwarmPlusMaster.swarmServer.getConnections()) {
//info("Looping connections: %s user %s".formatted(connection.getAddress(),connection.getClientSideName()));
if (connection.getClientSideName().equals(target)) connection.disconnect(); if (connection.getClientSideName().equals(target)) connection.disconnect();
//info("Disconnected %s".formatted(target),"DO YOU NEED AN ARGUMENT AGAIN?????");
} }
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
})) }))
@@ -123,6 +123,7 @@ public class SwarmManager extends Command {
error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!"); error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!");
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
} }
Module module = ModuleArgumentType.get(context); Module module = ModuleArgumentType.get(context);
Setting<?> setting = SettingArgumentType.get(context); Setting<?> setting = SettingArgumentType.get(context);
String value = SettingValueArgumentType.get(context); String value = SettingValueArgumentType.get(context);
@@ -146,6 +147,7 @@ public class SwarmManager extends Command {
error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!"); error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!");
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
} }
int rad = context.getArgument("radius",Integer.class); int rad = context.getArgument("radius",Integer.class);
int n = SwarmPlusMaster.swarmServer.connectionCount(); int n = SwarmPlusMaster.swarmServer.connectionCount();
Point2D.Double[] distribution = MathUtils.distributePoints(MeteorClient.mc.player.getX(),MeteorClient.mc.player.getZ(),rad,n); Point2D.Double[] distribution = MathUtils.distributePoints(MeteorClient.mc.player.getX(),MeteorClient.mc.player.getZ(),rad,n);
@@ -166,14 +168,17 @@ public class SwarmManager extends Command {
error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!"); error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!");
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
} }
int roundX = (int) Math.round(MeteorClient.mc.player.getX()); int roundX = (int) Math.round(MeteorClient.mc.player.getX());
int roundY = (int) Math.round(MeteorClient.mc.player.getY()); int roundY = (int) Math.round(MeteorClient.mc.player.getY());
int roundZ = (int) Math.round(MeteorClient.mc.player.getZ()); int roundZ = (int) Math.round(MeteorClient.mc.player.getZ());
SwarmPlusMaster.swarmServer.broadcast("[BARITONE] gotoxyz %s %s %s".formatted( SwarmPlusMaster.swarmServer.broadcast("[BARITONE] gotoxyz %s %s %s".formatted(
roundX, roundX,
roundY, roundY,
roundZ roundZ
)); ));
SwarmManager.this.info("Pathing (highlight)all bots(default) to the host."); SwarmManager.this.info("Pathing (highlight)all bots(default) to the host.");
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
}) })
@@ -183,10 +188,12 @@ public class SwarmManager extends Command {
error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!"); error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!");
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
} }
String target = StringArgumentType.getString(context,"target"); String target = StringArgumentType.getString(context,"target");
int roundX = (int) Math.round(MeteorClient.mc.player.getX()); int roundX = (int) Math.round(MeteorClient.mc.player.getX());
int roundY = (int) Math.round(MeteorClient.mc.player.getY()); int roundY = (int) Math.round(MeteorClient.mc.player.getY());
int roundZ = (int) Math.round(MeteorClient.mc.player.getZ()); int roundZ = (int) Math.round(MeteorClient.mc.player.getZ());
for (Connection connection : SwarmPlusMaster.swarmServer.getConnections().stream().toList()) { for (Connection connection : SwarmPlusMaster.swarmServer.getConnections().stream().toList()) {
if (!connection.getClientSideName().equalsIgnoreCase(target)) continue; if (!connection.getClientSideName().equalsIgnoreCase(target)) continue;
connection.sendMessage("[BARITONE] gotoxyz %s %s %s".formatted( connection.sendMessage("[BARITONE] gotoxyz %s %s %s".formatted(
@@ -197,6 +204,7 @@ public class SwarmManager extends Command {
SwarmManager.this.info("Pathing (highlight)%s(default) to the host.",target); SwarmManager.this.info("Pathing (highlight)%s(default) to the host.",target);
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
} }
SwarmManager.this.error("Could not find a connection with the name (highlight)%s",target); SwarmManager.this.error("Could not find a connection with the name (highlight)%s",target);
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
})) }))
@@ -222,10 +230,12 @@ public class SwarmManager extends Command {
error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!"); error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!");
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
} }
SwarmPlusMaster.swarmServer.broadcast("[BARITONE] gotoxz %s %s".formatted( SwarmPlusMaster.swarmServer.broadcast("[BARITONE] gotoxz %s %s".formatted(
IntegerArgumentType.getInteger(context,"x"), IntegerArgumentType.getInteger(context,"x"),
IntegerArgumentType.getInteger(context,"z") IntegerArgumentType.getInteger(context,"z")
)); ));
SwarmManager.this.info("Pathing all bots to (highlight)%s %s", SwarmManager.this.info("Pathing all bots to (highlight)%s %s",
IntegerArgumentType.getInteger(context,"x"), IntegerArgumentType.getInteger(context,"x"),
IntegerArgumentType.getInteger(context,"z")); IntegerArgumentType.getInteger(context,"z"));
@@ -239,11 +249,13 @@ public class SwarmManager extends Command {
error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!"); error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!");
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
} }
SwarmPlusMaster.swarmServer.broadcast("[BARITONE] gotoxyz %s %s %s".formatted( SwarmPlusMaster.swarmServer.broadcast("[BARITONE] gotoxyz %s %s %s".formatted(
IntegerArgumentType.getInteger(context,"x"), IntegerArgumentType.getInteger(context,"x"),
IntegerArgumentType.getInteger(context,"y"), IntegerArgumentType.getInteger(context,"y"),
IntegerArgumentType.getInteger(context,"z") IntegerArgumentType.getInteger(context,"z")
)); ));
SwarmManager.this.info("Pathing all bots to (highlight)%s %s %s", SwarmManager.this.info("Pathing all bots to (highlight)%s %s %s",
IntegerArgumentType.getInteger(context,"x"), IntegerArgumentType.getInteger(context,"x"),
IntegerArgumentType.getInteger(context,"y"), IntegerArgumentType.getInteger(context,"y"),
@@ -261,9 +273,11 @@ public class SwarmManager extends Command {
error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!"); error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!");
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
} }
SwarmPlusMaster.swarmServer.broadcast("[LOOK] absolute %s %s".formatted( SwarmPlusMaster.swarmServer.broadcast("[LOOK] absolute %s %s".formatted(
context.getArgument("pitch",double.class), context.getArgument("pitch",double.class),
context.getArgument("yaw",double.class))); context.getArgument("yaw",double.class)));
SwarmManager.this.info("Bots now facing (highlight)%s %s", SwarmManager.this.info("Bots now facing (highlight)%s %s",
context.getArgument("pitch",double.class), context.getArgument("pitch",double.class),
context.getArgument("yaw",double.class)); context.getArgument("yaw",double.class));
@@ -278,6 +292,7 @@ public class SwarmManager extends Command {
error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!"); error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!");
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
} }
SwarmPlusMaster.swarmServer.broadcast("[LOOK] player %s".formatted(context.getArgument("target",PlayerEntity.class).getName().getString())); SwarmPlusMaster.swarmServer.broadcast("[LOOK] player %s".formatted(context.getArgument("target",PlayerEntity.class).getName().getString()));
SwarmManager.this.info("Bots now targeting (highlight)%s",context.getArgument("target",PlayerEntity.class).getName().getString()); SwarmManager.this.info("Bots now targeting (highlight)%s",context.getArgument("target",PlayerEntity.class).getName().getString());
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
@@ -291,11 +306,32 @@ public class SwarmManager extends Command {
error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!"); error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!");
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
} }
PlayerEntity pe = PlayerArgumentType.get(context); PlayerEntity pe = PlayerArgumentType.get(context);
SwarmPlusMaster.swarmServer.broadcast("[BARITONE] follow %s".formatted(pe.getName().getString())); SwarmPlusMaster.swarmServer.broadcast("[BARITONE] follow %s".formatted(pe.getName().getString()));
SwarmManager.this.info("Bots now following (highlight)%s(default).",pe.getName().getString()); SwarmManager.this.info("Bots now following (highlight)%s(default).",pe.getName().getString());
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
}) })
.then(literal("snake")
.executes(context -> {
if (SwarmPlusMaster.swarmServer == null) {
error("SwarmPlusMaster module is disabled. Start a swarm server to send commands to it!");
return SINGLE_SUCCESS;
}
String pointer = MeteorClient.mc.player.getName().getString();
StringBuilder lineOrder = new StringBuilder("Line order: ");
lineOrder.append("%s <- ".formatted(pointer));
for (Connection connection : SwarmPlusMaster.swarmServer.getConnections()) {
lineOrder.append("%s <- ".formatted(pointer));
connection.sendMessage("[BARITONE] follow %s".formatted(pointer));
pointer = connection.getClientSideName();
}
SwarmManager.this.info("Bots are now following in a snake. " + lineOrder);
return SINGLE_SUCCESS;
}))
.then(literal("circle") .then(literal("circle")
.then(argument("radius",IntegerArgumentType.integer(1)) .then(argument("radius",IntegerArgumentType.integer(1))
.then(argument("update-freq", IntegerArgumentType.integer(0,10000)) .then(argument("update-freq", IntegerArgumentType.integer(0,10000))
@@ -308,7 +344,8 @@ public class SwarmManager extends Command {
circling = !circling; circling = !circling;
SwarmManager.this.info("Bots are %s circling (highlight)%s(default).",circling ? "now" : "no longer", pe.getName().getString()); SwarmManager.this.info("Bots are %s circling (highlight)%s(default).",circling ? "now" : "no longer", pe.getName().getString());
if (circling) { if (!circling) return SINGLE_SUCCESS;
int delay = IntegerArgumentType.getInteger(context,"update-freq"); int delay = IntegerArgumentType.getInteger(context,"update-freq");
if (delay <= 0){ if (delay <= 0){
SwarmManager.this.error("CHECK YOUR CONSOLE BOI + INVALID INTEGER INPUT"); SwarmManager.this.error("CHECK YOUR CONSOLE BOI + INVALID INTEGER INPUT");
@@ -336,7 +373,7 @@ public class SwarmManager extends Command {
} }
}); });
thread.start(); thread.start();
}
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
})) }))
) )
@@ -352,6 +389,7 @@ public class SwarmManager extends Command {
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
})) }))
.then(literal("stop").executes(context -> { .then(literal("stop").executes(context -> {
circling = false;
SwarmPlusMaster.swarmServer.broadcast("[STOP]"); SwarmPlusMaster.swarmServer.broadcast("[STOP]");
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
})) }))

View File

@@ -7,6 +7,7 @@ import me.trouper.butler.server.Response;
import me.trouper.butler.utils.MathUtils; import me.trouper.butler.utils.MathUtils;
import me.trouper.butler.utils.Text; import me.trouper.butler.utils.Text;
import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.pathing.PathManagers;
import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.settings.*;
import meteordevelopment.meteorclient.systems.config.Config; import meteordevelopment.meteorclient.systems.config.Config;
import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.systems.modules.Module;
@@ -146,7 +147,7 @@ public class SwarmPlusWorker extends Module {
System.exit(0); System.exit(0);
} }
default -> { default -> {
SwarmPlusWorker.this.error("An error occurred when receiving a packet from the host. (highlight)%s",full); SwarmPlusWorker.this.error("An error occurred when receiving a packet from the host. (highlight)%s", full);
} }
} }
} }