Don't attempt to clear registry that hasn't been loaded yet (#5101)

This commit is contained in:
chris 2024-10-25 00:55:19 +08:00 committed by GitHub
parent e7ecb55f33
commit 29fe033257
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View file

@ -723,7 +723,9 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {
runIfNonNull(newsHandler, NewsHandler::shutdown);
runIfNonNull(erosionUnixListener, UnixSocketClientListener::close);
Registries.RESOURCE_PACKS.get().clear();
if (Registries.RESOURCE_PACKS.loaded()) {
Registries.RESOURCE_PACKS.get().clear();
}
this.setEnabled(false);
}

View file

@ -112,6 +112,13 @@ public final class DeferredRegistry<M> implements IRegistry<M> {
this.loaded = true;
}
/**
* Whether this registry was loaded.
*/
public boolean loaded() {
return this.loaded;
}
/**
* Creates a new deferred registry.
*