-
Notifications
You must be signed in to change notification settings - Fork 21
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
Defer sponge command registration #184
base: main
Are you sure you want to change the base?
Defer sponge command registration #184
Conversation
Interesting, we never realized this issue as test mod commands are registered through a |
In my case, I ran into this issue while I was developing https://github.com/LegacyHypixel/LegacyBetterConfig |
Alright, after looking more into it, the test mods somehow don't use the command registering event. Which isn't the intended way of registering commands. Can you fix the test mods as well in this pr? |
i also noticed that the |
It's probably a remanent of when test mods weren't split by version yet. |
guess i can clean up those too while i’m at it then |
no idea why the 1.8 test commands were specifically forbidden from using text styling for urls, they work well enough (the only issue is that the url doesn't appear on the screen popup when clicked) all things considered, less problematic than newlines seemingly just not working at all in 1.7.10 |
The Problem
As it currently stands, trying to register sponge commands through
CommandRegistrar#EVENT
from either aClientModInitializer
or aDedicatedServerModInitializer
results in non-determinism as whether they are successfully registered depends on the order the initializers were invoked by fabric loader (becauseCommandRegistrar#EVENT
is also invoked from these entrypoints).The Solution
I added a
CommandRegistrationCallback#EVENT
event in the command api v1 library that is invoked before the vanilla command manager is filled with mod commands during theServerLifecycleEvents#SERVER_STARTING
callback. I then wrapped the sponge command registration event invocations in theImplInit
classes so that their registration is now deferred to theServerLifecycleEvents#SERVER_STARTING
callback rather than the mod initializers.This pull request ensures a strict load order between sponge commands and vanilla commands without breaking backwards compatibility.