fix: make findalts use the ip from the current player list first but if not found then use the one from the database

This commit is contained in:
ChomeNS
2025-05-15 19:57:15 +07:00
parent 8dad298c50
commit 8ab8ecd2f7
2 changed files with 8 additions and 2 deletions

View File

@@ -1 +1 @@
3196
3197

View File

@@ -8,6 +8,7 @@ import me.chayapak1.chomens_bot.command.CommandContext;
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;
@@ -49,7 +50,12 @@ public class FindAltsCommand extends Command {
final String player = context.getString(true, true);
DatabasePlugin.EXECUTOR_SERVICE.submit(() -> {
final String ipFromUsername = bot.playersDatabase.getPlayerIP(player);
final PlayerEntry playerInTheServer = bot.players.getEntry(player);
final String ipFromUsername;
if (playerInTheServer == null || playerInTheServer.ip == null) ipFromUsername = bot.playersDatabase.getPlayerIP(player);
else ipFromUsername = playerInTheServer.ip;
if (ipFromUsername == null) {
context.sendOutput(handle(bot, player, player, allServer));