Compare commits
3 commits
f96b9f0688
...
f095a92008
Author | SHA1 | Date | |
---|---|---|---|
f095a92008 | |||
ee2fdcd8bd | |||
096a013ebd |
5 changed files with 22 additions and 3 deletions
|
@ -4,6 +4,7 @@ import me.chayapak1.chomens_bot.plugins.*;
|
|||
import me.chayapak1.chomens_bot.util.ComponentUtilities;
|
||||
import me.chayapak1.chomens_bot.util.RandomStringUtilities;
|
||||
import org.geysermc.mcprotocollib.auth.GameProfile;
|
||||
import org.geysermc.mcprotocollib.network.BuiltinFlags;
|
||||
import org.geysermc.mcprotocollib.network.Session;
|
||||
import org.geysermc.mcprotocollib.network.event.session.*;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
|
@ -160,6 +161,10 @@ public class Bot {
|
|||
|
||||
this.session = session;
|
||||
|
||||
// this replicates the minecraft behavior of not resolving SRV records.
|
||||
// some servers check for this, so that's why i have it here
|
||||
session.setFlag(BuiltinFlags.ATTEMPT_SRV_RESOLVE, options.resolveSRV);
|
||||
|
||||
session.addListener(new SessionAdapter() {
|
||||
// fard
|
||||
|
||||
|
|
|
@ -171,6 +171,7 @@ public class Configuration {
|
|||
public boolean useCore = true;
|
||||
public boolean useChat = false;
|
||||
public boolean coreCommandSpy = false;
|
||||
public boolean resolveSRV = true;
|
||||
public int reconnectDelay = 2000;
|
||||
public boolean removeNamespaces = false;
|
||||
public int chatQueueDelay = 125;
|
||||
|
|
|
@ -7,6 +7,7 @@ import me.chayapak1.chomens_bot.command.CommandException;
|
|||
import me.chayapak1.chomens_bot.command.TrustLevel;
|
||||
import me.chayapak1.chomens_bot.data.PlayerEntry;
|
||||
import me.chayapak1.chomens_bot.util.ColorUtilities;
|
||||
import me.chayapak1.chomens_bot.util.UUIDUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
|
@ -33,10 +34,16 @@ public class UUIDCommand extends Command {
|
|||
if (!player.isEmpty()) {
|
||||
final PlayerEntry entry = bot.players.getEntry(player);
|
||||
|
||||
if (entry == null) throw new CommandException(Component.text("Invalid player name"));
|
||||
String name;
|
||||
String uuid;
|
||||
|
||||
final String name = entry.profile.getName();
|
||||
final String uuid = entry.profile.getIdAsString();
|
||||
if (entry == null) {
|
||||
name = player;
|
||||
uuid = UUIDUtilities.getOfflineUUID(player).toString();
|
||||
} else {
|
||||
name = entry.profile.getName();
|
||||
uuid = entry.profile.getIdAsString();
|
||||
}
|
||||
|
||||
return Component.translatable(
|
||||
"%s's UUID: %s",
|
||||
|
|
|
@ -10,6 +10,10 @@ import java.nio.ByteBuffer;
|
|||
public class UUIDUtilities {
|
||||
private UUIDUtilities () {}
|
||||
|
||||
public static UUID getOfflineUUID (String username) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes());
|
||||
}
|
||||
|
||||
public static int[] intArray (UUID uuid) {
|
||||
final ByteBuffer buffer = ByteBuffer.wrap(new byte[16]);
|
||||
buffer.putLong(0, uuid.getMostSignificantBits());
|
||||
|
|
|
@ -133,6 +133,7 @@ bots:
|
|||
# useCore - if enabled it just sends the command using chat instead of using core. recommended to enable useChat too when this is enabled
|
||||
# useChat - when the bot tellraws it will chat instead of using the core to run tellraw
|
||||
# coreCommandSpy - set to true if server supports enabling player's commandspy though command block
|
||||
# resolveSRV - whether to resolve SRV records on the server. the notchian minecraft doesn't resolve them
|
||||
# removeNamespaces - when the bot sends a command it will remove like `minecraft:` for example if set to true
|
||||
# coreRateLimit - will ignore commands if reached the ratelimit
|
||||
|
||||
|
@ -144,6 +145,7 @@ bots:
|
|||
useCore: true
|
||||
useChat: false
|
||||
coreCommandSpy: false
|
||||
resolveSRV: true
|
||||
reconnectDelay: 2000
|
||||
removeNamespaces: false
|
||||
chatQueueDelay: 125
|
||||
|
|
Loading…
Reference in a new issue