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

quasiConnectivity cannot accept any value above 1 when reloading from carpet.conf #1862

Closed
axialeaa opened this issue Jan 19, 2024 · 2 comments

Comments

@axialeaa
Copy link

Observed Behaviour

Using /carpet setDefault to change the quasiConnectivity rule to something above 1 throws an InvalidRuleValueException upon server restart, despite the validator theoretically accepting any number from 0 to the world height. The value will then set itself back to 1, the default.

Hypothesis

This is most likely to do with maxRange not reassigning properly inside the validator. Perhaps while the server command source is not null, the world cannot be found?

private static class QuasiConnectivityValidator extends Validator<Integer> {

    @Override
    public Integer validate(ServerCommandSource source, CarpetRule<Integer> changingRule, Integer newValue, String userInput) {
        int minRange = 0;
        int maxRange = 1;

        if (source == null) {
            maxRange = Integer.MAX_VALUE;
        } else {
            for (World level : source.getServer().getWorlds()) {
                maxRange = Math.max(maxRange, level.getHeight() - 1);
            }
        }

        return (newValue >= minRange && newValue <= maxRange) ? newValue : null;
    }
}

To Reproduce:

  1. Enter a singleplayer world and run /carpet setDefault quasiConnectivity 10
  2. Exit the world
  3. Rejoin the world, monitoring the game log as it loads, observing the InvalidRuleValueException being thrown for "10"
  4. Run /carpet quasiConnectivity, and observe the rule having been set to 1 instead of 10
@altrisi
Copy link
Collaborator

altrisi commented Jan 19, 2024

Yes, looks like when we load the rules the list of worlds isn't ready yet so it was staying at one.

@axialeaa
Copy link
Author

Interesting. Thanks for the fast response!

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

No branches or pull requests

2 participants