fix: console sender being null when the bot is not logged in to that server

This commit is contained in:
ChomeNS
2025-04-22 17:13:32 +07:00
parent 788f5e88e6
commit 8290473631

View File

@@ -3,14 +3,37 @@ package me.chayapak1.chomens_bot.command.contexts;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.command.CommandContext;
import me.chayapak1.chomens_bot.data.logging.LogType;
import me.chayapak1.chomens_bot.data.player.PlayerEntry;
import me.chayapak1.chomens_bot.util.UUIDUtilities;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.geysermc.mcprotocollib.auth.GameProfile;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
public class ConsoleCommandContext extends CommandContext {
private final Bot bot;
public ConsoleCommandContext (final Bot bot, final String prefix) {
super(bot, prefix, bot.players.getBotEntry() /* real */, false);
super(
bot,
prefix,
bot.players.getBotEntry() != null ?
bot.players.getBotEntry() :
new PlayerEntry(
new GameProfile(
UUIDUtilities.getOfflineUUID(bot.username),
bot.username
),
GameMode.CREATIVE,
-69420,
Component.text(bot.username),
0,
null,
new byte[0],
true
),
false
);
this.bot = bot;
}