Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the Optional type server status version being compared to null #1294

Merged
merged 1 commit into from
Mar 20, 2023

Conversation

MartijnMuijsers
Copy link
Contributor

The server status version (MinecraftServer.getServer().getStatus().version()) used to be a nullable class field, but it is now an Optional record field. Therefore, the comparison to null should be replaced with isEmpty(). In its current state, with the null check, this patch does nothing anymore (because the version will never be null).

To verify the status will in fact be an empty Optional, see net.minecraft.network.protocol.status#CODEC, which uses optionalFieldOf, which returns a com.mojang.serialization.codecs.OptionalFieldCodec for which the decode method never returns null, but an empty Optional in the corresponding scenarios instead.

Copy link
Member

@granny granny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it was an oversight during the update to 1.19.4 :) Thanks!

@granny granny merged commit eb14797 into PurpurMC:ver/1.19.4 Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants