Compare commits

...

3 commits

Author SHA1 Message Date
f095a92008 add offline player into UUIDCommand 2024-10-21 08:58:35 +07:00
ee2fdcd8bd add a config for it 2024-10-20 14:08:55 +07:00
096a013ebd trying to fix gregnant horse, but not working
i get timeout :(
but yes, it is because of SRV records stuff. it seems to work by redirecting clients that do SRV to mc.pregnanthorse.net, which is the trap server. but since the minecraft client doesn't resolve any, it just uses pregnanthorse.net, which is the actual server. anyways, heres the exception
Internal Exception: io.netty.channel.ConnectTimeoutException: connection timed out after 30000 ms: pregnant.horse/172.67.143.132:25565
2024-10-20 14:00:40 +07:00
5 changed files with 22 additions and 3 deletions

View file

@ -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

View file

@ -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;

View file

@ -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",

View file

@ -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());

View file

@ -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