-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
```refactor(mcbot): rename UserBind to UserInfo and update related APIs
Rename UserBind to UserInfo to better reflect its purpose. Synchronize updates across related APIs and data handling classes. Improve data folder path consistency by using Constants.DATA_FOLDER. Enhance Cmd class with Lombok annotations for better boilerplate code reduction. Ensure CmdUtils returns null for empty commands. BREAKING CHANGE: The class UserBind has been renamed to UserInfo. Any code utilizingUserBindApi, UserBind, or related data handling methods must now refer to UserInfoApi and UserInfo respectively. Additionally, constructor and method calls on Cmd class have been modified to be more concise with Lombok annotations. ```
- Loading branch information
Showing
10 changed files
with
107 additions
and
77 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
47 changes: 0 additions & 47 deletions
47
common/src/main/java/cn/evole/mods/mcbot/api/data/UserBindApi.java
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
common/src/main/java/cn/evole/mods/mcbot/api/data/UserInfoApi.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,55 @@ | ||
package cn.evole.mods.mcbot.api.data; | ||
|
||
import cn.evole.mods.mcbot.Constants; | ||
import cn.evole.mods.mcbot.plugins.data.UserInfo; | ||
import cn.evole.mods.mcbot.util.FileUtils; | ||
|
||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
/** | ||
* @Project: McBot | ||
* @Author: cnlimiter | ||
* @CreateTime: 2024/8/17 14:02 | ||
* @Description: | ||
*/ | ||
public class UserInfoApi { | ||
public static List<UserInfo> userInfos; | ||
public static Path userBindFile = FileUtils.checkFile(Constants.DATA_FOLDER.resolve("userBind.csv")); | ||
|
||
public static boolean groupHas(String group_id, String user_id){ | ||
for (UserInfo userInfo : userInfos){ | ||
if (userInfo.getGroupId().equals(group_id)){ | ||
return userInfo.getQqId().equals(user_id); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public static boolean isInGame(String group_id, String user_id){ | ||
for (UserInfo userInfo : userInfos){ | ||
if (userInfo.getGroupId().equals(group_id)){ | ||
return userInfo.getGameName().equals(user_id); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public static void add(String group_id, String qq_id, String game_name){ | ||
if (!groupHas(group_id, qq_id)) { | ||
UserInfo userInfo = new UserInfo(); | ||
userInfo.setCreateTime(System.currentTimeMillis()); | ||
userInfo.setQqId(qq_id); | ||
userInfo.setGroupId(group_id); | ||
userInfo.setGameName(game_name); | ||
userInfo.setCoin(5); | ||
userInfos.add(userInfo); | ||
} | ||
} | ||
|
||
public static void del(String group_id, String qq_id){ | ||
if (groupHas(group_id, qq_id)) { | ||
userInfos.removeIf(userInfo -> userInfo.getGroupId().equals(group_id) && userInfo.getQqId().equals(qq_id)); | ||
} | ||
} | ||
} |
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