Skip to content

Commit 17ff23a

Browse files
[+] Supported to change languages from config.
[~] Improved Json parsing performance. [!] Fixed plugins disable incorrectly. [+] Added Translatable logging setting. [#] Fixed Typo. [+] Added "packet-warning" option in config. [-] Removed useless classes. [~] Updated README.md. [~] Improved Logging system.
1 parent 40d6d9b commit 17ff23a

File tree

76 files changed

+1619
-679
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1619
-679
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PluginDocs.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ by Implementing `IListener` interface, and annotate `@EventHandler` on methods y
223223
import org.angellock.impl.events.EventPriority;
224224
import org.angellock.impl.events.IListener;
225225
import org.angellock.impl.events.annotations.EventHandler;
226-
import org.angellock.impl.events.types.PlayerMoveEvent;
226+
import org.angellock.impl.events.game.PlayerMoveEvent;
227227
import org.angellock.impl.ingame.Player;
228228

229229
public class MyListener implements IListener {
@@ -260,7 +260,7 @@ The only thing you need to do is make `ExamplePlugin` to also implement the `ILi
260260
```java
261261
import org.angellock.impl.events.IListener;
262262
import org.angellock.impl.events.annotations.EventHandler;
263-
import org.angellock.impl.events.types.EntityEmergedEvent;
263+
import org.angellock.impl.events.game.EntityEmergedEvent;
264264
import org.angellock.impl.providers.AbstractPlugin;
265265
import org.geysermc.mcprotocollib.protocol.data.game.entity.type.EntityType;
266266

@@ -382,7 +382,7 @@ public class ExamplePlugin extends AbstractPlugin implements IListener {
382382
And `.register()` method receives a `Command` object
383383
instance, a `Command` instance should be constructed by the `CommandBuilder`:
384384
```java
385-
Command command = new CommandBuilder().withName('commandName').build((response) -> {});
385+
Command command = new CommandBuilder().withName('commandName').build((response, botInstance) -> {});
386386
```
387387
`CommandBuilder` has multiple optional chaining methods other from `.withName()`, including:
388388
- `.withName(String cmd)`: Specify command name for executing.
@@ -394,7 +394,7 @@ public class ExamplePlugin extends AbstractPlugin implements IListener {
394394
```java
395395
@Override
396396
public void onEnable(AbstractRobot abstractRobot) {
397-
getCommands().register(new CommandBuilder().withName("test").allowedUsers("PlayerName").build((response) -> {
397+
getCommands().register(new CommandBuilder().withName("test").allowedUsers("PlayerName").build((response, botInstance) -> {
398398
String[] subCommand = response.getCommandList(); // get command list contains main-command and sub-command.
399399

400400
getLogger().info(Arrays.toString(subCommand));
@@ -407,7 +407,7 @@ public class ExamplePlugin extends AbstractPlugin implements IListener {
407407
```java
408408
@Override
409409
public void onEnable(AbstractRobot abstractRobot) {
410-
getCommands().register(new CommandBuilder().withName("uid").allowedUsers("Melibertan").build((response) -> {
410+
getCommands().register(new CommandBuilder().withName("uid").allowedUsers("Melibertan").build((response, botInstance) -> {
411411
String[] subCommand = response.getCommandList(); // get command list contains main-command and sub-command.
412412
String commandSender = response.getSender(); // get player who have sent this command.
413413
}));

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,20 +285,22 @@ each profile name, should be split with ";".
285285
{
286286
"server": "2b2t.xin",
287287
"port": 25565,
288-
"auto-reconnecting": true,
288+
"auto-reconnect": true,
289289
"packet-filter-delay": 0,
290-
"msg-send-delay": 3000,
290+
"msg-send-delay": 0,
291291
"max-chunk-view": 12,
292+
"anti-AFK": true,
293+
"language": "zh",
292294
"connect-timing-out": 2000,
293-
"reconnect-delay": 1000,
295+
"reconnect-delay": 5000,
294296
"debug-settings": {
295297
"enable-packet-debug": false,
296298
"packet-warning": true
297299
},
298300
"other": {
299-
"enable-skin-recorder": true
301+
"enable-skin-recorder": false
300302
}
301-
}
303+
}
302304
```
303305
### Config Options:
304306
@@ -315,6 +317,8 @@ each profile name, should be split with ";".
315317
| `msg-send-delay` | The delay of sending in-game messages. |
316318
| `enable-packet-debug` | Whether enable packet debugger. |
317319
| `packet-warning` | Showing packet errors or not. |
320+
| `language` | The UI locale settings. (Supports `zh`, `en` languages currently) |
321+
| `anti-AFK` | Whether bypassing AFK(Away From Keyboard) detection. |
318322
319323
## Hot Swapping Plugins In-Game
320324
Dolphin bot supports you to **hot-reload** and **hot-load** (**hot injection**) plugins in server, without quit the entire client and reconnecting to server.

pom.xml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ DolphinBot - https://github.com/NeonAngelThreads/DolphinBot
4+
~ Copyright (C) 2025 NeonAngelThreads (https://github.com/NeonAngelThreads)
5+
~
6+
~ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
7+
~ License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any
8+
~ later version.
9+
~
10+
~ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
11+
~ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
12+
~ License for more details. You should have received a copy of the GNU General Public License along with this
13+
~ program. If not, see <https://www.gnu.org/licenses/>.
14+
~
15+
~ https://space.bilibili.com/386644641
16+
-->
17+
218
<project xmlns="http://maven.apache.org/POM/4.0.0"
319
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
420
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
521
<modelVersion>4.0.0</modelVersion>
622

723
<groupId>org.angellock.impl</groupId>
824
<artifactId>DolphinBot</artifactId>
9-
<version>1.2.4-RELEASE-full</version>
25+
<version>1.3.0-ALPHA-full</version>
1026
<packaging>
1127
jar
1228
</packaging>

src/main/java/org/angellock/impl/AbstractRobot.java

Lines changed: 26 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
/*
2-
* DolphinBot - https://github.com/NeonAngelThreads/DolphinBot
3-
* Copyright (C) 2025 NeonAngelThreads (https://github.com/NeonAngelThreads)
2+
* DolphinBot - https://github.com/NeonAngelThreads/DolphinBot
3+
* Copyright (C) 2025 NeonAngelThreads (https://github.com/NeonAngelThreads)
44
*
5-
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6-
* License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any
7-
* later version.
5+
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6+
* License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any
7+
* later version.
88
*
9-
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10-
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
11-
* License for more details. You should have received a copy of the GNU General Public License along with this
12-
* program. If not, see <https://www.gnu.org/licenses/>.
9+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10+
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
11+
* License for more details. You should have received a copy of the GNU General Public License along with this
12+
* program. If not, see <https://www.gnu.org/licenses/>.
1313
*
14-
* https://space.bilibili.com/386644641
14+
* https://space.bilibili.com/386644641
1515
*/
1616

1717
package org.angellock.impl;
1818

1919

2020
import com.google.gson.JsonElement;
2121
import lombok.Getter;
22+
import lombok.Setter;
2223
import org.angellock.impl.commands.CommandSpec;
2324
import org.angellock.impl.events.IConnectListener;
2425
import org.angellock.impl.events.IDisconnectListener;
25-
import org.angellock.impl.events.handlers.ChatCommandHandler;
26-
import org.angellock.impl.events.handlers.KeepAliveHandler;
27-
import org.angellock.impl.events.handlers.PlayerEmergeHandler;
28-
import org.angellock.impl.events.handlers.ServerChatCommandHandler;
26+
import org.angellock.impl.events.TranslatableBundle;
27+
import org.angellock.impl.events.handlers.*;
2928
import org.angellock.impl.events.packets.EntityMovePacket;
3029
import org.angellock.impl.events.packets.PlayerPositionPacket;
3130
import org.angellock.impl.events.packets.debugger.PacketDebugger;
@@ -40,7 +39,6 @@
4039
import org.angellock.impl.plugin.SessionProvider;
4140
import org.angellock.impl.util.ConsoleTokens;
4241
import org.angellock.impl.util.PlainTextSerializer;
43-
import org.angellock.impl.util.math.Position;
4442
import org.geysermc.mcprotocollib.network.BuiltinFlags;
4543
import org.geysermc.mcprotocollib.network.ProxyInfo;
4644
import org.geysermc.mcprotocollib.network.Session;
@@ -63,18 +61,22 @@ public abstract class AbstractRobot implements ISendable, SessionProvider, IOpti
6361
protected TcpClientSession serverSession;
6462
protected static final Logger log = LoggerFactory.getLogger(ConsoleTokens.colorizeText("&aDolphinBot"));
6563
private final ScheduledExecutorService reconnectScheduler = Executors.newScheduledThreadPool(1);
64+
@Getter
6665
protected final PluginManager pluginManager;
6766
protected MinecraftProtocol minecraftProtocol;
6867
protected ConfigManager globalConfig;
6968
protected long connectDuration;
7069
protected boolean isByPassedVerification = true;
71-
protected GameMode serverGamemode = GameMode.ADVENTURE;
70+
@Setter
71+
protected @Getter GameMode serverGamemode = GameMode.ADVENTURE;
72+
@Getter
7273
private ChatMessageManager messageManager;
74+
@Getter
7375
private BotManager botManager;
74-
protected Position loginPos = new Position();
7576
protected ProxyInfo proxyInfo;
7677
protected @Getter ProfileObject infoHelper = new ProfileObject();
7778

79+
@Getter
7880
protected final TerminalCommandManager commandManager = new TerminalCommandManager();
7981
protected final CommandSpec commands = new CommandSpec(this);
8082

@@ -128,10 +130,6 @@ public AbstractRobot buildProtocol(){
128130
return this;
129131
}
130132

131-
public TerminalCommandManager getCommandManager() {
132-
return commandManager;
133-
}
134-
135133
public DolphinConfig config() {
136134
return this.globalConfig.config();
137135
}
@@ -140,10 +138,6 @@ public String getPassword(){
140138
return this.infoHelper.getPassword();
141139
}
142140

143-
public ChatMessageManager getMessageManager() {
144-
return messageManager;
145-
}
146-
147141
public void connect(){
148142
onPreLogin();
149143
if (this.proxyInfo != null) {
@@ -156,21 +150,14 @@ public void connect(){
156150

157151
this.serverSession.addListener((IConnectListener) event -> onJoin());
158152

159-
this.serverSession.addListener((IDisconnectListener) event -> {
160-
PlainTextSerializer serializer = new PlainTextSerializer();
161-
String text = serializer.serialize(event.getReason());
162-
if (text.isBlank()) {
163-
text = (event.getReason().toString());
164-
}
165-
onQuit(text);
166-
});
153+
this.serverSession.addListener(new DisconnectReasonHandler(this));
167154

168155
this.serverSession.addListener(new ServerChatCommandHandler(this.commands));
169156
this.serverSession.addListener(new ChatCommandHandler(this.commands));
170157
this.serverSession.addListener(new EntityMovePacket());
171158
this.serverSession.addListener(new PlayerEmergeHandler());
172-
this.serverSession.addListener(new PlayerPositionPacket(this));
173-
this.serverSession.addListener(new KeepAliveHandler());
159+
this.serverSession.addListener(new PlayerPositionPacket((RobotPlayer) this));
160+
//this.serverSession.addListener(new KeepAliveHandler());
174161
if (this.config().getDebugSettings().isEnablePacketDebug()) {
175162
this.serverSession.addListener(new PacketDebugger());
176163
}
@@ -204,20 +191,21 @@ public void connect(){
204191
}
205192
}
206193
catch (InterruptedException e){
207-
this.serverSession.disconnect("Interrupted");
208194
throw new RuntimeException(e);
209-
} catch (IllegalArgumentException ignore) {
210-
log.warn(ConsoleTokens.colorizeText("&6Unregistered packet error has been triggered!"));
195+
} catch (IllegalArgumentException e) {
196+
TranslatableBundle.warnTranslatableOf(EnumSystemEvents.PACKET_ERROR, e);
211197
}
212198
}
213199
} finally {
200+
this.serverSession.disconnect("Interrupted");
214201
scheduleReconnect();
215202
}
216203
}
217204

218205
public abstract boolean canSendMessages();
219206

220207
public void scheduleReconnect() {
208+
TranslatableBundle.infoTranslatableOf(EnumSystemEvents.RECONNECT);
221209
try {
222210
Thread.sleep(this.config().getReconnectDelay());
223211
} catch (InterruptedException e) {
@@ -244,10 +232,6 @@ public Session getSession(){
244232
return this.serverSession;
245233
}
246234

247-
public PluginManager getPluginManager() {
248-
return pluginManager;
249-
}
250-
251235
public long getConnectTime() {
252236
return connectDuration;
253237
}
@@ -265,14 +249,6 @@ public AbstractRobot withProfileName(String name) {
265249
return this;
266250
}
267251

268-
public GameMode getServerGamemode() {
269-
return serverGamemode;
270-
}
271-
272-
public void setServerGamemode(GameMode serverGamemode) {
273-
this.serverGamemode = serverGamemode;
274-
}
275-
276252
public Map<UUID, Player> getOnlinePlayers() {
277253
return PlayerTracker.getOnlinePlayers();
278254
}

src/main/java/org/angellock/impl/ChatMessageManager.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
/*
2-
* DolphinBot - https://github.com/NeonAngelThreads/DolphinBot
3-
* Copyright (C) 2025 NeonAngelThreads (https://github.com/NeonAngelThreads)
2+
* DolphinBot - https://github.com/NeonAngelThreads/DolphinBot
3+
* Copyright (C) 2025 NeonAngelThreads (https://github.com/NeonAngelThreads)
44
*
5-
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6-
* License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any
7-
* later version.
5+
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6+
* License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any
7+
* later version.
88
*
9-
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10-
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
11-
* License for more details. You should have received a copy of the GNU General Public License along with this
12-
* program. If not, see <https://www.gnu.org/licenses/>.
9+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10+
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
11+
* License for more details. You should have received a copy of the GNU General Public License along with this
12+
* program. If not, see <https://www.gnu.org/licenses/>.
1313
*
14-
* https://space.bilibili.com/386644641
14+
* https://space.bilibili.com/386644641
1515
*/
1616

1717
package org.angellock.impl;
1818

19+
import lombok.Getter;
1920
import org.angellock.impl.util.ConsoleTokens;
20-
import org.geysermc.mcprotocollib.network.Session;
2121
import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket;
2222
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundChatCommandPacket;
2323
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundChatPacket;
@@ -31,6 +31,7 @@
3131

3232
public class ChatMessageManager{
3333
protected static final Logger log = LoggerFactory.getLogger(ConsoleTokens.colorizeText("&7ChatMessageManager"));
34+
@Getter
3435
private final Queue<String> chatMessageQueue = new ArrayDeque<>();
3536
private final AbstractRobot instance;
3637

@@ -61,7 +62,7 @@ private void sendMessagePacket(String message){
6162
log.info(ConsoleTokens.colorizeText("&7Sending in-game chat message: &b&l&o{}"), message);
6263
this.instance.sendPacket(msgPacket);
6364
} else {
64-
boolean valid = this.instance.commandManager.callCommand(message);
65+
boolean valid = this.instance.commandManager.callCommand(message, instance);
6566
if(!valid){
6667
MinecraftPacket cmd = new ServerboundChatCommandPacket(message.replaceFirst("/", ""));
6768
log.info(ConsoleTokens.colorizeText("&6Sending chat Command: &b&l&o{}"), message);
@@ -70,7 +71,4 @@ private void sendMessagePacket(String message){
7071
}
7172
}
7273

73-
public Queue<String> getChatMessageQueue() {
74-
return chatMessageQueue;
75-
}
7674
}

0 commit comments

Comments
 (0)