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.ComponentUtilities;
|
||||||
import me.chayapak1.chomens_bot.util.RandomStringUtilities;
|
import me.chayapak1.chomens_bot.util.RandomStringUtilities;
|
||||||
import org.geysermc.mcprotocollib.auth.GameProfile;
|
import org.geysermc.mcprotocollib.auth.GameProfile;
|
||||||
|
import org.geysermc.mcprotocollib.network.BuiltinFlags;
|
||||||
import org.geysermc.mcprotocollib.network.Session;
|
import org.geysermc.mcprotocollib.network.Session;
|
||||||
import org.geysermc.mcprotocollib.network.event.session.*;
|
import org.geysermc.mcprotocollib.network.event.session.*;
|
||||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||||
|
@ -160,6 +161,10 @@ public class Bot {
|
||||||
|
|
||||||
this.session = session;
|
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() {
|
session.addListener(new SessionAdapter() {
|
||||||
// fard
|
// fard
|
||||||
|
|
||||||
|
|
|
@ -171,6 +171,7 @@ public class Configuration {
|
||||||
public boolean useCore = true;
|
public boolean useCore = true;
|
||||||
public boolean useChat = false;
|
public boolean useChat = false;
|
||||||
public boolean coreCommandSpy = false;
|
public boolean coreCommandSpy = false;
|
||||||
|
public boolean resolveSRV = true;
|
||||||
public int reconnectDelay = 2000;
|
public int reconnectDelay = 2000;
|
||||||
public boolean removeNamespaces = false;
|
public boolean removeNamespaces = false;
|
||||||
public int chatQueueDelay = 125;
|
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.command.TrustLevel;
|
||||||
import me.chayapak1.chomens_bot.data.PlayerEntry;
|
import me.chayapak1.chomens_bot.data.PlayerEntry;
|
||||||
import me.chayapak1.chomens_bot.util.ColorUtilities;
|
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.Component;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.event.HoverEvent;
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
|
@ -33,10 +34,16 @@ public class UUIDCommand extends Command {
|
||||||
if (!player.isEmpty()) {
|
if (!player.isEmpty()) {
|
||||||
final PlayerEntry entry = bot.players.getEntry(player);
|
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();
|
if (entry == null) {
|
||||||
final String uuid = entry.profile.getIdAsString();
|
name = player;
|
||||||
|
uuid = UUIDUtilities.getOfflineUUID(player).toString();
|
||||||
|
} else {
|
||||||
|
name = entry.profile.getName();
|
||||||
|
uuid = entry.profile.getIdAsString();
|
||||||
|
}
|
||||||
|
|
||||||
return Component.translatable(
|
return Component.translatable(
|
||||||
"%s's UUID: %s",
|
"%s's UUID: %s",
|
||||||
|
|
|
@ -10,6 +10,10 @@ import java.nio.ByteBuffer;
|
||||||
public class UUIDUtilities {
|
public class UUIDUtilities {
|
||||||
private UUIDUtilities () {}
|
private UUIDUtilities () {}
|
||||||
|
|
||||||
|
public static UUID getOfflineUUID (String username) {
|
||||||
|
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes());
|
||||||
|
}
|
||||||
|
|
||||||
public static int[] intArray (UUID uuid) {
|
public static int[] intArray (UUID uuid) {
|
||||||
final ByteBuffer buffer = ByteBuffer.wrap(new byte[16]);
|
final ByteBuffer buffer = ByteBuffer.wrap(new byte[16]);
|
||||||
buffer.putLong(0, uuid.getMostSignificantBits());
|
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
|
# 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
|
# 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
|
# 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
|
# 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
|
# coreRateLimit - will ignore commands if reached the ratelimit
|
||||||
|
|
||||||
|
@ -144,6 +145,7 @@ bots:
|
||||||
useCore: true
|
useCore: true
|
||||||
useChat: false
|
useChat: false
|
||||||
coreCommandSpy: false
|
coreCommandSpy: false
|
||||||
|
resolveSRV: true
|
||||||
reconnectDelay: 2000
|
reconnectDelay: 2000
|
||||||
removeNamespaces: false
|
removeNamespaces: false
|
||||||
chatQueueDelay: 125
|
chatQueueDelay: 125
|
||||||
|
|
Loading…
Reference in a new issue