Skip to content

Commit 3f8eae3

Browse files
[-] Removed unsafe reflection in Listeners
[#] Improved code quality. [+] Added submodule `DolphinStudio` in project. [#] Changed config file name to bot.config.global.json [#] Updated README [+] Added Server info display on web dashboard. [+] Synchronized chinese README_CN.md with README.md
1 parent ef9b30c commit 3f8eae3

20 files changed

+72
-53
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "DolphinStudio"]
2+
path = DolphinStudio
3+
url = https://github.com/NeonAngelThreads/DolphinStudio

DolphinStudio

Submodule DolphinStudio added at d091230

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ In this section, you will understand below how-tos:
157157
`--owner=owner1;owner2;owner3;...`
158158
159159
### Config File Setting
160-
Config files include functional config `mc.bot.config.json` and profile config `bot.profiles.json`
160+
Config files include functional config `bot.config.global.json` and profile config `bot.profiles.json`
161161
You can also move above profile arguments into config file ``bot.profiles.json`` following below formats, all config values in it will be loaded.
162162
DolphinBot will apply command-line options first, duplicated options in config file will be ignored.
163163
To specify the path of config file is optional, Use option `--config-file` to locate config directory or file.
@@ -286,7 +286,7 @@ each profile name, should be split with ";".
286286
}
287287
```
288288
### Advanced Configurations (optional)
289-
If you want to access more advanced configs, you can edit `mc.bot.config.json`.
289+
If you want to access more advanced configs, you can edit `bot.config.global.json`.
290290
Every single config option is equilibrium to option that defined by command line, and all config value including
291291
unrecognized option will be parsed, so you can add your customize config options.
292292
An example for configuring this file:

README_CN.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
您还可以通过添加参数来指定更多选项:
139139
`--owner` : 仅指定哪些人可以使用此机器人。
140140
2. **配置文件设置**
141-
配置文件包括功能配置文件 `mc.bot.config.json` 和账户配置文件 `bot.profiles.json`
141+
配置文件包括功能配置文件 `bot.config.global.json` 和账户配置文件 `bot.profiles.json`
142142
您还可以按照以下格式将上述配置文件参数移至配置文件`bot.profiles.json`中,其中的所有配置值都将被加载。
143143
DolphinBot 将首先应用命令行选项,配置文件中重复的选项将被忽略。
144144
指定配置文件路径是可选的,使用选项 `--config-file` 来定位配置目录或文件。
@@ -276,7 +276,7 @@ java -jar "DolphinBot-[version].jar" --profiles="bot#1;bot#2;bot#3;..."
276276
**Example:**
277277
`--owner=owner1;owner2;owner3;...`
278278
1. **高级配置(可选)**
279-
如果你想访问更高级的配置,可以编辑`mc.bot.config.json`
279+
如果你想访问更高级的配置,可以编辑`bot.config.global.json`
280280
每个配置选项都与命令行定义的选项相对应,所有配置值(包括无法识别的选项)都将被解析,因此您可以添加自定义配置选项。
281281
配置此文件的示例:
282282
```json
@@ -332,8 +332,8 @@ DolphinBot现在包含内置的Web控制台,支持远程机器人管理和控
332332
java -jar "DolphinBot-[version]-full.jar" --api [端口]
333333
```
334334

335-
API服务器将在指定端口启动(默认:25560),WebSocket日志服务器将在端口+1启动(默认:25561)。
336-
335+
API服务器将在指定端口启动(默认:25560),WebSocket日志服务器将在端口+1启动(默认:25561)。
336+
如果`--api`命令行参数缺失,API服务器将开启在默认25560端口。
337337
### Web控制台功能
338338
- **机器人管理仪表板** - 查看所有机器人实例,包括实时状态、游戏模式和位置
339339
- **独立终端** - 每个机器人拥有自己的终端实例,支持基于标签页的切换

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ public abstract class AbstractRobot implements ISendable, SessionProvider, IOpti
8888
protected final CommandSpec commands = new CommandSpec(this);
8989

9090
public AbstractRobot(ConfigManager configManager, PluginManager pluginManager){
91-
this.globalConfig = configManager;
91+
this.globalConfig = configManager.buildConfig();
9292
this.infoHelper.setName(this.globalConfig.getConfigValue("username"));
9393
this.infoHelper.setPassword(this.globalConfig.getConfigValue("password"));
94-
this.infoHelper.setServer(this.globalConfig.getCoreSettings().getServer());
95-
this.infoHelper.setPort(this.globalConfig.getCoreSettings().getPort());
94+
this.infoHelper.setServer(this.globalConfig.config().getServer());
95+
this.infoHelper.setPort(this.globalConfig.config().getPort());
9696

9797
this.pluginManager = pluginManager;
9898

@@ -150,8 +150,8 @@ public String getPassword(){
150150

151151
public void connect(){
152152
onPreLogin();
153-
String serverIP = this.infoHelper.getServer() != null ? this.infoHelper.getServer() : this.config().getServer();
154-
int serverPort = this.infoHelper.getPort() != 0 ? this.infoHelper.getPort() : this.config().getPort();
153+
String serverIP = this.infoHelper.getServer();// != null ? this.infoHelper.getServer() : this.config().getServer();
154+
int serverPort = this.infoHelper.getPort();// != 0 ? this.infoHelper.getPort() : this.config().getPort();
155155

156156
if (this.proxyInfo != null) {
157157
this.serverSession = new TcpClientSession(serverIP, serverPort, minecraftProtocol, this.proxyInfo);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void onPreLogin() {
9494
} catch (InterruptedException ignored) {}
9595
}
9696
this.connectTime = System.currentTimeMillis();
97-
log.info(this.getBotLabel(), TranslatableUtil.getFormattedMessage(EnumSystemEvents.CONNECT, this.config().getServer(), String.valueOf(this.config().getPort())));
97+
log.info(this.getBotLabel(), TranslatableUtil.getFormattedMessage(EnumSystemEvents.CONNECT, this.getInfoHelper().getServer(), String.valueOf(this.getInfoHelper().getPort())));
9898
}
9999

100100
@Override

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ public static void main(String[] args) {
8888
}
8989
@Nullable String profiles = (GLOBAL_CONFIG.valueOf(profilesArg));
9090

91-
ConfigManager config = new ConfigManager(GLOBAL_CONFIG, defaultConfigPath);
91+
ConfigManager config = new ConfigManager();
92+
ConfigManager.setDefaultPath(defaultConfigPath);
93+
ConfigManager.initGlobalSettings();
9294
BotManager botManager = new BotManager(defaultConfigPath, ".json", config)
9395
.globalPluginManager(GLOBAL_CONFIG.valueOf(pluginDir))
9496
.loadProfiles(profiles);

src/main/java/org/angellock/impl/api/websocket/handlers/BotsHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public void handleResponse(HttpExchange exchange) throws IOException {
4444
Map<String, Object> botInfo = new HashMap<>();
4545
botInfo.put("name", bot.getInfoHelper().getName());
4646
botInfo.put("profileName", bot.getProfileName());
47+
botInfo.put("address", String.format("%s:%s",bot.getInfoHelper().getServer(), bot.getInfoHelper().getPort()));
4748
botInfo.put("isConnected", bot.getSession() != null && bot.getSession().isConnected());
4849
botInfo.put("gameMode", bot.getServerGamemode() != null ? bot.getServerGamemode().name() : "UNKNOWN");
4950
botInfo.put("position", Map.of(

src/main/java/org/angellock/impl/events/AbstractEventProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public abstract class AbstractEventProcessor<T extends Packet> extends SessionAd
3535
private static final Logger log = LoggerFactory.getLogger(ConsoleTokens.colorizeText("&l&9PacketHandlers"));
3636
private final long DELAY;
3737
protected List<IActions<T>> actionList = new ArrayList<>();
38-
private static final boolean showWarn = ConfigManager.getCoreSettings().getDebugSettings().isShowWarns();
38+
private static final boolean showWarn = false;
3939
protected IActions<T> preAction = (T) -> {
4040
};
4141

src/main/java/org/angellock/impl/events/bukkit/ActiveListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class ActiveListener {
2828
private EventPriority priority = EventPriority.NORMAL;
2929

3030
public ActiveListener(Object listenerInstance, Method action, Class<?> eventType) {
31-
action.setAccessible(true);
31+
// action.setAccessible(true);
3232
this.listenerInstance = listenerInstance;
3333
this.action = action;
3434
this.eventType = eventType;

0 commit comments

Comments
 (0)