Compare commits
15
Commits
v1.2.10
...
939ed09bdb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
939ed09bdb | ||
|
|
8417fd7b45 | ||
|
|
60e624e47e | ||
|
|
e8e3b4f9c0 | ||
|
|
7c1eb7cf24 | ||
|
|
ce9d01a47f | ||
|
|
b81b61187f | ||
|
|
5e109efc56 | ||
|
|
91e4d44170 | ||
|
|
e2a477e56f | ||
|
|
1ce1f98801 | ||
|
|
9865364919 | ||
|
|
fb99076f88 | ||
|
|
da26ec8a99 | ||
|
|
8b2dddf8d6 |
No files matched your search
@@ -1,7 +1,7 @@
|
||||
# Minecraft bot stress tester
|
||||
🤖 A simple open source app written in Java used for stress testing Minecraft servers with bots (fake players).
|
||||
💥 It can be also used to test plugins or minigames.
|
||||
✔️ The MC version of the bots is 1.20.4
|
||||
✔️ The MC version of the bots is 1.21.7 (supports server 1.21.8)
|
||||
For older MC versions please look in the [releases](https://github.com/crpmax/mc-bots/releases " releases").
|
||||
|
||||
## 🆒 Features
|
||||
@@ -11,7 +11,7 @@ For older MC versions please look in the [releases](https://github.com/crpmax/mc
|
||||
- ✅ Set connection delay
|
||||
- ✅ Set messages or commands on join
|
||||
- ✅ Generate random or real looking nicknames or load from file
|
||||
- ✅ Online (premium) account support with login using Microsoft OAuth - only for migrated accounts
|
||||
- ✅ Online (premium) account support with login using Microsoft
|
||||
- ✅ Control all or selected bots
|
||||
|
||||
## 📖 Usage
|
||||
@@ -21,7 +21,7 @@ Use of pre-compiled jar from [releases](https://github.com/crpmax/mc-bots/releas
|
||||
When running, you can write a chat message to the terminal to send it by all bots.
|
||||
|
||||
## 🧪 Example
|
||||
`java -jar mc-bots-1.2.10.jar -s 192.168.0.189:25565 -p BOT_ -d 4000 5000 -c 30 -r`
|
||||
`java -jar mc-bots-1.2.17.jar -s 192.168.0.189:25565 -p BOT_ -d 4000 5000 -c 30 -r`
|
||||
This will connect 30 bots to server at 192.168.0.189:25565 with delay 4000-5000 ms and will use real-looking nicknames prefixed with BOT_
|
||||
|
||||
<img src="https://imgur.com/XWcckas.png" title="Connected bots" width="350px"/>
|
||||
|
||||
+14
-11
@@ -3,10 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'me.creepermaxcz.mc-bots'
|
||||
version '1.2.10'
|
||||
|
||||
sourceCompatibility = 1.17
|
||||
targetCompatibility = 1.17
|
||||
version '1.2.18'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -16,13 +13,19 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.steveice10:mcprotocollib:1.20.4-2-SNAPSHOT'
|
||||
implementation 'net.kyori:adventure-text-serializer-gson:4.16.0'
|
||||
implementation 'commons-cli:commons-cli:1.5.0'
|
||||
implementation 'com.diogonunes:JColor:5.2.0'
|
||||
implementation 'dnsjava:dnsjava:3.4.3'
|
||||
implementation 'org.slf4j:slf4j-nop:1.7.32'
|
||||
implementation 'org.jline:jline:3.22.0'
|
||||
implementation 'org.geysermc.mcprotocollib:protocol:1.21.11-SNAPSHOT'
|
||||
implementation 'net.kyori:adventure-text-serializer-gson:4.24.0'
|
||||
implementation 'commons-cli:commons-cli:1.9.0'
|
||||
implementation 'com.diogonunes:JColor:5.5.1'
|
||||
implementation 'dnsjava:dnsjava:3.5.3'
|
||||
implementation 'org.slf4j:slf4j-nop:2.0.17'
|
||||
implementation 'org.jline:jline:3.30.4'
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(21)
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,25 +1,27 @@
|
||||
package me.creepermaxcz.mcbots;
|
||||
|
||||
import com.github.steveice10.mc.auth.service.AuthenticationService;
|
||||
import com.github.steveice10.mc.auth.service.SessionService;
|
||||
import com.github.steveice10.mc.protocol.MinecraftConstants;
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.mc.protocol.data.UnexpectedEncryptionException;
|
||||
import com.github.steveice10.mc.protocol.data.game.ClientCommand;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerCombatKillPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatCommandPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.*;
|
||||
import com.github.steveice10.packetlib.ProxyInfo;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
|
||||
import com.github.steveice10.packetlib.event.session.SessionAdapter;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||
import org.geysermc.mcprotocollib.auth.GameProfile;
|
||||
import org.geysermc.mcprotocollib.auth.SessionService;
|
||||
import org.geysermc.mcprotocollib.network.ClientSession;
|
||||
import org.geysermc.mcprotocollib.network.ProxyInfo;
|
||||
import org.geysermc.mcprotocollib.network.Session;
|
||||
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
|
||||
import org.geysermc.mcprotocollib.network.event.session.SessionAdapter;
|
||||
import org.geysermc.mcprotocollib.network.factory.ClientNetworkSessionFactory;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
import org.geysermc.mcprotocollib.network.session.ClientNetworkSession;
|
||||
import org.geysermc.mcprotocollib.protocol.MinecraftConstants;
|
||||
import org.geysermc.mcprotocollib.protocol.MinecraftProtocol;
|
||||
import org.geysermc.mcprotocollib.protocol.data.UnexpectedEncryptionException;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.ClientCommand;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerCombatKillPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundChatCommandPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundChatPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.*;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.time.Instant;
|
||||
@@ -29,12 +31,10 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class Bot extends Thread {
|
||||
|
||||
MinecraftProtocol protocol = null;
|
||||
|
||||
private String nickname;
|
||||
private ProxyInfo proxy;
|
||||
private InetSocketAddress address;
|
||||
private Session client;
|
||||
private ClientSession client;
|
||||
private boolean hasMainListener;
|
||||
|
||||
private double lastX, lastY, lastZ = -1;
|
||||
@@ -43,25 +43,18 @@ public class Bot extends Thread {
|
||||
|
||||
private boolean manualDisconnecting = false;
|
||||
|
||||
public Bot(String nickname, InetSocketAddress address, ProxyInfo proxy) {
|
||||
this.nickname = nickname;
|
||||
public Bot(MinecraftProtocol protocol, InetSocketAddress address, ProxyInfo proxy) {
|
||||
this.nickname = protocol.getProfile().getName();
|
||||
this.address = address;
|
||||
this.proxy = proxy;
|
||||
|
||||
Log.info("Creating bot", nickname);
|
||||
protocol = new MinecraftProtocol(nickname);
|
||||
client = new TcpClientSession(address.getHostString(), address.getPort(), protocol, proxy);
|
||||
}
|
||||
|
||||
public Bot(AuthenticationService authService, InetSocketAddress address, ProxyInfo proxy) {
|
||||
this.nickname = authService.getUsername();
|
||||
this.address = address;
|
||||
this.proxy = proxy;
|
||||
|
||||
Log.info("Creating bot", nickname);
|
||||
protocol = new MinecraftProtocol(authService.getSelectedProfile(), authService.getAccessToken());
|
||||
|
||||
client = new TcpClientSession(address.getHostString(), address.getPort(), protocol, proxy);
|
||||
client = ClientNetworkSessionFactory.factory()
|
||||
.setAddress(address.getHostString(), address.getPort())
|
||||
.setProtocol(protocol)
|
||||
.setProxy(proxy)
|
||||
.create();
|
||||
|
||||
SessionService sessionService = new SessionService();
|
||||
client.setFlag(MinecraftConstants.SESSION_SERVICE_KEY, sessionService);
|
||||
@@ -93,11 +86,11 @@ public class Bot extends Thread {
|
||||
else if (packet instanceof ClientboundPlayerPositionPacket) {
|
||||
ClientboundPlayerPositionPacket p = (ClientboundPlayerPositionPacket) packet;
|
||||
|
||||
lastX = p.getX();
|
||||
lastY = p.getY();
|
||||
lastZ = p.getZ();
|
||||
lastX = p.getPosition().getX();
|
||||
lastY = p.getPosition().getY();
|
||||
lastZ = p.getPosition().getZ();
|
||||
|
||||
client.send(new ServerboundAcceptTeleportationPacket(p.getTeleportId()));
|
||||
client.send(new ServerboundAcceptTeleportationPacket(p.getId()));
|
||||
}
|
||||
else if (packet instanceof ClientboundPlayerCombatKillPacket){
|
||||
if (Main.autoRespawnDelay >= 0) {
|
||||
@@ -155,19 +148,10 @@ public class Bot extends Thread {
|
||||
}
|
||||
|
||||
public void sendChat(String text) {
|
||||
// timeStamp will provide when this message was sent by the user. If this value was not set or was set to 0,
|
||||
// The server console will print out that the message was "expired". To avoid this, set timeStamp as now.
|
||||
long timeStamp = Instant.now().toEpochMilli();
|
||||
|
||||
// Send command
|
||||
if (text.startsWith("/")) {
|
||||
client.send(new ServerboundChatCommandPacket(
|
||||
text.substring(1),
|
||||
timeStamp,
|
||||
0L,
|
||||
Collections.emptyList(),
|
||||
0,
|
||||
new BitSet()
|
||||
text.substring(1)
|
||||
));
|
||||
} else {
|
||||
// Send chat message
|
||||
@@ -181,7 +165,8 @@ public class Bot extends Thread {
|
||||
0L,
|
||||
null,
|
||||
0,
|
||||
new BitSet()
|
||||
new BitSet(),
|
||||
0
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -217,7 +202,7 @@ public class Bot extends Thread {
|
||||
|
||||
public void moveTo(double x, double y, double z)
|
||||
{
|
||||
client.send(new ServerboundMovePlayerPosPacket(true, x, y, z));
|
||||
client.send(new ServerboundMovePlayerPosPacket(true, false, x, y, z));
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package me.creepermaxcz.mcbots;
|
||||
|
||||
import com.github.steveice10.mc.auth.exception.request.AuthPendingException;
|
||||
import com.github.steveice10.mc.auth.service.AuthenticationService;
|
||||
import com.github.steveice10.mc.auth.service.MsaAuthenticationService;
|
||||
import com.github.steveice10.mc.auth.util.HTTP;
|
||||
import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo;
|
||||
import com.github.steveice10.packetlib.ProxyInfo;
|
||||
import net.lenni0451.commons.httpclient.HttpClient;
|
||||
import net.raphimc.minecraftauth.MinecraftAuth;
|
||||
import net.raphimc.minecraftauth.java.JavaAuthManager;
|
||||
import net.raphimc.minecraftauth.java.model.MinecraftProfile;
|
||||
import net.raphimc.minecraftauth.msa.model.MsaDeviceCode;
|
||||
import net.raphimc.minecraftauth.msa.service.impl.DeviceCodeMsaAuthService;
|
||||
import org.geysermc.mcprotocollib.auth.GameProfile;
|
||||
import org.geysermc.mcprotocollib.network.ProxyInfo;
|
||||
import org.geysermc.mcprotocollib.protocol.MinecraftProtocol;
|
||||
import org.geysermc.mcprotocollib.protocol.data.status.ServerStatusInfo;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.jline.reader.LineReader;
|
||||
import org.jline.reader.LineReaderBuilder;
|
||||
@@ -21,6 +25,7 @@ import java.io.*;
|
||||
import java.net.*;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -105,7 +110,7 @@ public class Main {
|
||||
try {
|
||||
proxyType = ProxyInfo.Type.valueOf(typeStr);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.error("Inavlid proxy type, use SOCKS4 or SOCKS5.");
|
||||
Log.error("Invalid proxy type, use SOCKS4 or SOCKS5.");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
@@ -269,55 +274,27 @@ public class Main {
|
||||
Log.warn("There was an error retrieving server status information. The server may be offline or running on a different version.");
|
||||
}
|
||||
|
||||
AuthenticationService authService = null;
|
||||
MinecraftProtocol protocol;
|
||||
if (cmd.hasOption("o")) {
|
||||
Log.warn("Online mode enabled. The bot count will be set to 1.");
|
||||
botCount = 1;
|
||||
|
||||
// Create request parameters map
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("client_id", CLIENT_ID);
|
||||
params.put("scope", "XboxLive.signin");
|
||||
HttpClient httpClient = MinecraftAuth.createHttpClient();
|
||||
JavaAuthManager authManager = JavaAuthManager.create(httpClient)
|
||||
.login(DeviceCodeMsaAuthService::new, (Consumer<MsaDeviceCode>) msaDeviceCode -> {
|
||||
Log.info("Authorize your Microsoft account on " + msaDeviceCode.getDirectVerificationUri());
|
||||
Log.info("Waiting for authorization.");
|
||||
});
|
||||
|
||||
// Send request to Microsoft OAuth api
|
||||
// https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code
|
||||
URI endpointURI = URI.create("https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode");
|
||||
MsaAuthenticationService.MsCodeResponse response = HTTP.makeRequestForm(
|
||||
Proxy.NO_PROXY, endpointURI, params, MsaAuthenticationService.MsCodeResponse.class
|
||||
);
|
||||
try {
|
||||
Log.info("Please go to " + response.verification_uri.toURL() + " to authenticate your account - Code: " + response.user_code);
|
||||
} catch (MalformedURLException e) {
|
||||
Log.error("Error while trying to get the url of the authentication page");
|
||||
}
|
||||
MinecraftProfile mcProfile = authManager.getMinecraftProfile().getUpToDate();
|
||||
Log.info("Logged in with username: " + mcProfile.getName());
|
||||
|
||||
authService = new MsaAuthenticationService(CLIENT_ID, response.device_code);
|
||||
|
||||
// Wait for user to login on microsoft page
|
||||
int retryMax = 20;
|
||||
while (true) {
|
||||
try {
|
||||
authService.login();
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
if (e instanceof AuthPendingException) {
|
||||
Log.info("Authentication is pending, waiting for user to authenticate...");
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
if (retryMax == 0)
|
||||
throw e;
|
||||
retryMax--;
|
||||
GameProfile gameProfile = new GameProfile(mcProfile.getId(), mcProfile.getName());
|
||||
protocol = new MinecraftProtocol(gameProfile, authManager.getMinecraftToken().getUpToDate().getToken());
|
||||
} else {
|
||||
throw e;
|
||||
protocol = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AuthenticationService finalAuthService = authService;
|
||||
new Thread(() -> {
|
||||
for (int i = 0; i < botCount; i++) {
|
||||
try {
|
||||
@@ -347,15 +324,15 @@ public class Main {
|
||||
}
|
||||
|
||||
Bot bot = null;
|
||||
if (finalAuthService != null) {
|
||||
if (protocol != null) {
|
||||
bot = new Bot(
|
||||
finalAuthService,
|
||||
protocol,
|
||||
inetAddr,
|
||||
proxyInfo
|
||||
);
|
||||
} else {
|
||||
bot = new Bot(
|
||||
nickGen.nextNick(),
|
||||
new MinecraftProtocol(nickGen.nextNick()),
|
||||
inetAddr,
|
||||
proxyInfo
|
||||
);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package me.creepermaxcz.mcbots;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.event.session.*;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import org.geysermc.mcprotocollib.network.Session;
|
||||
import org.geysermc.mcprotocollib.network.event.session.*;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundPlayerChatPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
package me.creepermaxcz.mcbots;
|
||||
|
||||
|
||||
import com.github.steveice10.mc.protocol.MinecraftConstants;
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo;
|
||||
import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoHandler;
|
||||
import com.github.steveice10.mc.protocol.data.status.handler.ServerPingTimeHandler;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
|
||||
import com.github.steveice10.packetlib.event.session.SessionAdapter;
|
||||
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||
import org.geysermc.mcprotocollib.network.ClientSession;
|
||||
import org.geysermc.mcprotocollib.network.Session;
|
||||
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
|
||||
import org.geysermc.mcprotocollib.network.event.session.SessionAdapter;
|
||||
import org.geysermc.mcprotocollib.network.factory.ClientNetworkSessionFactory;
|
||||
import org.geysermc.mcprotocollib.protocol.MinecraftConstants;
|
||||
import org.geysermc.mcprotocollib.protocol.MinecraftProtocol;
|
||||
import org.geysermc.mcprotocollib.protocol.data.status.ServerStatusInfo;
|
||||
import org.geysermc.mcprotocollib.protocol.data.status.handler.ServerInfoHandler;
|
||||
import org.geysermc.mcprotocollib.protocol.data.status.handler.ServerPingTimeHandler;
|
||||
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
public class ServerInfo {
|
||||
|
||||
private final Session client;
|
||||
private final ClientSession client;
|
||||
private ServerStatusInfo serverStatusInfo;
|
||||
private long ping;
|
||||
private boolean done;
|
||||
@@ -23,7 +25,11 @@ public class ServerInfo {
|
||||
public ServerInfo(InetSocketAddress address) {
|
||||
|
||||
MinecraftProtocol protocol = new MinecraftProtocol();
|
||||
client = new TcpClientSession(address.getHostString(), address.getPort(), protocol, null);
|
||||
|
||||
client = ClientNetworkSessionFactory.factory()
|
||||
.setAddress(address.getHostString(), address.getPort())
|
||||
.setProtocol(protocol)
|
||||
.create();
|
||||
|
||||
client.setFlag(MinecraftConstants.SERVER_INFO_HANDLER_KEY, (ServerInfoHandler) (session, info) -> {
|
||||
this.serverStatusInfo = info;
|
||||
|
||||
Reference in new issue
Block a user