3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-16 21:10:30 +01:00

Fix NPE in ComponentHolder

Dieser Commit ist enthalten in:
Gero 2023-12-07 16:20:32 +01:00 committet von Shane Freeder
Ursprung 5b8bba4b29
Commit 8a6c20ee32
3 geänderte Dateien mit 5 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -543,7 +543,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
public void clearPlayerListHeaderAndFooter() {
clearPlayerListHeaderAndFooterSilent();
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
this.connection.write(HeaderAndFooter.reset());
this.connection.write(HeaderAndFooter.reset(this.getProtocolVersion()));
}
}

Datei anzeigen

@ -28,13 +28,11 @@ import net.kyori.adventure.text.Component;
public class HeaderAndFooter implements MinecraftPacket {
private static final HeaderAndFooter RESET = new HeaderAndFooter();
private final ComponentHolder header;
private final ComponentHolder footer;
public HeaderAndFooter() {
this(ComponentHolder.EMPTY, ComponentHolder.EMPTY);
throw new UnsupportedOperationException("Decode is not implemented");
}
public HeaderAndFooter(ComponentHolder header, ComponentHolder footer) {
@ -72,7 +70,8 @@ public class HeaderAndFooter implements MinecraftPacket {
new ComponentHolder(protocolVersion, footer));
}
public static HeaderAndFooter reset() {
return RESET;
public static HeaderAndFooter reset(ProtocolVersion version) {
ComponentHolder empty = new ComponentHolder(version, Component.empty());
return new HeaderAndFooter(empty, empty);
}
}

Datei anzeigen

@ -52,14 +52,8 @@ import java.util.List;
import java.util.Map;
public class ComponentHolder {
public static ComponentHolder EMPTY = new ComponentHolder(null, Component.empty());
private static final Logger logger = LogManager.getLogger(ComponentHolder.class);
static {
EMPTY.json = "{\"text\":\"\"}";
EMPTY.binaryTag = StringBinaryTag.stringBinaryTag("");
}
private final ProtocolVersion version;
private @MonotonicNonNull Component component;
private @MonotonicNonNull String json;