From 8290473631cfe5859058cc51982e99496818e019 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Tue, 22 Apr 2025 17:13:32 +0700 Subject: [PATCH] fix: console sender being null when the bot is not logged in to that server --- .../contexts/ConsoleCommandContext.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/chayapak1/chomens_bot/command/contexts/ConsoleCommandContext.java b/src/main/java/me/chayapak1/chomens_bot/command/contexts/ConsoleCommandContext.java index fd64c74d..51c9660b 100644 --- a/src/main/java/me/chayapak1/chomens_bot/command/contexts/ConsoleCommandContext.java +++ b/src/main/java/me/chayapak1/chomens_bot/command/contexts/ConsoleCommandContext.java @@ -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; }