geforkt von Mirrors/Paper
Fix some component bugs in login disconnect packet (#10090)
Dieser Commit ist enthalten in:
Ursprung
09ae4f6257
Commit
c4e0d81696
@ -3231,6 +3231,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
|
||||
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Stores details for players attempting to log in.
|
||||
* <p>
|
||||
* This event is asynchronous, and not run using main thread.
|
||||
+ * <p>
|
||||
+ * When this event is fired, the player's locale is not
|
||||
+ * available. Therefore, any translatable component will be
|
||||
+ * rendered with the default locale, {@link java.util.Locale#US}.
|
||||
+ * <p>
|
||||
+ * Consider rendering any translatable yourself with {@link net.kyori.adventure.translation.GlobalTranslator#render}
|
||||
+ * if the client's language is known.
|
||||
*/
|
||||
public class AsyncPlayerPreLoginEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Result result;
|
||||
@ -3738,6 +3749,20 @@ diff --git a/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java b/sr
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java
|
||||
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Stores details for players attempting to log in
|
||||
+ * <p>
|
||||
+ * When this event is fired, the player's locale is not
|
||||
+ * available. Therefore, any translatable component will be
|
||||
+ * rendered with the default locale, {@link java.util.Locale#US}.
|
||||
+ * <p>
|
||||
+ * Consider rendering any translatable yourself with {@link net.kyori.adventure.translation.GlobalTranslator#render}
|
||||
+ * if the client's language is known.
|
||||
*
|
||||
* @deprecated This event causes synchronization from the login thread; {@link
|
||||
* AsyncPlayerPreLoginEvent} is preferred to keep the secondary threads
|
||||
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class PlayerPreLoginEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
@ -2167,6 +2167,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
public static final short MAX_STRING_LENGTH = 32767;
|
||||
public static final int MAX_COMPONENT_STRING_LENGTH = 262144;
|
||||
private static final int PUBLIC_KEY_SIZE = 256;
|
||||
@@ -0,0 +0,0 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
}
|
||||
|
||||
public <T> void writeJsonWithCodec(Codec<T> codec, T value) {
|
||||
+ // Paper start - Adventure
|
||||
+ this.writeJsonWithCodec(codec, value, MAX_STRING_LENGTH);
|
||||
+ }
|
||||
+ public <T> void writeJsonWithCodec(Codec<T> codec, T value, int maxLength) {
|
||||
+ // Paper end - Adventure
|
||||
DataResult<JsonElement> dataresult = codec.encodeStart(JsonOps.INSTANCE, value);
|
||||
|
||||
this.writeUtf(FriendlyByteBuf.GSON.toJson((JsonElement) Util.getOrThrow(dataresult, (s) -> {
|
||||
return new EncoderException("Failed to encode: " + s + " " + value);
|
||||
- })));
|
||||
+ })), maxLength); // Paper - Adventure
|
||||
}
|
||||
|
||||
public <T> void writeId(IdMap<T> registry, T value) {
|
||||
@@ -0,0 +0,0 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
return (Component) this.readWithCodecTrusted(NbtOps.INSTANCE, ComponentSerialization.CODEC);
|
||||
}
|
||||
@ -2605,6 +2623,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
buf.writeComponent(this.header);
|
||||
buf.writeComponent(this.footer);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java b/src/main/java/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/login/ClientboundLoginDisconnectPacket.java
|
||||
@@ -0,0 +0,0 @@ public class ClientboundLoginDisconnectPacket implements Packet<ClientLoginPacke
|
||||
}
|
||||
|
||||
public ClientboundLoginDisconnectPacket(FriendlyByteBuf buf) {
|
||||
- this.reason = Component.Serializer.fromJsonLenient(buf.readUtf(262144));
|
||||
+ this.reason = Component.Serializer.fromJsonLenient(buf.readUtf(FriendlyByteBuf.MAX_COMPONENT_STRING_LENGTH)); // Paper - diff on change
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(FriendlyByteBuf buf) {
|
||||
- buf.writeUtf(Component.Serializer.toJson(this.reason));
|
||||
+ // Paper start - Adventure
|
||||
+ //buf.writeUtf(Component.Serializer.toJson(this.reason));
|
||||
+
|
||||
+ // In the login phase, buf.adventure$locale field is always null
|
||||
+ buf.writeJsonWithCodec(net.minecraft.network.chat.ComponentSerialization.localizedCodec(java.util.Locale.US), this.reason, FriendlyByteBuf.MAX_COMPONENT_STRING_LENGTH);
|
||||
+ // Paper end - Adventure
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren