add bot.profile() mabe

This commit is contained in:
Chayapak 2023-05-01 08:40:12 +07:00
parent bb7a156084
commit 7232defa7f
3 changed files with 12 additions and 6 deletions

View file

@ -1,7 +1,9 @@
package land.chipmunk.chayapak.chomens_bot; 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.MinecraftProtocol;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket; 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.Session;
import com.github.steveice10.packetlib.event.session.*; import com.github.steveice10.packetlib.event.session.*;
import com.github.steveice10.packetlib.packet.Packet; import com.github.steveice10.packetlib.packet.Packet;
@ -32,14 +34,14 @@ public class Bot {
@Getter private String username; @Getter private String username;
@Getter private GameProfile profile;
@Getter public Session session; @Getter public Session session;
@Getter private boolean loggedIn = false; @Getter private boolean loggedIn = false;
@Getter private final ScheduledExecutorService executor = Executors.newScheduledThreadPool(100); @Getter private final ScheduledExecutorService executor = Executors.newScheduledThreadPool(100);
private final List<Packet> packetQueue = new ArrayList<>();
@Getter @Setter private ConsolePlugin console; @Getter @Setter private ConsolePlugin console;
@Getter @Setter private LoggerPlugin logger; // in ConsolePlugin @Getter @Setter private LoggerPlugin logger; // in ConsolePlugin
@Getter @Setter private DiscordPlugin discord; // same for this one too @Getter @Setter private DiscordPlugin discord; // same for this one too
@ -141,7 +143,11 @@ public class Bot {
loggedIn = true; loggedIn = true;
listener.connected(new ConnectedEvent(session)); listener.connected(new ConnectedEvent(session));
} }
} else if (packet instanceof ClientboundGameProfilePacket) packetReceived((ClientboundGameProfilePacket) packet);
} }
public void packetReceived(ClientboundGameProfilePacket packet) {
profile = packet.getProfile();
} }
@Override @Override

View file

@ -40,7 +40,7 @@ public class BotUserCommand implements Command {
final Bot bot = context.bot(); final Bot bot = context.bot();
final String username = bot.username(); final String username = bot.username();
final String uuid = bot.players().getBotEntry().profile().getIdAsString(); final String uuid = bot.profile().getIdAsString();
return Component.translatable( return Component.translatable(
"The bot's username is: %s and the UUID is: %s", "The bot's username is: %s and the UUID is: %s",

View file

@ -111,8 +111,8 @@ public class SelfCarePlugin extends Bot.Listener {
else bot.core().run("essentials:socialspy " + bot.username() + " enable"); else bot.core().run("essentials:socialspy " + bot.username() + " enable");
} }
else if (selfCares.mute() && muted && bot.options().hasEssentials()) { else if (selfCares.mute() && muted && bot.options().hasEssentials()) {
if (bot.options().useChat()) bot.chat().send("/essentials:mute " + bot.username()); if (bot.options().useChat()) bot.chat().send("/essentials:mute " + bot.profile().getIdAsString());
else bot.core().run("essentials:mute " + bot.username()); else bot.core().run("essentials:mute " + bot.profile().getIdAsString());
} }
} }