Skip to content

Commit

Permalink
refactor(mcbot): update config and remove unused code
Browse files Browse the repository at this point in the history
- Remove unused BotConfig field for mirai authentication
- Update ActionPath enum description
- Delete unused BotUtils class
- Simplify
  • Loading branch information
cnlimiter committed Oct 25, 2024
1 parent 2bbd36e commit 120f892
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/**
* @Project: McBot
* @Author: cnlimiter
* @CreateTime: 2024/9/11 23:34
* @Description: 用于自定义服务器事件行为
* @CreateTime: 2024/9/15 13:51
* @Description:
*/
public enum ActionPath {
PLAYER_ADVANCEMENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public class BotConfig {
private String url = "ws://127.0.0.1:8080";
@Comment("鉴权")
private String token = "";
@Comment("mirai鉴权方式不一样")
private boolean mirai = false;
@Comment("机器人qq")
private long botId = 0L;//机器人qq
@Comment("自动重连")
Expand All @@ -34,7 +32,7 @@ public class BotConfig {
private long timeoutCompensation = 1000;

public cn.evole.onebot.client.core.BotConfig build() {
return new cn.evole.onebot.client.core.BotConfig(url, token, botId, mirai, reconnect, maxReconnectAttempts);
return new cn.evole.onebot.client.core.BotConfig(url, token, botId, token.startsWith("mirai_"), reconnect, maxReconnectAttempts);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@
*/
public class ActionHandler {
private static final File dir = Constants.CONFIG_FOLDER.resolve("actions").toFile();

}
3 changes: 2 additions & 1 deletion common/src/main/java/cn/evole/mods/mcbot/util/CmdUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public static String findSimpleCmd(String command) {
}

public static boolean hasPermission(String group_id, String user_id, Cmd cmd){
return (UserInfoApi.get(group_id, user_id) != null &&
if (cmd.getId().equals("bind")) return true;
else return (UserInfoApi.get(group_id, user_id) != null &&
UserInfoApi.get(group_id, user_id).getPermissions().contains(ModConfig.get().getBotConfig().getTag() + ".mcbot.cmd." + cmd.getId())
|| cmd.getAllow_members().contains(user_id)
);
Expand Down
84 changes: 0 additions & 84 deletions common/src/main/java/cn/evole/mods/mcbot/util/onebot/BotUtils.java

This file was deleted.

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ credits=
description=Adds chat linking between QQ and Minecraft and QQ commands to request server data.
minecraft_version_range=[1.20, 1.21)
minecraft_version=1.20.1
mod_version_label=alpha2
mod_version_label=alpha3

# Mappings
mappings_channel = parchment
Expand Down

0 comments on commit 120f892

Please sign in to comment.