mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-02 05:21:45 +01:00
Dedicated GameProfile record (#1482)
This commit is contained in:
parent
d7e958fa07
commit
3e2ac14048
@ -55,6 +55,7 @@ import net.minestom.server.network.packet.server.SendablePacket;
|
|||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.login.LoginDisconnectPacket;
|
import net.minestom.server.network.packet.server.login.LoginDisconnectPacket;
|
||||||
import net.minestom.server.network.packet.server.play.*;
|
import net.minestom.server.network.packet.server.play.*;
|
||||||
|
import net.minestom.server.network.player.GameProfile;
|
||||||
import net.minestom.server.network.player.PlayerConnection;
|
import net.minestom.server.network.player.PlayerConnection;
|
||||||
import net.minestom.server.network.player.PlayerSocketConnection;
|
import net.minestom.server.network.player.PlayerSocketConnection;
|
||||||
import net.minestom.server.recipe.Recipe;
|
import net.minestom.server.recipe.Recipe;
|
||||||
@ -263,7 +264,19 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
sendPacket(new SpawnPositionPacket(respawnPoint, 0));
|
sendPacket(new SpawnPositionPacket(respawnPoint, 0));
|
||||||
|
|
||||||
// Add player to list with spawning skin
|
// Add player to list with spawning skin
|
||||||
PlayerSkinInitEvent skinInitEvent = new PlayerSkinInitEvent(this, skin);
|
PlayerSkin profileSkin = null;
|
||||||
|
if (playerConnection instanceof PlayerSocketConnection socketConnection) {
|
||||||
|
final GameProfile gameProfile = socketConnection.gameProfile();
|
||||||
|
if (gameProfile != null) {
|
||||||
|
for (GameProfile.Property property : gameProfile.properties()) {
|
||||||
|
if (property.name().equals("textures")) {
|
||||||
|
profileSkin = new PlayerSkin(property.value(), property.signature());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlayerSkinInitEvent skinInitEvent = new PlayerSkinInitEvent(this, profileSkin);
|
||||||
EventDispatcher.call(skinInitEvent);
|
EventDispatcher.call(skinInitEvent);
|
||||||
this.skin = skinInitEvent.getSkin();
|
this.skin = skinInitEvent.getSkin();
|
||||||
// FIXME: when using Geyser, this line remove the skin of the client
|
// FIXME: when using Geyser, this line remove the skin of the client
|
||||||
|
@ -1,12 +1,5 @@
|
|||||||
package net.minestom.server.extras.bungee;
|
package net.minestom.server.extras.bungee;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import net.minestom.server.entity.PlayerSkin;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BungeeCord forwarding support. This does not count as a security feature, and you will still be required to manage your firewall.
|
* BungeeCord forwarding support. This does not count as a security feature, and you will still be required to manage your firewall.
|
||||||
* <p>
|
* <p>
|
||||||
@ -31,29 +24,4 @@ public final class BungeeCordProxy {
|
|||||||
public static boolean isEnabled() {
|
public static boolean isEnabled() {
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerSkin readSkin(@NotNull String json) {
|
|
||||||
JsonArray array = JsonParser.parseString(json).getAsJsonArray();
|
|
||||||
String skinTexture = null;
|
|
||||||
String skinSignature = null;
|
|
||||||
|
|
||||||
for (JsonElement element : array) {
|
|
||||||
JsonObject jsonObject = element.getAsJsonObject();
|
|
||||||
JsonElement name = jsonObject.get("name");
|
|
||||||
if (name == null || !name.getAsString().equals("textures")) continue;
|
|
||||||
|
|
||||||
JsonElement value = jsonObject.get("value");
|
|
||||||
JsonElement signature = jsonObject.get("signature");
|
|
||||||
if (value == null || signature == null) continue;
|
|
||||||
|
|
||||||
skinTexture = value.getAsString();
|
|
||||||
skinSignature = signature.getAsString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skinTexture != null && skinSignature != null) {
|
|
||||||
return new PlayerSkin(skinTexture, skinSignature);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.minestom.server.extras.velocity;
|
package net.minestom.server.extras.velocity;
|
||||||
|
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.entity.PlayerSkin;
|
|
||||||
import net.minestom.server.utils.binary.BinaryReader;
|
import net.minestom.server.utils.binary.BinaryReader;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -76,26 +75,4 @@ public final class VelocityProxy {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerSkin readSkin(@NotNull BinaryReader reader) {
|
|
||||||
String skinTexture = null;
|
|
||||||
String skinSignature = null;
|
|
||||||
final int properties = reader.readVarInt();
|
|
||||||
for (int i = 0; i < properties; i++) {
|
|
||||||
final String name = reader.readSizedString(Short.MAX_VALUE);
|
|
||||||
final String value = reader.readSizedString(Short.MAX_VALUE);
|
|
||||||
final String signature = reader.readBoolean() ? reader.readSizedString(Short.MAX_VALUE) : null;
|
|
||||||
|
|
||||||
if (name.equals("textures")) {
|
|
||||||
skinTexture = value;
|
|
||||||
skinSignature = signature;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skinTexture != null && skinSignature != null) {
|
|
||||||
return new PlayerSkin(skinTexture, skinSignature);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
package net.minestom.server.network.packet.client.handshake;
|
package net.minestom.server.network.packet.client.handshake;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.entity.PlayerSkin;
|
|
||||||
import net.minestom.server.extras.bungee.BungeeCordProxy;
|
import net.minestom.server.extras.bungee.BungeeCordProxy;
|
||||||
import net.minestom.server.network.ConnectionState;
|
import net.minestom.server.network.ConnectionState;
|
||||||
import net.minestom.server.network.packet.client.ClientPreplayPacket;
|
import net.minestom.server.network.packet.client.ClientPreplayPacket;
|
||||||
import net.minestom.server.network.packet.server.login.LoginDisconnectPacket;
|
import net.minestom.server.network.packet.server.login.LoginDisconnectPacket;
|
||||||
|
import net.minestom.server.network.player.GameProfile;
|
||||||
import net.minestom.server.network.player.PlayerConnection;
|
import net.minestom.server.network.player.PlayerConnection;
|
||||||
import net.minestom.server.network.player.PlayerSocketConnection;
|
import net.minestom.server.network.player.PlayerSocketConnection;
|
||||||
import net.minestom.server.utils.binary.BinaryReader;
|
import net.minestom.server.utils.binary.BinaryReader;
|
||||||
@ -15,6 +19,8 @@ import net.minestom.server.utils.binary.BinaryWriter;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public record HandshakePacket(int protocolVersion, @NotNull String serverAddress,
|
public record HandshakePacket(int protocolVersion, @NotNull String serverAddress,
|
||||||
@ -45,41 +51,49 @@ public record HandshakePacket(int protocolVersion, @NotNull String serverAddress
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(@NotNull PlayerConnection connection) {
|
public void process(@NotNull PlayerConnection connection) {
|
||||||
|
|
||||||
String address = serverAddress;
|
String address = serverAddress;
|
||||||
// Bungee support (IP forwarding)
|
// Bungee support (IP forwarding)
|
||||||
if (BungeeCordProxy.isEnabled() && connection instanceof PlayerSocketConnection socketConnection && nextState == 2) {
|
if (BungeeCordProxy.isEnabled() && connection instanceof PlayerSocketConnection socketConnection && nextState == 2) {
|
||||||
if (address != null) {
|
final String[] split = address.split("\00");
|
||||||
final String[] split = address.split("\00");
|
|
||||||
|
|
||||||
if (split.length == 3 || split.length == 4) {
|
if (split.length == 3 || split.length == 4) {
|
||||||
address = split[0];
|
address = split[0];
|
||||||
|
|
||||||
final SocketAddress socketAddress = new java.net.InetSocketAddress(split[1],
|
final SocketAddress socketAddress = new java.net.InetSocketAddress(split[1],
|
||||||
((java.net.InetSocketAddress) connection.getRemoteAddress()).getPort());
|
((java.net.InetSocketAddress) connection.getRemoteAddress()).getPort());
|
||||||
socketConnection.setRemoteAddress(socketAddress);
|
socketConnection.setRemoteAddress(socketAddress);
|
||||||
|
|
||||||
UUID playerUuid = UUID.fromString(
|
UUID playerUuid = UUID.fromString(
|
||||||
split[2]
|
split[2]
|
||||||
.replaceFirst(
|
.replaceFirst(
|
||||||
"(\\p{XDigit}{8})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}+)", "$1-$2-$3-$4-$5"
|
"(\\p{XDigit}{8})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}+)", "$1-$2-$3-$4-$5"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
PlayerSkin playerSkin = null;
|
|
||||||
|
|
||||||
if (split.length == 4) {
|
List<GameProfile.Property> properties = new ArrayList<>();
|
||||||
playerSkin = BungeeCordProxy.readSkin(split[3]);
|
if (split.length == 4) {
|
||||||
|
final String rawPropertyJson = split[3];
|
||||||
|
final JsonArray propertyJson = JsonParser.parseString(rawPropertyJson).getAsJsonArray();
|
||||||
|
for (JsonElement element : propertyJson) {
|
||||||
|
final JsonObject jsonObject = element.getAsJsonObject();
|
||||||
|
final JsonElement name = jsonObject.get("name");
|
||||||
|
final JsonElement value = jsonObject.get("value");
|
||||||
|
final JsonElement signature = jsonObject.get("signature");
|
||||||
|
if (name == null || value == null) continue;
|
||||||
|
|
||||||
|
final String nameString = name.getAsString();
|
||||||
|
final String valueString = value.getAsString();
|
||||||
|
final String signatureString = signature == null ? null : signature.getAsString();
|
||||||
|
|
||||||
|
properties.add(new GameProfile.Property(nameString, valueString, signatureString));
|
||||||
}
|
}
|
||||||
|
|
||||||
socketConnection.UNSAFE_setBungeeUuid(playerUuid);
|
|
||||||
socketConnection.UNSAFE_setBungeeSkin(playerSkin);
|
|
||||||
} else {
|
|
||||||
socketConnection.sendPacket(new LoginDisconnectPacket(INVALID_BUNGEE_FORWARDING));
|
|
||||||
socketConnection.disconnect();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final GameProfile gameProfile = new GameProfile(playerUuid, "test", properties);
|
||||||
|
socketConnection.UNSAFE_setProfile(gameProfile);
|
||||||
} else {
|
} else {
|
||||||
// Happen when a client ping the server, ignore
|
socketConnection.sendPacket(new LoginDisconnectPacket(INVALID_BUNGEE_FORWARDING));
|
||||||
|
socketConnection.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,10 +104,8 @@ public record HandshakePacket(int protocolVersion, @NotNull String serverAddress
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (nextState) {
|
switch (nextState) {
|
||||||
case 1:
|
case 1 -> connection.setConnectionState(ConnectionState.STATUS);
|
||||||
connection.setConnectionState(ConnectionState.STATUS);
|
case 2 -> {
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (protocolVersion == MinecraftServer.PROTOCOL_VERSION) {
|
if (protocolVersion == MinecraftServer.PROTOCOL_VERSION) {
|
||||||
connection.setConnectionState(ConnectionState.LOGIN);
|
connection.setConnectionState(ConnectionState.LOGIN);
|
||||||
} else {
|
} else {
|
||||||
@ -101,10 +113,10 @@ public record HandshakePacket(int protocolVersion, @NotNull String serverAddress
|
|||||||
connection.sendPacket(new LoginDisconnectPacket(INVALID_VERSION_TEXT));
|
connection.sendPacket(new LoginDisconnectPacket(INVALID_VERSION_TEXT));
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
default:
|
default -> {
|
||||||
// Unexpected error
|
// Unexpected error
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,11 @@ package net.minestom.server.network.packet.client.login;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.entity.Player;
|
|
||||||
import net.minestom.server.entity.PlayerSkin;
|
|
||||||
import net.minestom.server.extras.velocity.VelocityProxy;
|
import net.minestom.server.extras.velocity.VelocityProxy;
|
||||||
import net.minestom.server.network.ConnectionManager;
|
import net.minestom.server.network.ConnectionManager;
|
||||||
import net.minestom.server.network.packet.client.ClientPreplayPacket;
|
import net.minestom.server.network.packet.client.ClientPreplayPacket;
|
||||||
import net.minestom.server.network.packet.server.login.LoginDisconnectPacket;
|
import net.minestom.server.network.packet.server.login.LoginDisconnectPacket;
|
||||||
|
import net.minestom.server.network.player.GameProfile;
|
||||||
import net.minestom.server.network.player.PlayerConnection;
|
import net.minestom.server.network.player.PlayerConnection;
|
||||||
import net.minestom.server.network.player.PlayerSocketConnection;
|
import net.minestom.server.network.player.PlayerSocketConnection;
|
||||||
import net.minestom.server.utils.binary.BinaryReader;
|
import net.minestom.server.utils.binary.BinaryReader;
|
||||||
@ -19,7 +18,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public record LoginPluginResponsePacket(int messageId, byte @Nullable [] data) implements ClientPreplayPacket {
|
public record LoginPluginResponsePacket(int messageId, byte @Nullable [] data) implements ClientPreplayPacket {
|
||||||
private final static ConnectionManager CONNECTION_MANAGER = MinecraftServer.getConnectionManager();
|
private final static ConnectionManager CONNECTION_MANAGER = MinecraftServer.getConnectionManager();
|
||||||
@ -38,9 +36,7 @@ public record LoginPluginResponsePacket(int messageId, byte @Nullable [] data) i
|
|||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
||||||
SocketAddress socketAddress = null;
|
SocketAddress socketAddress = null;
|
||||||
UUID playerUuid = null;
|
GameProfile gameProfile = null;
|
||||||
String playerUsername = null;
|
|
||||||
PlayerSkin playerSkin = null;
|
|
||||||
|
|
||||||
// Velocity
|
// Velocity
|
||||||
if (VelocityProxy.isEnabled() && channel.equals(VelocityProxy.PLAYER_INFO_CHANNEL)) {
|
if (VelocityProxy.isEnabled() && channel.equals(VelocityProxy.PLAYER_INFO_CHANNEL)) {
|
||||||
@ -52,29 +48,15 @@ public record LoginPluginResponsePacket(int messageId, byte @Nullable [] data) i
|
|||||||
final InetAddress address = VelocityProxy.readAddress(reader);
|
final InetAddress address = VelocityProxy.readAddress(reader);
|
||||||
final int port = ((java.net.InetSocketAddress) connection.getRemoteAddress()).getPort();
|
final int port = ((java.net.InetSocketAddress) connection.getRemoteAddress()).getPort();
|
||||||
socketAddress = new InetSocketAddress(address, port);
|
socketAddress = new InetSocketAddress(address, port);
|
||||||
|
gameProfile = new GameProfile(reader);
|
||||||
playerUuid = reader.readUuid();
|
|
||||||
playerUsername = reader.readSizedString(16);
|
|
||||||
|
|
||||||
playerSkin = VelocityProxy.readSkin(reader);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
if (socketAddress != null) {
|
socketConnection.setRemoteAddress(socketAddress);
|
||||||
socketConnection.setRemoteAddress(socketAddress);
|
socketConnection.UNSAFE_setProfile(gameProfile);
|
||||||
}
|
CONNECTION_MANAGER.startPlayState(connection, gameProfile.uuid(), gameProfile.name(), true);
|
||||||
if (playerUsername != null) {
|
|
||||||
socketConnection.UNSAFE_setLoginUsername(playerUsername);
|
|
||||||
}
|
|
||||||
|
|
||||||
final String username = socketConnection.getLoginUsername();
|
|
||||||
final UUID uuid = playerUuid != null ?
|
|
||||||
playerUuid : CONNECTION_MANAGER.getPlayerConnectionUuid(connection, username);
|
|
||||||
|
|
||||||
Player player = CONNECTION_MANAGER.startPlayState(connection, uuid, username, true);
|
|
||||||
player.setSkin(playerSkin);
|
|
||||||
} else {
|
} else {
|
||||||
LoginDisconnectPacket disconnectPacket = new LoginDisconnectPacket(INVALID_PROXY_RESPONSE);
|
LoginDisconnectPacket disconnectPacket = new LoginDisconnectPacket(INVALID_PROXY_RESPONSE);
|
||||||
socketConnection.sendPacket(disconnectPacket);
|
socketConnection.sendPacket(disconnectPacket);
|
||||||
|
@ -5,7 +5,6 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
|||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.crypto.PlayerPublicKey;
|
import net.minestom.server.crypto.PlayerPublicKey;
|
||||||
import net.minestom.server.crypto.SignatureValidator;
|
import net.minestom.server.crypto.SignatureValidator;
|
||||||
import net.minestom.server.entity.Player;
|
|
||||||
import net.minestom.server.extras.MojangAuth;
|
import net.minestom.server.extras.MojangAuth;
|
||||||
import net.minestom.server.extras.bungee.BungeeCordProxy;
|
import net.minestom.server.extras.bungee.BungeeCordProxy;
|
||||||
import net.minestom.server.extras.velocity.VelocityProxy;
|
import net.minestom.server.extras.velocity.VelocityProxy;
|
||||||
@ -95,13 +94,9 @@ public record LoginStartPacket(@NotNull String username,
|
|||||||
final boolean bungee = BungeeCordProxy.isEnabled();
|
final boolean bungee = BungeeCordProxy.isEnabled();
|
||||||
// Offline
|
// Offline
|
||||||
final UUID playerUuid = bungee && isSocketConnection ?
|
final UUID playerUuid = bungee && isSocketConnection ?
|
||||||
((PlayerSocketConnection) connection).getBungeeUuid() :
|
((PlayerSocketConnection) connection).gameProfile().uuid() :
|
||||||
CONNECTION_MANAGER.getPlayerConnectionUuid(connection, username);
|
CONNECTION_MANAGER.getPlayerConnectionUuid(connection, username);
|
||||||
|
CONNECTION_MANAGER.startPlayState(connection, playerUuid, username, true);
|
||||||
Player player = CONNECTION_MANAGER.startPlayState(connection, playerUuid, username, true);
|
|
||||||
if (bungee && isSocketConnection) {
|
|
||||||
player.setSkin(((PlayerSocketConnection) connection).getBungeeSkin());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
package net.minestom.server.network.player;
|
||||||
|
|
||||||
|
import net.minestom.server.utils.binary.BinaryReader;
|
||||||
|
import net.minestom.server.utils.binary.BinaryWriter;
|
||||||
|
import net.minestom.server.utils.binary.Writeable;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public record GameProfile(@NotNull UUID uuid, @NotNull String name,
|
||||||
|
@NotNull List<@NotNull Property> properties) implements Writeable {
|
||||||
|
public GameProfile {
|
||||||
|
if (name.isBlank())
|
||||||
|
throw new IllegalArgumentException("Name cannot be blank");
|
||||||
|
if (name.length() > 16)
|
||||||
|
throw new IllegalArgumentException("Name length cannot be greater than 16 characters");
|
||||||
|
properties = List.copyOf(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameProfile(@NotNull BinaryReader reader) {
|
||||||
|
this(reader.readUuid(), reader.readSizedString(16), reader.readVarIntList(Property::new));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(@NotNull BinaryWriter writer) {
|
||||||
|
writer.writeUuid(uuid);
|
||||||
|
writer.writeSizedString(name);
|
||||||
|
writer.writeVarIntList(properties, BinaryWriter::write);
|
||||||
|
}
|
||||||
|
|
||||||
|
public record Property(@NotNull String name, @NotNull String value,
|
||||||
|
@Nullable String signature) implements Writeable {
|
||||||
|
public Property(@NotNull String name, @NotNull String value) {
|
||||||
|
this(name, value, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Property(@NotNull BinaryReader reader) {
|
||||||
|
this(reader.readSizedString(), reader.readSizedString(),
|
||||||
|
reader.readBoolean() ? reader.readSizedString() : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(@NotNull BinaryWriter writer) {
|
||||||
|
writer.writeSizedString(name);
|
||||||
|
writer.writeSizedString(value);
|
||||||
|
writer.writeBoolean(signature != null);
|
||||||
|
if (signature != null) writer.writeSizedString(signature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,6 @@ import net.kyori.adventure.translation.GlobalTranslator;
|
|||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.adventure.MinestomAdventure;
|
import net.minestom.server.adventure.MinestomAdventure;
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
import net.minestom.server.entity.PlayerSkin;
|
|
||||||
import net.minestom.server.event.EventDispatcher;
|
import net.minestom.server.event.EventDispatcher;
|
||||||
import net.minestom.server.event.ListenerHandle;
|
import net.minestom.server.event.ListenerHandle;
|
||||||
import net.minestom.server.event.player.PlayerPacketOutEvent;
|
import net.minestom.server.event.player.PlayerPacketOutEvent;
|
||||||
@ -62,6 +61,7 @@ public class PlayerSocketConnection extends PlayerConnection {
|
|||||||
|
|
||||||
// Data from client packets
|
// Data from client packets
|
||||||
private String loginUsername;
|
private String loginUsername;
|
||||||
|
private GameProfile gameProfile;
|
||||||
private String serverAddress;
|
private String serverAddress;
|
||||||
private int serverPort;
|
private int serverPort;
|
||||||
private int protocolVersion;
|
private int protocolVersion;
|
||||||
@ -70,10 +70,6 @@ public class PlayerSocketConnection extends PlayerConnection {
|
|||||||
// cleared once the player enters the play state
|
// cleared once the player enters the play state
|
||||||
private final Map<Integer, String> pluginRequestMap = new ConcurrentHashMap<>();
|
private final Map<Integer, String> pluginRequestMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
// Bungee
|
|
||||||
private UUID bungeeUuid;
|
|
||||||
private PlayerSkin bungeeSkin;
|
|
||||||
|
|
||||||
private final List<BinaryBuffer> waitingBuffers = new ArrayList<>();
|
private final List<BinaryBuffer> waitingBuffers = new ArrayList<>();
|
||||||
private final AtomicReference<BinaryBuffer> tickBuffer = new AtomicReference<>(POOL.get());
|
private final AtomicReference<BinaryBuffer> tickBuffer = new AtomicReference<>(POOL.get());
|
||||||
private BinaryBuffer cacheBuffer;
|
private BinaryBuffer cacheBuffer;
|
||||||
@ -216,6 +212,14 @@ public class PlayerSocketConnection extends PlayerConnection {
|
|||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @Nullable GameProfile gameProfile() {
|
||||||
|
return gameProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UNSAFE_setProfile(@NotNull GameProfile gameProfile) {
|
||||||
|
this.gameProfile = gameProfile;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the username received from the client during connection.
|
* Retrieves the username received from the client during connection.
|
||||||
* <p>
|
* <p>
|
||||||
@ -283,22 +287,6 @@ public class PlayerSocketConnection extends PlayerConnection {
|
|||||||
this.protocolVersion = protocolVersion;
|
this.protocolVersion = protocolVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable UUID getBungeeUuid() {
|
|
||||||
return bungeeUuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UNSAFE_setBungeeUuid(UUID bungeeUuid) {
|
|
||||||
this.bungeeUuid = bungeeUuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable PlayerSkin getBungeeSkin() {
|
|
||||||
return bungeeSkin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UNSAFE_setBungeeSkin(PlayerSkin bungeeSkin) {
|
|
||||||
this.bungeeSkin = bungeeSkin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an entry to the plugin request map.
|
* Adds an entry to the plugin request map.
|
||||||
* <p>
|
* <p>
|
||||||
|
Loading…
Reference in New Issue
Block a user