Skip to content

Commit 4c800d9

Browse files
Merge remote-tracking branch 'origin/master'
2 parents 3825269 + 53c6726 commit 4c800d9

File tree

5 files changed

+48
-40
lines changed

5 files changed

+48
-40
lines changed

PluginDocs.md

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

43-
import org.angellock.impl.AbstractRobot;
43+
import org.angellock.impl.RobotPlayer;
4444
import org.angellock.impl.events.handlers.LoginHandler;
4545
import org.angellock.impl.providers.AbstractPlugin;
4646

@@ -73,7 +73,7 @@ In this section, you will learn:
7373
}
7474

7575
@Override
76-
public void onEnable(AbstractRobot entityBot) {
76+
public void onEnable(RobotPlayer entityBot) {
7777
getListeners().add(
7878
new LoginHandler().addExtraAction((loginPacket) -> {
7979
getLogger().info(loginPacket.getCommonPlayerSpawnInfo().getGameMode().name());
@@ -117,7 +117,7 @@ These methods aiming to build the chain calling style for simplicity.
117117
import org.angellock.impl.api.state.LoginStateMachine;
118118

119119
@Override
120-
public void onEnable(AbstractRobot entityBot) {
120+
public void onEnable(RobotPlayer entityBot) {
121121

122122
LoginStateMachine loginStateMachine = new LoginStateMachine();
123123

@@ -150,7 +150,7 @@ you can simply add `.and()` branch statement in that state node. **For example:*
150150
import org.angellock.impl.api.state.LoginStateMachine;
151151

152152
@Override
153-
public void onEnable(AbstractRobot entityBot) {
153+
public void onEnable(RobotPlayer entityBot) {
154154

155155
LoginStateMachine loginStateMachine = new LoginStateMachine();
156156

@@ -161,8 +161,8 @@ public void onEnable(AbstractRobot entityBot) {
161161
.source(LoginState.VERIFY).whenReceive("机器人验证已完毕").goal(LoginState.REGISTER, registerAction)
162162
.source(LoginState.REGISTER).whenReceive("已成功注册").goal(LoginState.JOIN, joinAction)
163163
.source(LoginState.LOGIN).whenReceive("已成功登录").goal(LoginState.JOIN, joinAction)
164-
.resetOnlyWhen(KickReason.HUMAN_VERIFICATION).
165-
build(); // This method will build the state machine object without return value
164+
.resetOnlyWhen(KickReason.HUMAN_VERIFICATION)
165+
.build(); // This method will build the state machine object without return value
166166
}
167167
```
168168
**Explanation:**
@@ -249,7 +249,7 @@ Added below code to `onEnable()` method in `ExamplePlugin`:
249249
```java
250250
...
251251
@Override
252-
public void onEnable(AbstractRobot entityBot) {
252+
public void onEnable(RobotPlayer entityBot) {
253253
registerEvent(new MyListener());
254254
}
255255
```
@@ -267,7 +267,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.type.EntityType;
267267

268268
public class ExamplePlugin extends AbstractPlugin implements IListener {
269269
@Override
270-
public void onEnable(AbstractRobot entityBot) {
270+
public void onEnable(RobotPlayer entityBot) {
271271
registerEvent(this); // Because plugin class implemented IListener, so it is also a Listener Type.
272272
}
273273

@@ -329,7 +329,7 @@ public class ExamplePlugin extends AbstractPlugin implements IListener {
329329

330330
````java
331331
@Override
332-
public void onEnable(AbstractRobot entityBot) {
332+
public void onEnable(RobotPlayer entityBot) {
333333
getListeners().add(
334334
new LoginHandler().addExtraAction((loginPacket) -> {
335335
getLogger().info(loginPacket.getCommonPlayerSpawnInfo().getGameMode());
@@ -366,7 +366,7 @@ public class ExamplePlugin extends AbstractPlugin implements IListener {
366366
import org.angellock.impl.extensions.examples.MyHandler;
367367

368368
@Override
369-
public void onEnable(AbstractRobot entityBot) {
369+
public void onEnable(RobotPlayer entityBot) {
370370
getListeners().add(
371371
new MyHandler().addExtraAction((playerChatPacket) -> {
372372
getLogger().info(playerChatPacket.getContent()); // Example Action.
@@ -396,7 +396,7 @@ public class ExamplePlugin extends AbstractPlugin implements IListener {
396396
and prints sub-commands you passed, the code looks like this:
397397
```java
398398
@Override
399-
public void onEnable(AbstractRobot abstractRobot) {
399+
public void onEnable(RobotPlayer robot) {
400400
getCommands().register(new CommandBuilder().withName("test").allowedUsers("PlayerName").build((response, botInstance) -> {
401401
String[] subCommand = response.getCommandList(); // get command list contains main-command and sub-command.
402402

@@ -409,7 +409,7 @@ public class ExamplePlugin extends AbstractPlugin implements IListener {
409409
**An Example of getting command-sender and command list:**
410410
```java
411411
@Override
412-
public void onEnable(AbstractRobot abstractRobot) {
412+
public void onEnable(RobotPlayer robot) {
413413
getCommands().register(new CommandBuilder().withName("uid").allowedUsers("Melibertan").build((response, botInstance) -> {
414414
String[] subCommand = response.getCommandList(); // get command list contains main-command and sub-command.
415415
String commandSender = response.getSender(); // get player who have sent this command.
@@ -452,12 +452,12 @@ public class ExampleMessageListener implements IListener {
452452
Step 2:
453453

454454
```java
455-
import org.angellock.impl.AbstractRobot;
455+
import org.angellock.impl.RobotPlayer;
456456
import org.angellock.impl.plugin.AbstractPlugin;
457457

458458
public class MessagePlugin extends AbstractPlugin {
459459
@Override
460-
public void onEnable(AbstractRobot robot){
460+
public void onEnable(RobotPlayer robot){
461461
getEvents().registerListeners(new ExampleMessageListener(), this);
462462
}
463463
}
@@ -471,7 +471,7 @@ import org.angellock.impl.plugin.AbstractPlugin;
471471

472472
public class SendMsgPlugin extends AbstractPlugin {
473473
@Override
474-
public void onEnable(AbstractRobot robot) {
474+
public void onEnable(RobotPlayer robot) {
475475
if (...){ // when the sending condition is meet
476476
BotManager.getBotByName("bot#1") // you can specify on which bot you want to send to. (you define on config file)
477477
.callHandleableEvent(new MessageBroadcastEvent("something you want to send"));
@@ -493,9 +493,9 @@ DolphinAPI also implemented player event system, allowing you to detect and pred
493493
import org.angellock.impl.providers.AbstractPlugin;
494494
public class TestPlayerPlugin extends AbstractPlugin {
495495
@Override
496-
public void onEnable(AbstractRobot abstractRobot) {
496+
public void onEnable(RobotPlayer robot) {
497497
getListeners().add(new EntityMovePacket().addExtraAction((movepacket)->{
498-
getLogger().info("Moving player position: "+abstractRobot.getOnlinePlayers().get(movepacket.getEntityId()).getPosition());
498+
getLogger().info("Moving player position: "+robot.getOnlinePlayers().get(movepacket.getEntityId()).getPosition());
499499
}));
500500
}
501501

@@ -524,11 +524,11 @@ DolphinAPI also implemented player event system, allowing you to detect and pred
524524
import org.angellock.impl.ingame.IPlayer;
525525
...
526526
@Override
527-
public void onEnable(AbstractRobot abstractRobot) {
528-
IPlayer target = abstractRobot.getOnlinePlayers().get(movepacket.getEntityId());
527+
public void onEnable(RobotPlayer robot) {
528+
IPlayer target = robot.getOnlinePlayers().get(movepacket.getEntityId());
529529
if(target != null){
530-
if(target.getPosition().getDistance(abstractRobot.getPosition()) < 7){
531-
abstractRobot.getSession().disconnect("Test");
530+
if(target.getPosition().getDistance(robot.getPosition()) < 7){
531+
robot.getSession().disconnect("Test");
532532
}
533533
}
534534
}

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,14 @@
8787
- You can send in-game messages or execute commands form the dolphin bot terminal.
8888
- Built-in commands:
8989
-
90-
| Terminal Commands | Description |
91-
|:--------------------------------------------:|-----------------------------------------------------|
92-
| `reload <plugin Name> [bot name]` | Hot-reloading a specified plugin |
93-
| `load <pLugin Name> [bot name]` | Hot-loading a specified plugin |
94-
| `respawn` | Respawn the bot when in game. |
95-
| `license` (`l`, `lic`) | Show the license on the terminal |
96-
| `help` (`h`, `?`) | Show the Command menu and usages for each command |
90+
| Terminal Commands | Description |
91+
|:---------------------------------:|---------------------------------------------------|
92+
| `reload <plugin Name> [bot name]` | Hot-reloading a specified plugin |
93+
| `load <pLugin Name> [bot name]` | Hot-loading a specified plugin |
94+
| `reconnect` (`rc`) | Reconnect to the server in game. |
95+
| `license` (`l`, `lic`) | Show the license on the terminal |
96+
| `help` (`h`, `?`) | Show the Command menu and usages for each command |
97+
| `respawn` (`rs`) | Respawn the bot. |
9798

9899
- For these commands, you can press `TAB` to complete automatically.
99100
## Getting Started

README_CN.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,14 @@
8888
- 您可以通过 DolphinBot 终端发送游戏消息,或执行命令。
8989
- 内置命令:
9090
-
91-
| 终端命令 | 用途描述 |
92-
|-----------------------------|---------------|
93-
| `reload <插件名称> [机器人名称]` | 热重载指定的插件 |
94-
| `load <插件名称> [机器人名称]` | 热加载(热注入)指定的插件 |
95-
| `respawn` | 在游戏中重生机器人 |
96-
| `license` (`l`, `lic`) | 在终端显示许可证 |
97-
| `help` (`h`, `?`) | 显示命令菜单和每个命令的用法 |
91+
| 终端命令 | 用途描述 |
92+
|---------------------------|----------------|
93+
| `reload <插件名称> [机器人名称]` | 热重载指定的插件 |
94+
| `load <插件名称> [机器人名称]` | 热加载(热注入)指定的插件 |
95+
| `respawn` | 在游戏中重生机器人 |
96+
| `license` (`l`, `lic`) | 在终端显示许可证 |
97+
| `reconnnect` (`rc`) | 重新连接服务器 |
98+
| `help` (`h`, `?`) | 显示命令菜单和每个命令的用法 |
9899

99100
- 对于这些命令,您可以按`TAB`键自动补全。
100101
## 快速入门

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<artifactId>DolphinBot</artifactId>
2525
<name>DolphinBot</name>
2626
<description>Advanced Bot Cluster Framework for Minecraft</description>
27-
<version>1.4.1-RELEASE-full</version>
27+
<version>1.4.2-RELEASE-full</version>
2828
<packaging>
2929
jar
3030
</packaging>

src/main/java/org/angellock/impl/win32terminal/SystemTabCompleter.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.angellock.impl.commands.AbstractCommand;
2020
import org.angellock.impl.commands.ICommandCompleter;
2121
import org.angellock.impl.commands.terminal.TerminalCommand;
22+
import org.angellock.impl.ingame.PlayerTracker;
2223
import org.angellock.impl.managers.TerminalCommandManager;
2324
import org.angellock.impl.plugin.PluginManager;
2425
import org.jline.reader.Candidate;
@@ -28,9 +29,7 @@
2829
import org.jline.utils.AttributedStringBuilder;
2930
import org.jline.utils.AttributedStyle;
3031

31-
import java.util.ArrayList;
32-
import java.util.HashMap;
33-
import java.util.List;
32+
import java.util.*;
3433

3534
public class SystemTabCompleter implements Completer {
3635
private static SystemTabCompleter completer;
@@ -61,13 +60,20 @@ public void complete(LineReader lineReader, ParsedLine parsedLine, List<Candidat
6160

6261
String inputCommand = line.replaceFirst("/", "");
6362
for (TerminalCommand cmd : commands.values()) {
64-
appendCandidate(list, cmd.getName(), cmd.getDescription());
63+
if (cmd.getName().contains(inputCommand)) {
64+
appendCandidate(list, cmd.getName(), cmd.getDescription());
65+
}
6566
for (String alias : cmd.getAliases()) {
6667
if (alias.contains(inputCommand)) {
6768
appendCandidate(list, alias, cmd.getDescription());
6869
}
6970
}
7071
}
72+
if(list.isEmpty()){
73+
PlayerTracker.getPlayerUUIDMapping().forEach(
74+
(name, uuid) -> appendCandidate(list, name, uuid.toString())
75+
);
76+
}
7177
}
7278

7379
private static void appendCandidate(List<Candidate> list, String name, String desc) {

0 commit comments

Comments
 (0)