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

Add variant support for slugs & server version limitation #1356

Merged
merged 5 commits into from
Aug 2, 2024

Conversation

Pablete1234
Copy link
Member

@Pablete1234 Pablete1234 commented Jul 6, 2024

<map min-server-version="1.21">
    <name>New map</name>
    <variant id="old" min-server-version="1.8" max-server-version="1.17" world="legacy">Old map</variant>
</map>

The map itself can have min-server-version and max-server-version and individual variants can also override this

Slugs

Currently slugs are broken in variants, as one variant can't know the slug of other variants, since it's not part of the XML it sees (part of conditionals)
This PR fixes that by adding slug as an attribute in variants:

<map>
  <name>New map</name>
  <variant id="old" slug="map_old">Old map</variant>
</map>

If a slug is defined in the variant, that slug is used, otherwise:
For variants override=true: the slug defaults to the variant name slugified
For variants override=false & no default <slug>: the slug will be the full variant name slugified
For variants override=false & and default <slug>: the slug will be defaultslug + "_" + variantId

This aligns closely with what the behavior would usually be if it went thru the old rules, but won't always be the same

@Pablete1234 Pablete1234 added the feature New feature or request label Jul 6, 2024
@Pablete1234 Pablete1234 force-pushed the add-version-requirements branch from 77caa04 to e2a61a2 Compare July 6, 2024 18:17
@Pablete1234 Pablete1234 force-pushed the add-version-requirements branch from 8812dba to c7e3fc0 Compare July 27, 2024 18:42
TTtie and others added 2 commits July 27, 2024 20:52
This patch adds the ability to prevent 1.13+ maps without a specified minimum version in `map.xml` from accidentally being loaded into legacy servers, causing undefined behavior including server crashes when cycled to.

This is achieved by reading the data version (an integer increased with any Minecraft version, including snapshots [1]) from `level.dat` bundled with the map and inferring whether the map is a 1.13+ map.

[1]: https://minecraft.wiki/w/Data_version

Signed-off-by: TTtie <[email protected]>
Copy link
Contributor

@TTtie TTtie left a comment

Choose a reason for hiding this comment

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

uh-oh! it blew up 😭

add'l issues/notes:

  • /map <map> lists variants not loaded due to version restrictions
  • it might be worthwhile to note somewhere in the docs that max-server-version="1.8" means "limit to 1.8.0", not "limit to 1.8.8" (depending on how common the belief of "max-server-version="1.8" includes 1.8.8 servers" is going to get)

@Pablete1234
Copy link
Member Author

image
image

Variants that can't load will now appear in red and have an explicit hover message

@Pablete1234 Pablete1234 marked this pull request as ready for review July 31, 2024 20:19
@Pablete1234 Pablete1234 requested a review from cswhite2000 as a code owner July 31, 2024 20:19
@Pablete1234
Copy link
Member Author

There's one pending thing and it's unused node detection can mark the attributes on the root as unused for the variants. How exactly we tackle unused node detection in variants is something i want to give more thought and a more final solution later down the road, so it'll be ignored for now.

@Pablete1234 Pablete1234 changed the title Add support for version-gated maps & variants Add variant support for slugs & server version limitation Jul 31, 2024
Copy link
Member

@cswhite2000 cswhite2000 left a comment

Choose a reason for hiding this comment

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

No major concerns

info.getId(), info, (m1, m2) -> m2.getVersion().isOlderThan(m1.getVersion()) ? m1 : m2);
// Only if from a supported version, add it to our library
if (info.isServerSupported()) {
maps.merge(
Copy link
Member

Choose a reason for hiding this comment

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

Will this register as a failure and should it? I feel like there would be some value in logging it specifically as a version incompatibility. I feel like people might be confused if we don't log anything.

Copy link
Member Author

Choose a reason for hiding this comment

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

It will simply skip maps that are not for the current server version. It is intended as you may maintain a repo that contains both 1.8 and 1.21 maps, and simply when running in 1.8 the 1.21 maps are skipped and all is good

I'm not sure about logging as it'd likely lead to log-spam that is not really serving any use, as in, whoever set those maps knows what they're doing

@Pablete1234 Pablete1234 merged commit 8ceb978 into dev Aug 2, 2024
2 checks passed
@Pablete1234 Pablete1234 deleted the add-version-requirements branch August 2, 2024 16:10
Pablete1234 added a commit that referenced this pull request Nov 30, 2024
Signed-off-by: Pablo Herrera <[email protected]>
Signed-off-by: TTtie <[email protected]>
Co-authored-by: TTtie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Development

Successfully merging this pull request may close these issues.

4 participants