diff --git a/common/src/main/java/cn/evole/mods/mcbot/api/action/ActionPath.java b/common/src/main/java/cn/evole/mods/mcbot/api/action/ActionPath.java index 24d4ae2..e0e5742 100644 --- a/common/src/main/java/cn/evole/mods/mcbot/api/action/ActionPath.java +++ b/common/src/main/java/cn/evole/mods/mcbot/api/action/ActionPath.java @@ -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, diff --git a/common/src/main/java/cn/evole/mods/mcbot/common/config/BotConfig.java b/common/src/main/java/cn/evole/mods/mcbot/common/config/BotConfig.java index 4c20ca2..a3f942c 100644 --- a/common/src/main/java/cn/evole/mods/mcbot/common/config/BotConfig.java +++ b/common/src/main/java/cn/evole/mods/mcbot/common/config/BotConfig.java @@ -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("自动重连") @@ -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); } } diff --git a/common/src/main/java/cn/evole/mods/mcbot/plugins/action/ActionHandler.java b/common/src/main/java/cn/evole/mods/mcbot/plugins/action/ActionHandler.java index 036243b..9b3a763 100644 --- a/common/src/main/java/cn/evole/mods/mcbot/plugins/action/ActionHandler.java +++ b/common/src/main/java/cn/evole/mods/mcbot/plugins/action/ActionHandler.java @@ -12,5 +12,4 @@ */ public class ActionHandler { private static final File dir = Constants.CONFIG_FOLDER.resolve("actions").toFile(); - } diff --git a/common/src/main/java/cn/evole/mods/mcbot/util/CmdUtils.java b/common/src/main/java/cn/evole/mods/mcbot/util/CmdUtils.java index c58ef09..25c0007 100644 --- a/common/src/main/java/cn/evole/mods/mcbot/util/CmdUtils.java +++ b/common/src/main/java/cn/evole/mods/mcbot/util/CmdUtils.java @@ -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) ); diff --git a/common/src/main/java/cn/evole/mods/mcbot/util/onebot/BotUtils.java b/common/src/main/java/cn/evole/mods/mcbot/util/onebot/BotUtils.java deleted file mode 100644 index d79df8b..0000000 --- a/common/src/main/java/cn/evole/mods/mcbot/util/onebot/BotUtils.java +++ /dev/null @@ -1,84 +0,0 @@ -//package cn.evole.mods.mcbot.util.onebot; -// -//import cn.evole.onebot.sdk.event.message.GroupMessageEvent; -//import lombok.val; -// -//import java.util.concurrent.atomic.AtomicBoolean; -// -///** -// * Project: Bot-Connect-fabric-1.18 -// * Author: cnlimiter -// * Date: 2023/1/21 19:04 -// * Description: -// */ -//public class BotUtils { -// /** -// * q群消息是否存在变量 -// * -// * @param msg q群消息 -// * @return 是否存在变量 -// */ -// -// private static boolean isVar(String msg) { -// AtomicBoolean match = new AtomicBoolean(false); -// CustomCmdHandler.INSTANCE.getCustomCmds().forEach( -// cmd -> { -// if (cmd.getCmdContent().contains("%") | cmd.getCmdContent().contains("#")) {//是否变量模板 -// if (msg.contains(cmd.getCmdAlies()))//去除命令符号 -// match.set(true); -// } -// -// } -// ); -// return match.get(); -// } -// -// /** -// * 变量解析 -// * -// * @param customCmd 自定义实例 -// * @param cmd q群指令 -// * @return 处理完的指令 -// */ -// public static String varParse(CustomCmd customCmd, String cmd, GroupMessageEvent event) { -// String returnCmd = ""; -// if (isVar(cmd)) {//存在变量 -// val replaceContent = customCmd.getCmdContent().split("%")[0].trim(); -// returnCmd = cmd.replace(customCmd.getCmdAlies(), replaceContent);//返回q群指令 -// returnCmd = returnCmd.replace("#", event.getSender().getUserId()); -// } else returnCmd = customCmd.getCmdContent();//返回普通自定义命令指令 -// return returnCmd; -// } -// -// -// public static boolean groupAdminParse(GroupMessageEvent event) { -// return !event.getSender().getRole().equals("MEMBER") && !event.getSender().getRole().equals("member"); -// } -// -// -// /** -// * 获取字符串%(即变量)出现的个数 -// * -// * @param str 传进来的字符串 -// * @return 统计%出现的个数 -// */ -// private static int getSubStr(String str) { -// // 用空字符串替换所有要查找的字符串 -// String destStr = str.replaceAll("%", ""); -// // 查找字符出现的个数 = (原字符串长度 - 替换后的字符串长度)/要查找的字符串长度 -// return (str.length() - destStr.length()) / "%".length(); -// } -// public static String cmdParse(String command) { -// // 找到最后一个空格的位置 -// int lastSpaceIndex = command.lastIndexOf(" "); -// -// // 如果没有空格,则整个命令就是关键词 -// if (lastSpaceIndex == -1) { -// return command; -// } -// -// // 返回最后一个空格之前的内容 -// return command.substring(0, lastSpaceIndex); -// } -// -//} diff --git a/gradle.properties b/gradle.properties index dc4b82d..57d3744 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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