13
0
geforkt von Mirrors/Velocity

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() { public void clearPlayerListHeaderAndFooter() {
clearPlayerListHeaderAndFooterSilent(); clearPlayerListHeaderAndFooterSilent();
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) { 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 { public class HeaderAndFooter implements MinecraftPacket {
private static final HeaderAndFooter RESET = new HeaderAndFooter();
private final ComponentHolder header; private final ComponentHolder header;
private final ComponentHolder footer; private final ComponentHolder footer;
public HeaderAndFooter() { public HeaderAndFooter() {
this(ComponentHolder.EMPTY, ComponentHolder.EMPTY); throw new UnsupportedOperationException("Decode is not implemented");
} }
public HeaderAndFooter(ComponentHolder header, ComponentHolder footer) { public HeaderAndFooter(ComponentHolder header, ComponentHolder footer) {
@ -72,7 +70,8 @@ public class HeaderAndFooter implements MinecraftPacket {
new ComponentHolder(protocolVersion, footer)); new ComponentHolder(protocolVersion, footer));
} }
public static HeaderAndFooter reset() { public static HeaderAndFooter reset(ProtocolVersion version) {
return RESET; 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; import java.util.Map;
public class ComponentHolder { public class ComponentHolder {
public static ComponentHolder EMPTY = new ComponentHolder(null, Component.empty());
private static final Logger logger = LogManager.getLogger(ComponentHolder.class); private static final Logger logger = LogManager.getLogger(ComponentHolder.class);
static {
EMPTY.json = "{\"text\":\"\"}";
EMPTY.binaryTag = StringBinaryTag.stringBinaryTag("");
}
private final ProtocolVersion version; private final ProtocolVersion version;
private @MonotonicNonNull Component component; private @MonotonicNonNull Component component;
private @MonotonicNonNull String json; private @MonotonicNonNull String json;