Skip to content

Commit d03743e

Browse files
[~] Fixed console colors could not be correctly displayed in Windows terminal.
[+] Added 13 new different packet event. [+] Supported reloading a plugin without restarting. [+] Added UStringHelper for forcing unicode string converts. [+] Added More Util classes. [+] Added Win32ColorSerializer for windows style color rendering. [~] Improved packet listening system [~] Added Player interfaces for plugin development [~] Improved Logging system.
1 parent 2c85cfe commit d03743e

Some content is hidden

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

54 files changed

+767
-254
lines changed

PluginDocs.md

Lines changed: 103 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -40,49 +40,48 @@ In this section, you will learn:
4040
````java
4141
package org.angellock.impl.extensions;
4242

43-
import org.angellock.impl.AbstractRobot;
44-
import org.angellock.impl.events.packets.LoginHandler;
45-
import org.angellock.impl.providers.AbstractPlugin;
46-
import org.angellock.impl.util.ConsoleTokens;
47-
48-
public class ExamplePlugin extends AbstractPlugin {
49-
@Override
50-
public String getPluginName() {
51-
return "My First Plugin";
52-
}
53-
54-
@Override
55-
public String getVersion() {
56-
return "1.0.0";
57-
}
58-
59-
@Override
60-
public String getDescription() {
61-
return "Hello DolphinBot";
62-
}
63-
64-
@Override
65-
public void onDisable() {
66-
getLogger().info("Disabling {} - {}", this.getName(), getVersion());
67-
//Disable Message
68-
}
69-
70-
@Override
71-
public void onLoad() {
72-
getLogger().info("Loading {} - {}", this.getName(), getVersion());
73-
// Loading Plugin Message
74-
}
75-
76-
@Override
77-
public void onEnable(AbstractRobot entityBot) {
78-
getListeners().add(
79-
new LoginHandler().addExtraAction((loginPacket) -> {
80-
getLogger().info(loginPacket.getCommonPlayerSpawnInfo().getGameMode().name());
81-
})
82-
);
83-
}
43+
import org.angellock.impl.AbstractRobot;
44+
import org.angellock.impl.events.handlers.LoginHandler;
45+
import org.angellock.impl.providers.AbstractPlugin;
46+
47+
public class ExamplePlugin extends AbstractPlugin {
48+
@Override
49+
public String getPluginName() {
50+
return "My First Plugin";
8451
}
8552

53+
@Override
54+
public String getVersion() {
55+
return "1.0.0";
56+
}
57+
58+
@Override
59+
public String getDescription() {
60+
return "Hello DolphinBot";
61+
}
62+
63+
@Override
64+
public void onDisable() {
65+
getLogger().info("Disabling {} - {}", this.getName(), getVersion());
66+
//Disable Message
67+
}
68+
69+
@Override
70+
public void onLoad() {
71+
getLogger().info("Loading {} - {}", this.getName(), getVersion());
72+
// Loading Plugin Message
73+
}
74+
75+
@Override
76+
public void onEnable(AbstractRobot entityBot) {
77+
getListeners().add(
78+
new LoginHandler().addExtraAction((loginPacket) -> {
79+
getLogger().info(loginPacket.getCommonPlayerSpawnInfo().getGameMode().name());
80+
})
81+
);
82+
}
83+
}
84+
8685
````
8786
- You can also refer to the example plugin in folder `/example-plugin/example_plugin` for help, or you can base on this demo plugin as your template to develop your own plugin.
8887
- After you package your plugin, put the packaged plugin in folder `/plugins`.
@@ -108,24 +107,24 @@ In this section, you will learn:
108107
- **Customize Handlers:**
109108
Excepting implemented handlers, you can make custom packet handlers by **extending** `AbstractEventProcessor` class:
110109
For example, if you want to create a custom handler that listens and handles `ClientboundPlayerChatPacket`, you should **extend**
111-
the `AbstractEventProcessor` class:
110+
the `AbstractEventProcessor` class:
112111
````java
113112
package org.angellock.impl.extensions;
114113

115114
import org.angellock.impl.events.AbstractEventProcessor;
116-
import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket;
115+
import org.geysermc.mcprotocollib.network.packet.Packet;
117116
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundPlayerChatPacket;
118117

119118
public class MyHandler extends AbstractEventProcessor<ClientboundPlayerChatPacket> { // specifying target packet type.
120119
@Override
121-
protected boolean isTargetPacket(MinecraftPacket packet) {
120+
protected boolean isTargetPacket(Packet packet) {
122121
return (packet instanceof ClientboundPlayerChatPacket); // filtering out other packet type.
123122
}
124123
}
125124

126125
````
127126
After that, you can use your packet handler ``MyHandler`` class to register your custom listener at your custom plugin.
128-
By using `.addExtraAction()`, you can add your wanted action towards `MyHandler`. Finally, add it to the global listener.
127+
By using `.addExtraAction()`, you can add your wanted action towards `MyHandler`. Finally, add it to the global listener.
129128
````java
130129
import org.angellock.impl.extensions.examples.MyHandler;
131130

@@ -184,6 +183,65 @@ In this section, you will learn:
184183
- ### 3. Message Manager:
185184
In-game chat messages sends is managed by `MessageManager`.
186185
For each bot individual has a message manager.
186+
## Player Events:
187+
DolphinAPI also implemented player event system, allowing you to detect and predict online players on server.
188+
- `Player` class:
189+
Every `Player` object represents an individual player in the scope of server stimulation distance.
190+
It provides position information. position data is automatically updated by the robot instance.
191+
**An Example of Player Event Use:**
192+
Below code implements that auto capture position of a moving player.
193+
```java
194+
import org.angellock.impl.providers.AbstractPlugin;
195+
public class TestPlayerPlugin extends AbstractPlugin {
196+
@Override
197+
public void onEnable(AbstractRobot abstractRobot) {
198+
getListeners().add(new EntityMovePacket().addExtraAction((movepacket)->{
199+
getLogger().info("Moving player position: "+abstractRobot.getOnlinePlayers().get(movepacket.getEntityId()).getPosition());
200+
}));
201+
}
202+
203+
@Override
204+
public String getPluginName() {
205+
return "TestPlugin";
206+
}
207+
@Override
208+
public String getVersion() {
209+
return "1.0.0";
210+
}
211+
@Override
212+
public String getDescription() {
213+
return "TestPlugin";
214+
}
215+
@Override
216+
public void onDisable() {
217+
getLogger().info("disabling plugin!");
218+
}
219+
}
220+
```
221+
If you want to detect the moving player distance from your bot, you can use `player.getPosition().getDistance(bot.getPosition())`:
222+
**Here is Example:**
223+
This code presents that if a player is 7 blocks close to your bot, bot will auto quit the game.
224+
````java
225+
import org.angellock.impl.ingame.IPlayer;
226+
...
227+
@Override
228+
public void onEnable(AbstractRobot abstractRobot) {
229+
IPlayer target = abstractRobot.getOnlinePlayers().get(movepacket.getEntityId());
230+
if(target != null){
231+
if(target.getPosition().getDistance(abstractRobot.getPosition()) < 7){
232+
abstractRobot.getSession().disconnect("Test");
233+
}
234+
}
235+
}
236+
````
237+
## Unicode String Helper
238+
Dolphin bot provides `UStringHelper` class to help you to convert the common text (including digits) into other Unicode characters,
239+
which can obfuscate server to bypass key word censoring.
240+
**Example:**
241+
````java
242+
String message = "TestText123 789";
243+
String stringUUID = UStringHelper.forceUnicode(message);
244+
````
187245

188246
## 4. How a Plugin Works
189247
1. **Base Plugin Events**:

README.md

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
</a>
1212
<br>
1313
<a href="https://github.com/NeonAngelThreads/DolphinBot/commits/master/">
14-
<img src="https://img.shields.io/github/last-commit/NeonAngelThreads/DolphinBot" alt="Release"/>
14+
<img src="https://img.shields.io/github/last-commit/NeonAngelThreads/DolphinBot" alt="commits"/>
1515
</a>
1616
<img src="https://img.shields.io/github/commit-activity/w/NeonAngelThreads/DolphinBot" alt="GitHub commit activity"/>
17-
<a href="https://github.com/NeonAngelThreads/DolphinBot/releases">
18-
<img src="https://img.shields.io/github/issues/NeonAngelThreads/DolphinBot" alt="Release"/>
17+
<a href="https://github.com/NeonAngelThreads/DolphinBot/issues">
18+
<img src="https://img.shields.io/github/issues/NeonAngelThreads/DolphinBot" alt="issues"/>
19+
</a>
20+
<a href="https://github.com/NeonAngelThreads/DolphinBot/tree/master/src/main">
21+
<img src="https://img.shields.io/github/languages/code-size/NeonAngelThreads/DolphinBot" alt="GitHub code size"/>
1922
</a>
20-
<img src="https://img.shields.io/github/languages/code-size/NeonAngelThreads/DolphinBot" alt="GitHub code size"/>
21-
2223
<p align="center">
2324
<a href="https://github.com/NeonAngelThreads/DolphinBot/blob/master/PluginDocs.md">📖Docs</a>
2425
·
@@ -40,10 +41,16 @@
4041
- Supporting to configure the bot clusters, and start at once.
4142
- Supporting colourful console logging strings expression `colorizeText("&6Hello &lWorld")`.
4243
- Automatic answer questions in `2b2t.xin` for speeding up login process.
44+
- Supporting to reload a plugin while the client is running on server.
4345
## Introduction:
44-
Implemented Event APIs:
45-
- [`Command Systems`](https://github.com/NeonAngelThreads/DolphinBot/)
46-
- [`Packet Handlers`](https://github.com/NeonAngelThreads/DolphinBot/)
46+
**Features category:**
47+
- [`Hot-Reloading Plugin`](#hot-swapping-plugins-in-game)
48+
49+
**Implemented Event APIs:**
50+
- [`Command Systems`](PluginDocs.md#2-commands-system)
51+
- [`Packet Handlers`](PluginDocs.md#3-deep-understand-dolphinapis-)
52+
- [`Player Events`](PluginDocs.md#player-events)
53+
- [`Force Unicode Chat`](PluginDocs.md#unicode-string-helper)
4754

4855
Command-line Arguments
4956
## Getting Started
@@ -55,7 +62,7 @@ In this section, you will understand below how-tos:
5562
- **5. How to make a custom plugin**
5663

5764
1. **Download the Client**
58-
Download the jar archive file: `DolphinBot-[version].jar`.
65+
Download the jar archive file: `DolphinBot-[version]-full.jar`.
5966
Requirements: **Java version >= 17**
6067
2. **Configuration of the Bot**
6168
**Configuring Profile**
@@ -164,12 +171,16 @@ In this section, you will understand below how-tos:
164171
```
165172
Config Options:
166173
167-
Config | Description
168-
----------------------- | -----------
169-
`server` | For defining server address.
170-
`port` | For defining server port.
171-
`auto-reconnecting` | Whether reconnect to server when got kicked or disconnect by some reasons.
172-
`packet-filter-delay` | Max receiving delay(millis) between every target packet.
173-
`max-chunk-view` | Max scale of chunk packet receiving.
174-
`connect-timing-out` | How long millis does it take to determine a connection time out.
175-
`reconnect-delay` | Min delay(millis) for cooling down when reconnect a server.
174+
| Config | Description |
175+
|-----------------------|----------------------------------------------------------------------------|
176+
| `server` | For defining server address. |
177+
| `port` | For defining server port. |
178+
| `auto-reconnecting` | Whether reconnect to server when got kicked or disconnect by some reasons. |
179+
| `packet-filter-delay` | Max receiving delay(millis) between every target packet. |
180+
| `max-chunk-view` | Max scale of chunk packet receiving. |
181+
| `connect-timing-out` | How long millis does it take to determine a connection time out. |
182+
| `reconnect-delay` | Min delay(millis) for cooling down when reconnect a server. |
183+
## Hot Swapping Plugins In-Game
184+
Dolphin bot supports you to hot-reload plugins in server, without quit the entire client and reconnecting to server.
185+
You can send `!reload <pluginName>` dolphin command in server chat.
186+
Console controlling are still in-developing, currently.

mc.bot.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"server": "127.0.0.1",
2+
"server": "2b2t.xin",
33
"port": 25565,
44
"auto-reconnecting": true,
55

pom.xml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.angellock.impl</groupId>
88
<artifactId>DolphinBot</artifactId>
9-
<version>1.1.9-BETA-full</version>
9+
<version>1.1.14-RELEASE-full</version>
1010
<packaging>
1111
jar
1212
</packaging>
@@ -28,7 +28,12 @@
2828
<dependency>
2929
<groupId>org.geysermc.mcprotocollib</groupId>
3030
<artifactId>protocol</artifactId>
31-
<version>1.21-SNAPSHOT</version>
31+
<version>1.21.2-SNAPSHOT</version>
32+
</dependency>
33+
<dependency>
34+
<groupId>net.kyori</groupId>
35+
<artifactId>adventure-text-serializer-json</artifactId>
36+
<version>4.15.0</version>
3237
</dependency>
3338
<dependency>
3439
<groupId>org.jline</groupId>
@@ -48,13 +53,7 @@
4853
<dependency>
4954
<groupId>ch.qos.logback</groupId>
5055
<artifactId>logback-classic</artifactId>
51-
<version>1.5.12</version>
52-
</dependency>
53-
54-
<dependency>
55-
<groupId>net.kyori</groupId>
56-
<artifactId>adventure-text-serializer-json</artifactId>
57-
<version>4.15.0</version>
56+
<version>1.5.18</version>
5857
</dependency>
5958
</dependencies>
6059

0 commit comments

Comments
 (0)