mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 15:00:13 +01:00
net/minecraft/network/protocol/login
This commit is contained in:
parent
33efd7ee12
commit
27a47b77c7
4 changed files with 33 additions and 36 deletions
|
@ -1,13 +1,12 @@
|
||||||
--- a/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java
|
--- a/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java
|
||||||
+++ b/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java
|
+++ b/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java
|
||||||
@@ -47,4 +47,14 @@
|
@@ -47,4 +_,13 @@
|
||||||
public void handle(ClientLoginPacketListener listener) {
|
public void handle(ClientLoginPacketListener handler) {
|
||||||
listener.handleCustomQuery(this);
|
handler.handleCustomQuery(this);
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ // Paper start - MC Utils - default query payloads
|
+ // Paper start - MC Utils - default query payloads
|
||||||
+ public static record PlayerInfoChannelPayload(ResourceLocation id, FriendlyByteBuf buffer) implements CustomQueryPayload {
|
+ public static record PlayerInfoChannelPayload(ResourceLocation id, FriendlyByteBuf buffer) implements CustomQueryPayload {
|
||||||
+
|
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void write(final FriendlyByteBuf buf) {
|
+ public void write(final FriendlyByteBuf buf) {
|
||||||
+ buf.writeBytes(this.buffer.copy());
|
+ buf.writeBytes(this.buffer.copy());
|
|
@ -0,0 +1,21 @@
|
||||||
|
--- a/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java
|
||||||
|
+++ b/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java
|
||||||
|
@@ -18,11 +_,16 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClientboundLoginDisconnectPacket(FriendlyByteBuf buffer) {
|
||||||
|
- this.reason = Component.Serializer.fromJsonLenient(buffer.readUtf(262144), RegistryAccess.EMPTY);
|
||||||
|
+ this.reason = Component.Serializer.fromJsonLenient(buffer.readUtf(FriendlyByteBuf.MAX_COMPONENT_STRING_LENGTH), RegistryAccess.EMPTY); // Paper - diff on change
|
||||||
|
}
|
||||||
|
|
||||||
|
private void write(FriendlyByteBuf buffer) {
|
||||||
|
- buffer.writeUtf(Component.Serializer.toJson(this.reason, RegistryAccess.EMPTY));
|
||||||
|
+ // Paper start - Adventure
|
||||||
|
+ // buffer.writeUtf(Component.Serializer.toJson(this.reason, RegistryAccess.EMPTY));
|
||||||
|
+ // In the login phase, buffer.adventure$locale field is most likely null, but plugins may use internals to set it via the channel attribute
|
||||||
|
+ java.util.Locale bufLocale = buffer.adventure$locale;
|
||||||
|
+ buffer.writeJsonWithCodec(net.minecraft.network.chat.ComponentSerialization.localizedCodec(bufLocale == null ? java.util.Locale.US : bufLocale), this.reason, FriendlyByteBuf.MAX_COMPONENT_STRING_LENGTH);
|
||||||
|
+ // Paper end - Adventure
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
|
@ -1,12 +1,12 @@
|
||||||
--- a/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java
|
--- a/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java
|
||||||
+++ b/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java
|
+++ b/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java
|
||||||
@@ -20,7 +20,17 @@
|
@@ -20,7 +_,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CustomQueryAnswerPayload readPayload(int queryId, FriendlyByteBuf buf) {
|
private static CustomQueryAnswerPayload readPayload(int transactionId, FriendlyByteBuf buffer) {
|
||||||
- return readUnknownPayload(buf);
|
- return readUnknownPayload(buffer);
|
||||||
+ // Paper start - MC Utils - default query payloads
|
+ // Paper start - MC Utils - default query payloads
|
||||||
+ FriendlyByteBuf buffer = buf.readNullable((buf2) -> {
|
+ FriendlyByteBuf buf = buffer.readNullable((buf2) -> {
|
||||||
+ int i = buf2.readableBytes();
|
+ int i = buf2.readableBytes();
|
||||||
+ if (i >= 0 && i <= MAX_PAYLOAD_SIZE) {
|
+ if (i >= 0 && i <= MAX_PAYLOAD_SIZE) {
|
||||||
+ return new FriendlyByteBuf(buf2.readBytes(i));
|
+ return new FriendlyByteBuf(buf2.readBytes(i));
|
||||||
|
@ -14,19 +14,18 @@
|
||||||
+ throw new IllegalArgumentException("Payload may not be larger than " + MAX_PAYLOAD_SIZE + " bytes");
|
+ throw new IllegalArgumentException("Payload may not be larger than " + MAX_PAYLOAD_SIZE + " bytes");
|
||||||
+ }
|
+ }
|
||||||
+ });
|
+ });
|
||||||
+ return buffer == null ? null : new net.minecraft.network.protocol.login.ServerboundCustomQueryAnswerPacket.QueryAnswerPayload(buffer);
|
+ return buf == null ? null : new net.minecraft.network.protocol.login.ServerboundCustomQueryAnswerPacket.QueryAnswerPayload(buf);
|
||||||
+ // Paper end - MC Utils - default query payloads
|
+ // Paper end - MC Utils - default query payloads
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CustomQueryAnswerPayload readUnknownPayload(FriendlyByteBuf buf) {
|
private static CustomQueryAnswerPayload readUnknownPayload(FriendlyByteBuf buffer) {
|
||||||
@@ -47,4 +57,21 @@
|
@@ -47,4 +_,19 @@
|
||||||
public void handle(ServerLoginPacketListener listener) {
|
public void handle(ServerLoginPacketListener handler) {
|
||||||
listener.handleCustomQueryPacket(this);
|
handler.handleCustomQueryPacket(this);
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ // Paper start - MC Utils - default query payloads
|
+ // Paper start - MC Utils - default query payloads
|
||||||
+ public static final class QueryAnswerPayload implements CustomQueryAnswerPayload {
|
+ public static final class QueryAnswerPayload implements CustomQueryAnswerPayload {
|
||||||
+
|
|
||||||
+ public final FriendlyByteBuf buffer;
|
+ public final FriendlyByteBuf buffer;
|
||||||
+
|
+
|
||||||
+ public QueryAnswerPayload(final net.minecraft.network.FriendlyByteBuf buffer) {
|
+ public QueryAnswerPayload(final net.minecraft.network.FriendlyByteBuf buffer) {
|
||||||
|
@ -39,5 +38,4 @@
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - MC Utils - default query payloads
|
+ // Paper end - MC Utils - default query payloads
|
||||||
+
|
|
||||||
}
|
}
|
|
@ -1,21 +0,0 @@
|
||||||
--- a/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java
|
|
||||||
+++ b/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java
|
|
||||||
@@ -18,11 +18,16 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
private ClientboundLoginDisconnectPacket(FriendlyByteBuf buf) {
|
|
||||||
- this.reason = Component.Serializer.fromJsonLenient(buf.readUtf(262144), RegistryAccess.EMPTY);
|
|
||||||
+ this.reason = Component.Serializer.fromJsonLenient(buf.readUtf(FriendlyByteBuf.MAX_COMPONENT_STRING_LENGTH), RegistryAccess.EMPTY); // Paper - diff on change
|
|
||||||
}
|
|
||||||
|
|
||||||
private void write(FriendlyByteBuf buf) {
|
|
||||||
- buf.writeUtf(Component.Serializer.toJson(this.reason, RegistryAccess.EMPTY));
|
|
||||||
+ // Paper start - Adventure
|
|
||||||
+ // buf.writeUtf(Component.Serializer.toJson(this.reason, RegistryAccess.EMPTY));
|
|
||||||
+ // In the login phase, buf.adventure$locale field is most likely null, but plugins may use internals to set it via the channel attribute
|
|
||||||
+ java.util.Locale bufLocale = buf.adventure$locale;
|
|
||||||
+ buf.writeJsonWithCodec(net.minecraft.network.chat.ComponentSerialization.localizedCodec(bufLocale == null ? java.util.Locale.US : bufLocale), this.reason, FriendlyByteBuf.MAX_COMPONENT_STRING_LENGTH);
|
|
||||||
+ // Paper end - Adventure
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
Loading…
Reference in a new issue