diff --git a/plumbot-bukkit/src/main/java/me/regadpole/plumbot/command/Commands.java b/plumbot-bukkit/src/main/java/me/regadpole/plumbot/command/Commands.java index b01fc7f..f3180bd 100644 --- a/plumbot-bukkit/src/main/java/me/regadpole/plumbot/command/Commands.java +++ b/plumbot-bukkit/src/main/java/me/regadpole/plumbot/command/Commands.java @@ -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 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": diff --git a/plumbot-bukkit/src/main/java/me/regadpole/plumbot/event/server/ServerEvent.java b/plumbot-bukkit/src/main/java/me/regadpole/plumbot/event/server/ServerEvent.java index 3fde8ab..3ae9ac9 100644 --- a/plumbot-bukkit/src/main/java/me/regadpole/plumbot/event/server/ServerEvent.java +++ b/plumbot-bukkit/src/main/java/me/regadpole/plumbot/event/server/ServerEvent.java @@ -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 groups = Config.getGroupQQs(); for (long groupID : groups) { PlumBot.getBot().sendMsg(true, "玩家" + name + "因为未在白名单中被踢出", groupID); @@ -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 groups = Config.getGroupQQs(); for (long group : groups) { PlumBot.getBot().sendMsg(true, "玩家" + name + "因为未在白名单中被踢出", group); @@ -96,7 +96,8 @@ public void onPreLogin(AsyncPlayerPreLoginEvent event){ return; } } - event.allow(); + PlumBot.getScheduler().runTask(event::allow); + }); } } @@ -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 groups = Config.getGroupQQs(); for (long groupID : groups) { PlumBot.getBot().sendMsg(true, "玩家" + name + "因为未在白名单中被踢出", groupID); @@ -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 groups = Config.getGroupQQs(); for (long group : groups) { PlumBot.getBot().sendMsg(true, "玩家" + name + "因为未在白名单中被踢出", group); diff --git a/plumbot-bukkit/src/main/java/me/regadpole/plumbot/internal/database/DatabaseManager.java b/plumbot-bukkit/src/main/java/me/regadpole/plumbot/internal/database/DatabaseManager.java index d84e28b..695f3ec 100644 --- a/plumbot-bukkit/src/main/java/me/regadpole/plumbot/internal/database/DatabaseManager.java +++ b/plumbot-bukkit/src/main/java/me/regadpole/plumbot/internal/database/DatabaseManager.java @@ -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(); @@ -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; @@ -315,8 +311,10 @@ public static List 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");