Skip to content

Commit

Permalink
Merge pull request #46 from RegadPoleCN/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
RegadPoleCN authored Aug 8, 2024
2 parents 4d3de31 + 3f84e78 commit 825ae20
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
return true;
}
if (args.length == 3) {
if (!WhitelistHelper.checkIDNotExist(args[1])) {
sender.sendMessage(plugin.getEnvironment().prefix+"§c绑定失败,此ID已绑定用户" + DatabaseManager.getBindId(args[1], DataBase.type().toLowerCase(), PlumBot.getDatabase()));
if (!WhitelistHelper.checkIDNotExist(args[2])) {
sender.sendMessage(plugin.getEnvironment().prefix+"§c绑定失败,此ID已绑定用户" + DatabaseManager.getBindId(args[2], DataBase.type().toLowerCase(), PlumBot.getDatabase()));
return true;
}
List<String> id = WhitelistHelper.addAndGet(args[2], args[1], DataBase.type().toLowerCase(), PlumBot.getDatabase());
sender.sendMessage(plugin.getEnvironment().prefix+"§a成功申请白名单," + args[0] + "目前的白名单为" + id);
sender.sendMessage(plugin.getEnvironment().prefix+"§a成功申请白名单," + args[1] + "目前的白名单为" + id);
}
break;
case "kook":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void onPreLogin(AsyncPlayerPreLoginEvent event){
long qq;
qq = (DatabaseManager.getBindId(name, DataBase.type().toLowerCase(), PlumBot.getDatabase()));
if (qq == 0L) {
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_WHITELIST, Args.WhitelistKick());
PlumBot.getScheduler().runTask(() -> event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_WHITELIST, Args.WhitelistKick()));
List<Long> groups = Config.getGroupQQs();
for (long groupID : groups) {
PlumBot.getBot().sendMsg(true, "玩家" + name + "因为未在白名单中被踢出", groupID);
Expand All @@ -87,7 +87,7 @@ public void onPreLogin(AsyncPlayerPreLoginEvent event){
}
for (long groupID : Config.getGroupQQs()) {
if(!PlumBot.getBot().checkUserInGroup(qq, groupID)){
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_WHITELIST, Args.WhitelistKick());
PlumBot.getScheduler().runTask(() -> event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_WHITELIST, Args.WhitelistKick()));
List<Long> groups = Config.getGroupQQs();
for (long group : groups) {
PlumBot.getBot().sendMsg(true, "玩家" + name + "因为未在白名单中被踢出", group);
Expand All @@ -96,7 +96,8 @@ public void onPreLogin(AsyncPlayerPreLoginEvent event){
return;
}
}
event.allow();
PlumBot.getScheduler().runTask(event::allow);

});
}
}
Expand All @@ -112,7 +113,7 @@ public void onJoin(PlayerJoinEvent event){
long qq;
qq = (DatabaseManager.getBindId(name, DataBase.type().toLowerCase(), PlumBot.getDatabase()));
if (qq == 0L) {
player.kickPlayer(Args.WhitelistKick());
PlumBot.getScheduler().runTask(() -> player.kickPlayer(Args.WhitelistKick()));
List<Long> groups = Config.getGroupQQs();
for (long groupID : groups) {
PlumBot.getBot().sendMsg(true, "玩家" + name + "因为未在白名单中被踢出", groupID);
Expand All @@ -121,7 +122,7 @@ public void onJoin(PlayerJoinEvent event){
}
for (long groupID : Config.getGroupQQs()) {
if(!PlumBot.getBot().checkUserInGroup(qq, groupID)){
player.kickPlayer(Args.WhitelistKick());
PlumBot.getScheduler().runTask(() -> player.kickPlayer(Args.WhitelistKick()));
List<Long> groups = Config.getGroupQQs();
for (long group : groups) {
PlumBot.getBot().sendMsg(true, "玩家" + name + "因为未在白名单中被踢出", group);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,6 @@ public static void removeBind(String qq, String mode, Database db) {

ResultSet resultSet = connection.prepareStatement(select).executeQuery();

if (resultSet.isBeforeFirst()) {
resultSet.next();
}
connection.prepareStatement(delete).executeUpdate();
resultSet.close();
connection.close();
Expand All @@ -270,10 +267,9 @@ public static long getBindId(String id, String mode, Database db) {

ResultSet resultSet = connection.prepareStatement(select).executeQuery();

if (resultSet.isBeforeFirst()) {
resultSet.next();
if (resultSet.next()) {
qq = resultSet.getLong("qq");
}
qq = resultSet.getLong("qq");
resultSet.close();
connection.close();
break;
Expand Down Expand Up @@ -315,8 +311,10 @@ public static List<String> getBind(String qq,String mode, Database db) {

ResultSet resultSet = connection.prepareStatement(select).executeQuery();

if (resultSet.isBeforeFirst()) {
resultSet.next();
if (!resultSet.next()) {
resultSet.close();
connection.close();
break;
}
do {
String tempId = resultSet.getString("id");
Expand Down

0 comments on commit 825ae20

Please sign in to comment.