Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #46

Merged
merged 20 commits into from
Aug 8, 2024
Merged

Dev #46

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading