Skip to content

Commit

Permalink
1.管理员白名单limitless
Browse files Browse the repository at this point in the history
2.管理严删除用户白名单remake
git commit -m
  • Loading branch information
RegadPoleCN committed Jun 20, 2024
1 parent 2f50691 commit b820841
Show file tree
Hide file tree
Showing 11 changed files with 347 additions and 92 deletions.
2 changes: 1 addition & 1 deletion plumbot-bukkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>me.regadpole</groupId>
<artifactId>plumbot</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
</parent>

<artifactId>plumbot-bukkit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import me.regadpole.plumbot.bot.KookBot;
import me.regadpole.plumbot.config.Config;
import me.regadpole.plumbot.config.DataBase;
import me.regadpole.plumbot.internal.WhitelistHelper;
import me.regadpole.plumbot.internal.database.DatabaseManager;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
Expand All @@ -13,6 +14,7 @@
import snw.jkook.plugin.Plugin;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Commands implements CommandExecutor{
Expand Down Expand Up @@ -65,6 +67,69 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
sender.sendMessage("§6/pb info :§f插件基本信息");
sender.sendMessage("§6/pb kook help :§f获取kook帮助");
sender.sendMessage("§6/pb kook plugins :§f获取kook插件列表");
sender.sendMessage("§6/pb queryBind <id:ID或qq:qq> :§f查询id或qq绑定数据");
sender.sendMessage("§6/pb addBind <qq> <id> :§f为qq添加ID白名单");
break;
case "queryBind":
if (args.length == 1) {
sender.sendMessage("命令错误,格式:/plumbot queryBind <id:ID或qq:QQ>");
return true;
}
if (args.length > 2) {
sender.sendMessage("命令错误,格式:/plumbot queryBind <id:ID或qq:QQ>");
return true;
}
if (args.length == 2) {
if (args[1].startsWith("id:")) {
String name = args[1].substring(3);
if (name.isEmpty()) {
sender.sendMessage("id不能为空");
return true;
}
PlumBot.getScheduler().runTaskAsynchronously(() -> {
long qq = DatabaseManager.getBindId(name, DataBase.type().toLowerCase(), PlumBot.getDatabase());
if (qq==0L) {
sender.sendMessage("ID尚未申请白名单");
return;
}
sender.sendMessage(name+"的申请用户为"+qq);
});
return true;
} else if (args[1].startsWith("qq:")) {
String qq = args[1].substring(3);
if (qq.isEmpty()) {
sender.sendMessage("QQ不能为空");
return true;
}
PlumBot.getScheduler().runTaskAsynchronously(() -> {
List<String> id = DatabaseManager.getBind(qq, DataBase.type().toLowerCase(), PlumBot.getDatabase());
if (id.isEmpty()) {
sender.sendMessage(qq+"尚未申请白名单");
return;
}
sender.sendMessage(qq+"拥有白名单ID:"+id);
});
return true;
}
break;
}
case "addBind":
if (args.length == 1) {
sender.sendMessage("命令错误,格式:/plumbot queryBind <id:ID或qq:QQ>");
return true;
}
if (args.length > 2) {
sender.sendMessage("命令错误,格式:/plumbot queryBind <id:ID或qq:QQ>");
return true;
}
if (args.length == 2) {
if (!WhitelistHelper.checkIDNotExist(args[1])) {
sender.sendMessage("绑定失败,此ID已绑定用户" + DatabaseManager.getBindId(args[1], DataBase.type().toLowerCase(), PlumBot.getDatabase()));
return true;
}
List<String> id = WhitelistHelper.addAndGet(args[1], args[0], DataBase.type().toLowerCase(), PlumBot.getDatabase());
sender.sendMessage("成功申请白名单," + args[0] + "目前的白名单为" + id);
}
break;
case "kook":
if (args.length == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void createConfig(){
if (!Config.getBotYamlVersion().equals("1.3.0")){
INSTANCE.saveResource(botFile.getName(), true);
}
if (!Config.getConfigYamlVersion().equals("1.3.1")){
if (!Config.getConfigYamlVersion().equals("1.3.2")){
INSTANCE.saveResource(configFile.getName(), true);
}
if (!Config.getCommandsYamlVersion().equals("1.2.2")){
Expand Down Expand Up @@ -126,6 +126,10 @@ public static boolean WhiteList(){
return getConfigYaml().getBoolean("WhiteList.enable");
}

public static int WhiteListMaxCount(){
return getConfigYaml().getInt("WhiteList.maxCount");
}

public static boolean JoinAndLeave(){
return getConfigYaml().getBoolean("JoinAndLeave");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ public void onChannelMessageReceive(ChannelMessageEvent e) {
return;
}
PlumBot.getScheduler().runTaskAsynchronously(() -> {
String idForName = DatabaseManager.getBind(qq, DataBase.type().toLowerCase(), PlumBot.getDatabase());
if (idForName == null) {
List<String> idForName = DatabaseManager.getBind(qq, DataBase.type().toLowerCase(), PlumBot.getDatabase());
if (idForName.isEmpty()) {
e.getMessage().reply("尚未申请白名单");
return;
}
Expand Down Expand Up @@ -225,8 +225,8 @@ public void onChannelMessageReceive(ChannelMessageEvent e) {
return;
}
PlumBot.getScheduler().runTaskAsynchronously(() -> {
String idForName = DatabaseManager.getBind(String.valueOf(senderID), DataBase.type().toLowerCase(), PlumBot.getDatabase());
if (idForName == null || idForName.isEmpty()) {
List<String> idForName = DatabaseManager.getBind(String.valueOf(senderID), DataBase.type().toLowerCase(), PlumBot.getDatabase());
if (idForName.isEmpty()) {
e.getMessage().reply("您尚未申请白名单");
return;
}
Expand Down Expand Up @@ -348,10 +348,10 @@ public void onPrivateMessageReceive(PrivateMessageReceivedEvent e) {
public void onGroupDecreaseNotice(UserLeaveGuildEvent e) {
String userId = e.getUser().getId();
String groupId = e.getGuildId();
String player = DatabaseManager.getBind(userId, DataBase.type().toLowerCase(), PlumBot.getDatabase());
if (player == null) {
List<String> player = DatabaseManager.getBind(userId, DataBase.type().toLowerCase(), PlumBot.getDatabase());
if (player.isEmpty()) {
return;
}
DatabaseManager.removeBindid(player, DataBase.type().toLowerCase(), PlumBot.getDatabase());
DatabaseManager.removeBind(userId, DataBase.type().toLowerCase(), PlumBot.getDatabase());
}
}
Loading

0 comments on commit b820841

Please sign in to comment.