Skip to content

Commit 542e2ff

Browse files
authored
Fix optional enforcesSecureChat in ServerStatusInfo (#762)
1 parent 64d5824 commit 542e2ff

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/main/java/com/github/steveice10/mc/protocol/data/status/ServerStatusInfo.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import lombok.NonNull;
77
import lombok.Setter;
88
import net.kyori.adventure.text.Component;
9+
import org.jetbrains.annotations.Nullable;
910

1011
@Data
1112
@Setter(AccessLevel.NONE)
@@ -15,5 +16,5 @@ public class ServerStatusInfo {
1516
private @NonNull PlayerInfo playerInfo;
1617
private @NonNull Component description;
1718
private byte[] iconPng;
18-
private boolean enforcesSecureChat;
19+
private @Nullable Boolean enforcesSecureChat;
1920
}

src/main/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundStatusResponsePacket.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ public ClientboundStatusResponsePacket(ByteBuf in, MinecraftCodecHelper helper)
5454
icon = this.stringToIcon(obj.get("favicon").getAsString());
5555
}
5656

57-
boolean enforcesSecureChat = obj.get("enforcesSecureChat").getAsBoolean();
57+
Boolean enforcesSecureChat = null;
58+
if (obj.has("enforcesSecureChat")) {
59+
enforcesSecureChat = obj.get("enforcesSecureChat").getAsBoolean();
60+
}
5861
this.info = new ServerStatusInfo(version, players, description, icon, enforcesSecureChat);
5962
}
6063

@@ -85,7 +88,9 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOExcepti
8588
if (this.info.getIconPng() != null) {
8689
obj.addProperty("favicon", this.iconToString(this.info.getIconPng()));
8790
}
88-
obj.addProperty("enforcesSecureChat", this.info.isEnforcesSecureChat());
91+
if (this.info.getEnforcesSecureChat() != null) {
92+
obj.addProperty("enforcesSecureChat", this.info.getEnforcesSecureChat());
93+
}
8994

9095
helper.writeString(out, obj.toString());
9196
}

0 commit comments

Comments
 (0)