From 059664ca0ca495529bf86afdcddf7fddfbc09cbf Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sat, 3 May 2025 13:54:44 +0700 Subject: [PATCH] fix: run `*alts` in the database executor (it was running on the packet thread the whole time :skull::skull::skull:) --- build-number.txt | 2 +- .../chomens_bot/commands/FindAltsCommand.java | 29 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/build-number.txt b/build-number.txt index 7ef86c62..a268f484 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -3064 \ No newline at end of file +3065 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/FindAltsCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/FindAltsCommand.java index b032118b..0aab5063 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/FindAltsCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/FindAltsCommand.java @@ -9,6 +9,7 @@ import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; import me.chayapak1.chomens_bot.data.chat.ChatPacketType; import me.chayapak1.chomens_bot.data.player.PlayerEntry; +import me.chayapak1.chomens_bot.plugins.DatabasePlugin; import net.kyori.adventure.text.Component; import java.util.List; @@ -46,21 +47,25 @@ public class FindAltsCommand extends Command { final PlayerEntry playerEntry = bot.players.getEntry(player); - if (playerEntry == null) { - return handle(bot, player, true, player, allServer); - } else if (playerEntry.ip != null) { - return handle(bot, playerEntry.ip, false, player, allServer); - } else { - final CompletableFuture future = bot.players.getPlayerIP(playerEntry); + DatabasePlugin.EXECUTOR_SERVICE.submit(() -> { + if (playerEntry == null) { + context.sendOutput(handle(bot, player, true, player, allServer)); + } else if (playerEntry.ip != null) { + context.sendOutput(handle(bot, playerEntry.ip, false, player, allServer)); + } else { + final CompletableFuture future = bot.players.getPlayerIP(playerEntry); - if (future == null) return null; + if (future == null) return null; - future.thenApply(targetIP -> { - context.sendOutput(handle(bot, targetIP, false, player, allServer)); + future.thenApply(targetIP -> { + context.sendOutput(handle(bot, targetIP, false, player, allServer)); - return targetIP; - }); - } + return targetIP; + }); + } + + return null; + }); return null; }