-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
```refactor(mcbot): refactor command and bot API for permission overh…
…aul- Rename variable 'group_name' to 'group_id' and 'qq_id' to 'user_id' for clarity. - Implement placeholder replacement in commands to allow for dynamic command construction. - Remove unused 'GuildRole' enum. - Add 'PlaceHolderApi' class to handle placeholder replacements. - Update 'UserInfoApi.get' method to accept 'group_id' and 'user_id' as parameters. - Refactor 'CmdUtils' utility methods to support new command parsing logic. - Modify event handling methods to utilize updated command and user info APIs.- Adjust configuration loading and command registration to reflect new permission system. BREAKING CHANGE: Command syntax and permission checks have been overhauled. Existing commands may need to be updated to accommodate new placeholder syntax and permission requirements. Ensure commands are modified accordingly to maintain functionality. ```
- Loading branch information
Showing
17 changed files
with
169 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
common/src/main/java/cn/evole/mods/mcbot/api/placeholder/PlaceHolderApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package cn.evole.mods.mcbot.api.placeholder; | ||
|
||
/** | ||
* @Project: McBot | ||
* @Author: cnlimiter | ||
* @CreateTime: 2024/8/18 14:08 | ||
* @Description: | ||
*/ | ||
public class PlaceHolderApi { | ||
} |
14 changes: 10 additions & 4 deletions
14
common/src/main/java/cn/evole/mods/mcbot/common/command/AddBindCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
package cn.evole.mods.mcbot.common.command; | ||
|
||
import cn.evole.mods.mcbot.api.data.UserInfoApi; | ||
import cn.evole.mods.mcbot.common.config.ModConfig; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
import net.minecraft.commands.CommandSourceStack; | ||
import net.minecraft.network.chat.Component; | ||
|
||
public class AddBindCommand { | ||
|
||
public static int execute(CommandContext<CommandSourceStack> context) throws CommandSyntaxException { | ||
String group_name = context.getArgument("GroupName", String.class); | ||
String qq_id = context.getArgument("QQId", String.class); | ||
String group_id = String.valueOf(context.getArgument("GroupId", Long.class)); | ||
String qq_id = String.valueOf(context.getArgument("QQId", Long.class)); | ||
String game_name = context.getArgument("GameName", String.class); | ||
//UserBindApi.add(group_name, qq_id, game_name); | ||
ModConfig.save(); | ||
if (UserInfoApi.get(group_id, qq_id) == null) { | ||
UserInfoApi.add(group_id, qq_id, game_name); | ||
context.getSource().sendSuccess(() -> Component.literal("群: "+ group_id + " 的用户: " + qq_id + "绑定成功!"), true); | ||
} else { | ||
context.getSource().sendSuccess(() -> Component.literal("群: "+ group_id + " 的用户: " + qq_id + "已经绑定完毕!"), true); | ||
} | ||
return 1; | ||
} | ||
} |
13 changes: 10 additions & 3 deletions
13
common/src/main/java/cn/evole/mods/mcbot/common/command/DelBindCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
package cn.evole.mods.mcbot.common.command; | ||
|
||
import cn.evole.mods.mcbot.api.data.UserInfoApi; | ||
import cn.evole.mods.mcbot.common.config.ModConfig; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
import net.minecraft.commands.CommandSourceStack; | ||
import net.minecraft.network.chat.Component; | ||
|
||
public class DelBindCommand { | ||
|
||
public static int execute(CommandContext<CommandSourceStack> context) throws CommandSyntaxException { | ||
String qq_id = context.getArgument("QQId", String.class); | ||
//UserBindApi.del(qq_id); | ||
ModConfig.save(); | ||
String group_id = String.valueOf(context.getArgument("GroupId", Long.class)); | ||
String qq_id = String.valueOf(context.getArgument("QQId", Long.class)); | ||
if (UserInfoApi.get(group_id, qq_id) != null) { | ||
UserInfoApi.del(group_id, qq_id); | ||
context.getSource().sendSuccess(() -> Component.literal("群: "+ group_id + " 的用户: " + qq_id + " 删除成功!"), true); | ||
} else { | ||
context.getSource().sendSuccess(() -> Component.literal("群: "+ group_id + " 的用户: " + qq_id + " 未找到!"), true); | ||
} | ||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.