Skip to content

Commit c57febb

Browse files
committed
update to MC 1.20.4
1 parent 78cf076 commit c57febb

File tree

4 files changed

+6515
-5294
lines changed

4 files changed

+6515
-5294
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Minecraft bot stress tester
22
🤖 A simple open source app written in Java used for stress testing Minecraft servers with bots (fake players).
33
💥 It can be also used to test plugins or minigames.
4-
✔️ The MC version of the bots is 1.20 (supports 1.20.x).
4+
✔️ The MC version of the bots is 1.20.4
55
For older MC versions please look in the [releases](https://github.com/crpmax/mc-bots/releases " releases").
66

77
## 🆒 Features
@@ -15,13 +15,13 @@ For older MC versions please look in the [releases](https://github.com/crpmax/mc
1515
- ✅ Control all or selected bots
1616

1717
## 📖 Usage
18-
Minimal Java version: 8
18+
Minimal Java version: 17
1919
Use of pre-compiled jar from [releases](https://github.com/crpmax/mc-bots/releases " releases"):
2020
`java -jar mc-bots.jar -s <server address> [arguments]`
2121
When running, you can write a chat message to the terminal to send it by all bots.
2222

2323
## 🧪 Example
24-
`java -jar mc-bots-1.2.6.jar -s 192.168.0.189:25565 -p BOT_ -d 4000 5000 -c 30 -r`
24+
`java -jar mc-bots-1.2.10.jar -s 192.168.0.189:25565 -p BOT_ -d 4000 5000 -c 30 -r`
2525
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_
2626

2727
<img src="https://imgur.com/XWcckas.png" title="Connected bots" width="350px"/>

build.gradle

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ plugins {
33
}
44

55
group 'me.creepermaxcz.mc-bots'
6-
version '1.2.9'
6+
version '1.2.10'
77

8-
sourceCompatibility = 1.8
9-
targetCompatibility = 1.8
8+
sourceCompatibility = 1.17
9+
targetCompatibility = 1.17
1010

1111
repositories {
1212
mavenCentral()
@@ -16,7 +16,8 @@ repositories {
1616
}
1717

1818
dependencies {
19-
implementation 'com.github.steveice10:mcprotocollib:1.20.2-1'
19+
implementation 'com.github.steveice10:mcprotocollib:1.20.4-2-SNAPSHOT'
20+
implementation 'net.kyori:adventure-text-serializer-gson:4.16.0'
2021
implementation 'commons-cli:commons-cli:1.5.0'
2122
implementation 'com.diogonunes:JColor:5.2.0'
2223
implementation 'dnsjava:dnsjava:3.4.3'

src/main/java/me/creepermaxcz/mcbots/Utils.java

+41-25
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.kyori.adventure.text.Component;
88
import net.kyori.adventure.text.TextComponent;
99
import net.kyori.adventure.text.TranslatableComponent;
10+
import net.kyori.adventure.text.TranslationArgument;
1011
import net.kyori.adventure.text.format.Style;
1112
import net.kyori.adventure.text.format.TextColor;
1213
import net.kyori.adventure.text.format.TextDecoration;
@@ -15,6 +16,7 @@
1516
import java.io.InputStream;
1617
import java.io.InputStreamReader;
1718
import java.util.ArrayList;
19+
import java.util.Arrays;
1820
import java.util.List;
1921
import java.util.Map;
2022

@@ -121,38 +123,52 @@ public static List<Attribute> getFormats(Map<TextDecoration, TextDecoration.Stat
121123
}
122124

123125
public static String translate(TranslatableComponent message) {
124-
if (lang == null) {
125-
try {
126-
InputStream resource = Utils.class.getResourceAsStream("/files/lang.json");
127-
lang = new JsonParser().parse(new InputStreamReader(resource)).getAsJsonObject();
128-
} catch (Exception e) {
129-
Log.crit(e);
126+
try {
127+
if (lang == null) {
128+
try {
129+
InputStream resource = Utils.class.getResourceAsStream("/files/lang.json");
130+
if (resource == null) {
131+
throw new Exception("Failed to load lang resource.");
132+
}
133+
lang = new JsonParser().parse(new InputStreamReader(resource)).getAsJsonObject();
134+
} catch (Exception e) {
135+
Log.crit(e);
136+
}
130137
}
131-
}
132-
//Log.info(message.toString());
138+
//Log.info(message.toString());
133139

134-
String key = message.key();
135-
String base = key;
140+
String key = message.key();
141+
String base = key;
136142

137-
JsonElement value = lang.get(key);
138-
if (value != null) {
139-
base = value.getAsString();
140-
}
143+
JsonElement value = lang.get(key);
144+
if (value != null) {
145+
base = value.getAsString();
146+
}
141147

142-
ArrayList<String> placeholders = new ArrayList<>();
148+
ArrayList<String> placeholders = new ArrayList<>();
143149

144-
if (message.args().size() > 0) {
145-
for (Component component : message.args()) {
146-
if (component instanceof TranslatableComponent) {
147-
placeholders.add(translate((TranslatableComponent) component));
148-
} else if (component instanceof TextComponent) {
149-
placeholders.add(getFullText((TextComponent) component, false));
150+
if (message.arguments().size() > 0) {
151+
for (TranslationArgument arg : message.arguments()) {
152+
Component component = arg.asComponent();
153+
if (component instanceof TranslatableComponent) {
154+
placeholders.add(translate((TranslatableComponent) component));
155+
} else if (arg instanceof TextComponent) {
156+
placeholders.add(getFullText((TextComponent) component, false));
157+
}
150158
}
159+
//Log.info(Arrays.toString(placeholders.toArray()));
160+
try {
161+
return String.format(base, placeholders.toArray());
162+
} catch (Exception e) {
163+
Log.error("Error formatting '"+base+"' with placeholders " + Arrays.toString(placeholders.toArray()));
164+
}
165+
} else {
166+
return base;
151167
}
152-
//Log.info(Arrays.toString(placeholders.toArray()));
153-
return String.format(base, placeholders.toArray());
154-
} else {
155-
return base;
168+
} catch (Exception e) {
169+
Log.error(e);
156170
}
171+
172+
return "";
157173
}
158174
}

0 commit comments

Comments
 (0)