From dfce9dae46700cff255791df16db72bfd9584d2b Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Mon, 30 Jun 2025 13:53:03 +1000 Subject: [PATCH] Logging and checking --- .../me/cortex/voxy/commonImpl/VoxyInstance.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/cortex/voxy/commonImpl/VoxyInstance.java b/src/main/java/me/cortex/voxy/commonImpl/VoxyInstance.java index 1e564452..7b60b8e3 100644 --- a/src/main/java/me/cortex/voxy/commonImpl/VoxyInstance.java +++ b/src/main/java/me/cortex/voxy/commonImpl/VoxyInstance.java @@ -73,6 +73,7 @@ public abstract class VoxyInstance { // note, the reference count should be separate from the number of active chunks to prevent many issues // a world is no longer active once it has no reference counts and no active chunks associated with it public WorldEngine getNullable(WorldIdentifier identifier) { + if (!this.isRunning) return null; var cache = identifier.cachedEngineObject; WorldEngine world; if (cache == null) { @@ -109,11 +110,21 @@ public abstract class VoxyInstance { } public WorldEngine getOrCreate(WorldIdentifier identifier) { + if (!this.isRunning) { + Logger.error("Tried getting world object on voxy instance but its not running"); + return null; + } var world = this.getNullable(identifier); if (world != null) { return world; } long stamp = this.activeWorldLock.writeLock(); + + if (!this.isRunning) { + Logger.error("Tried getting world object on voxy instance but its not running"); + return null; + } + world = this.activeWorlds.get(identifier); if (world == null) { //Create world here @@ -128,10 +139,13 @@ public abstract class VoxyInstance { protected abstract SectionStorage createStorage(WorldIdentifier identifier); private WorldEngine createWorld(WorldIdentifier identifier) { + if (!this.isRunning) { + throw new IllegalStateException("Cannot create world while not running"); + } if (this.activeWorlds.containsKey(identifier)) { throw new IllegalStateException("Existing world with identifier"); } - Logger.info("Creating new world engine: " + identifier.getLongHash()); + Logger.info("Creating new world engine: " + identifier.getLongHash() + "@" + System.identityHashCode(this)); var world = new WorldEngine(this.createStorage(identifier), this); world.setSaveCallback(this.savingService::enqueueSave); this.activeWorlds.put(identifier, world);