diff --git a/src/main/java/net/minestom/server/network/packet/server/play/ResourcePackSendPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/ResourcePackSendPacket.java index c33d24c4c..015bc503f 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/ResourcePackSendPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/ResourcePackSendPacket.java @@ -13,7 +13,7 @@ public class ResourcePackSendPacket implements ServerPacket { public String url = ""; public String hash = "0000000000000000000000000000000000000000"; // Size 40 public boolean forced; - public Component forcedMessage = Component.empty(); + public Component forcedMessage; public ResourcePackSendPacket() { } @@ -30,8 +30,11 @@ public class ResourcePackSendPacket implements ServerPacket { writer.writeSizedString(url); writer.writeSizedString(hash); writer.writeBoolean(forced); - if (forced) { + if (forcedMessage != null) { + writer.writeBoolean(true); writer.writeComponent(forcedMessage); + } else { + writer.writeBoolean(false); } } @@ -40,8 +43,12 @@ public class ResourcePackSendPacket implements ServerPacket { this.url = reader.readSizedString(); this.hash = reader.readSizedString(); this.forced = reader.readBoolean(); - if (forced) { + + final boolean hasMessage = reader.readBoolean(); + if (hasMessage) { this.forcedMessage = reader.readComponent(); + } else { + this.forcedMessage = null; } } diff --git a/src/main/java/net/minestom/server/resourcepack/ResourcePack.java b/src/main/java/net/minestom/server/resourcepack/ResourcePack.java index c0719bec0..cd10a3e47 100644 --- a/src/main/java/net/minestom/server/resourcepack/ResourcePack.java +++ b/src/main/java/net/minestom/server/resourcepack/ResourcePack.java @@ -35,10 +35,14 @@ public class ResourcePack { return new ResourcePack(url, hash); } - public static ResourcePack forced(@NotNull String url, @Nullable String hash, @NotNull Component forcedMessage) { + public static ResourcePack forced(@NotNull String url, @Nullable String hash, @Nullable Component forcedMessage) { return new ResourcePack(url, hash, true, forcedMessage); } + public static ResourcePack forced(@NotNull String url, @Nullable String hash) { + return forced(url, hash, null); + } + /** * Gets the resource pack URL. *