diff --git a/src/main/java/net/minestom/server/network/packet/server/play/DisconnectPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/DisconnectPacket.java index c3ef7bd56..48a3e3e7b 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/DisconnectPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/DisconnectPacket.java @@ -1,6 +1,5 @@ package net.minestom.server.network.packet.server.play; -import net.kyori.adventure.text.Component; import net.minestom.server.chat.JsonMessage; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; @@ -8,14 +7,14 @@ import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; public class DisconnectPacket implements ServerPacket { - private String payload; + public String message; /** * Creates a new disconnect packet with a given string. - * @param payload the message + * @param message the message */ - public DisconnectPacket(@NotNull String payload) { - this.payload = payload; + public DisconnectPacket(@NotNull String message) { + this.message = message; } /** @@ -28,7 +27,7 @@ public class DisconnectPacket implements ServerPacket { @Override public void write(@NotNull BinaryWriter writer) { - writer.writeSizedString(payload); + writer.writeSizedString(message); } @Override diff --git a/src/main/java/net/minestom/server/network/packet/server/play/PlayerListHeaderAndFooterPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/PlayerListHeaderAndFooterPacket.java index 021f98727..003540418 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/PlayerListHeaderAndFooterPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/PlayerListHeaderAndFooterPacket.java @@ -1,26 +1,24 @@ package net.minestom.server.network.packet.server.play; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; import net.minestom.server.utils.binary.BinaryWriter; -import org.apache.commons.lang3.Validate; import org.jetbrains.annotations.NotNull; +import java.util.Objects; + public class PlayerListHeaderAndFooterPacket implements ServerPacket { + private static final String EMPTY_COMPONENT = PlainComponentSerializer.plain().serialize(Component.empty()); + public String header; public String footer; - public PlayerListHeaderAndFooterPacket(@NotNull String header, @NotNull String footer) { - Validate.notNull(header, "Header cannot be null."); - Validate.notNull(footer, "Footer cannot be null."); - this.header = header; - this.footer = footer; - } - @Override public void write(@NotNull BinaryWriter writer) { - writer.writeSizedString(header); - writer.writeSizedString(footer); + writer.writeSizedString(Objects.requireNonNullElse(header, EMPTY_COMPONENT)); + writer.writeSizedString(Objects.requireNonNullElse(footer, EMPTY_COMPONENT)); } @Override diff --git a/src/main/java/net/minestom/server/network/packet/server/play/TitlePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/TitlePacket.java index 25f8717bc..f99e0e53b 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/TitlePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/TitlePacket.java @@ -2,7 +2,6 @@ package net.minestom.server.network.packet.server.play; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.title.Title; -import net.minestom.server.chat.JsonMessage; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; import net.minestom.server.utils.TickUtils; @@ -18,14 +17,17 @@ import static net.minestom.server.network.packet.server.play.TitlePacket.Action. public class TitlePacket implements ServerPacket { - private Action action; + public Action action; - private String payload; + public String payload; - private int fadeIn, stay, fadeOut; + public int fadeIn; + public int stay; + public int fadeOut; /** * Constructs a new title packet from an action that can take a string argument. + * * @param action the action * @param payload the payload * @throws IllegalArgumentException if the action is not {@link Action#SET_TITLE}, @@ -39,6 +41,7 @@ public class TitlePacket implements ServerPacket { /** * Constructs a new title packet from a clear or reset action. + * * @param action the action * @throws IllegalArgumentException if the action is not {@link Action#RESET}, * or {@link Action#HIDE} @@ -49,6 +52,7 @@ public class TitlePacket implements ServerPacket { /** * Constructs a new title packet for {@link Action#SET_TIMES_AND_DISPLAY}. + * * @param fadeIn the fade in time * @param stay the stay time * @param fadeOut the fade out time @@ -97,6 +101,7 @@ public class TitlePacket implements ServerPacket { /** * Creates a collection of title packets from an Adventure title. + * * @param title the title * @return the packets */