From 29fe033257d78e92cf7f3c957b809599d3f83b06 Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 25 Oct 2024 00:55:19 +0800 Subject: [PATCH] Don't attempt to clear registry that hasn't been loaded yet (#5101) --- core/src/main/java/org/geysermc/geyser/GeyserImpl.java | 4 +++- .../org/geysermc/geyser/registry/DeferredRegistry.java | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/geysermc/geyser/GeyserImpl.java b/core/src/main/java/org/geysermc/geyser/GeyserImpl.java index 9df1d2189..4672aef5b 100644 --- a/core/src/main/java/org/geysermc/geyser/GeyserImpl.java +++ b/core/src/main/java/org/geysermc/geyser/GeyserImpl.java @@ -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); } diff --git a/core/src/main/java/org/geysermc/geyser/registry/DeferredRegistry.java b/core/src/main/java/org/geysermc/geyser/registry/DeferredRegistry.java index 6a2f2ae37..ce77261ae 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/DeferredRegistry.java +++ b/core/src/main/java/org/geysermc/geyser/registry/DeferredRegistry.java @@ -112,6 +112,13 @@ public final class DeferredRegistry implements IRegistry { this.loaded = true; } + /** + * Whether this registry was loaded. + */ + public boolean loaded() { + return this.loaded; + } + /** * Creates a new deferred registry. *