Skip to content

Commit

Permalink
Fix optional enforcesSecureChat in ServerStatusInfo (#762)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreypfau authored Nov 23, 2023
1 parent 64d5824 commit 542e2ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.NonNull;
import lombok.Setter;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.Nullable;

@Data
@Setter(AccessLevel.NONE)
Expand All @@ -15,5 +16,5 @@ public class ServerStatusInfo {
private @NonNull PlayerInfo playerInfo;
private @NonNull Component description;
private byte[] iconPng;
private boolean enforcesSecureChat;
private @Nullable Boolean enforcesSecureChat;
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ public ClientboundStatusResponsePacket(ByteBuf in, MinecraftCodecHelper helper)
icon = this.stringToIcon(obj.get("favicon").getAsString());
}

boolean enforcesSecureChat = obj.get("enforcesSecureChat").getAsBoolean();
Boolean enforcesSecureChat = null;
if (obj.has("enforcesSecureChat")) {
enforcesSecureChat = obj.get("enforcesSecureChat").getAsBoolean();
}
this.info = new ServerStatusInfo(version, players, description, icon, enforcesSecureChat);
}

Expand Down Expand Up @@ -85,7 +88,9 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOExcepti
if (this.info.getIconPng() != null) {
obj.addProperty("favicon", this.iconToString(this.info.getIconPng()));
}
obj.addProperty("enforcesSecureChat", this.info.isEnforcesSecureChat());
if (this.info.getEnforcesSecureChat() != null) {
obj.addProperty("enforcesSecureChat", this.info.getEnforcesSecureChat());
}

helper.writeString(out, obj.toString());
}
Expand Down

0 comments on commit 542e2ff

Please sign in to comment.