Add null check for Component in BinaryWriter

This commit is contained in:
Kieran Wallbanks 2021-03-12 15:18:06 +00:00
parent 5ac5b0ba99
commit c40139349b

View File

@ -16,6 +16,7 @@ import org.jglrxavpok.hephaistos.nbt.NBTWriter;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -68,7 +69,7 @@ public class BinaryWriter extends OutputStream {
* @param component the component * @param component the component
*/ */
public void writeComponent(Component component) { public void writeComponent(Component component) {
this.writeSizedString(MinecraftServer.getSerializationManager().serialize(component)); this.writeSizedString(MinecraftServer.getSerializationManager().serialize(Objects.requireNonNullElseGet(component, Component::empty)));
} }
/** /**