From 7232defa7f5c9097bc30f6b4f95f32406e5e371d Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Mon, 1 May 2023 08:40:12 +0700 Subject: [PATCH] add bot.profile() mabe --- .../java/land/chipmunk/chayapak/chomens_bot/Bot.java | 12 +++++++++--- .../chomens_bot/commands/BotUserCommand.java | 2 +- .../chayapak/chomens_bot/plugins/SelfCarePlugin.java | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java index 6e40360..7967859 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java @@ -1,7 +1,9 @@ package land.chipmunk.chayapak.chomens_bot; +import com.github.steveice10.mc.auth.data.GameProfile; import com.github.steveice10.mc.protocol.MinecraftProtocol; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket; +import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundGameProfilePacket; import com.github.steveice10.packetlib.Session; import com.github.steveice10.packetlib.event.session.*; import com.github.steveice10.packetlib.packet.Packet; @@ -32,14 +34,14 @@ public class Bot { @Getter private String username; + @Getter private GameProfile profile; + @Getter public Session session; @Getter private boolean loggedIn = false; @Getter private final ScheduledExecutorService executor = Executors.newScheduledThreadPool(100); - private final List packetQueue = new ArrayList<>(); - @Getter @Setter private ConsolePlugin console; @Getter @Setter private LoggerPlugin logger; // in ConsolePlugin @Getter @Setter private DiscordPlugin discord; // same for this one too @@ -141,7 +143,11 @@ public class Bot { loggedIn = true; listener.connected(new ConnectedEvent(session)); } - } + } else if (packet instanceof ClientboundGameProfilePacket) packetReceived((ClientboundGameProfilePacket) packet); + } + + public void packetReceived(ClientboundGameProfilePacket packet) { + profile = packet.getProfile(); } @Override diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotUserCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotUserCommand.java index 49aeb22..44e548b 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotUserCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotUserCommand.java @@ -40,7 +40,7 @@ public class BotUserCommand implements Command { final Bot bot = context.bot(); final String username = bot.username(); - final String uuid = bot.players().getBotEntry().profile().getIdAsString(); + final String uuid = bot.profile().getIdAsString(); return Component.translatable( "The bot's username is: %s and the UUID is: %s", diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/SelfCarePlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/SelfCarePlugin.java index a258b6c..6300d93 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/SelfCarePlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/SelfCarePlugin.java @@ -111,8 +111,8 @@ public class SelfCarePlugin extends Bot.Listener { else bot.core().run("essentials:socialspy " + bot.username() + " enable"); } else if (selfCares.mute() && muted && bot.options().hasEssentials()) { - if (bot.options().useChat()) bot.chat().send("/essentials:mute " + bot.username()); - else bot.core().run("essentials:mute " + bot.username()); + if (bot.options().useChat()) bot.chat().send("/essentials:mute " + bot.profile().getIdAsString()); + else bot.core().run("essentials:mute " + bot.profile().getIdAsString()); } }