diff --git a/src/main/java/xyz/nucleoid/plasmid/game/config/GameConfig.java b/src/main/java/xyz/nucleoid/plasmid/game/config/GameConfig.java index e5ea8fa6..bb338b77 100644 --- a/src/main/java/xyz/nucleoid/plasmid/game/config/GameConfig.java +++ b/src/main/java/xyz/nucleoid/plasmid/game/config/GameConfig.java @@ -54,6 +54,13 @@ public Identifier source() { return this.source; } + /** + * @return the source location that this config was loaded from, if loaded from a file. + */ + public static String sourceName(GameConfig config) { + return Optional.ofNullable(config.source).map(Identifier::toString).orElse("[unknown source]"); + } + /** * @return the name for this game config, defaulted to the game type name if none is specified */ diff --git a/src/main/java/xyz/nucleoid/plasmid/game/manager/GameSpaceManager.java b/src/main/java/xyz/nucleoid/plasmid/game/manager/GameSpaceManager.java index 91d6be10..d91caa49 100644 --- a/src/main/java/xyz/nucleoid/plasmid/game/manager/GameSpaceManager.java +++ b/src/main/java/xyz/nucleoid/plasmid/game/manager/GameSpaceManager.java @@ -110,7 +110,7 @@ private ManagedGameSpace addGameSpace(GameConfig config, GameConfig source this.idToGameSpace.put(id, gameSpace); this.userIdToGameSpace.put(userId, gameSpace); - Plasmid.LOGGER.info("Game space {} (source: {}) opened", id, config.source()); + Plasmid.LOGGER.info("Game space {} (source: {}) opened", id, GameConfig.sourceName(config)); GameEvents.OPENED.invoker().onGameSpaceOpened(config, gameSpace); procedure.apply(gameSpace); diff --git a/src/main/java/xyz/nucleoid/plasmid/game/manager/ManagedGameSpace.java b/src/main/java/xyz/nucleoid/plasmid/game/manager/ManagedGameSpace.java index 8572fdf5..4b4bfcf8 100644 --- a/src/main/java/xyz/nucleoid/plasmid/game/manager/ManagedGameSpace.java +++ b/src/main/java/xyz/nucleoid/plasmid/game/manager/ManagedGameSpace.java @@ -11,6 +11,7 @@ import xyz.nucleoid.plasmid.Plasmid; import xyz.nucleoid.plasmid.event.GameEvents; import xyz.nucleoid.plasmid.game.*; +import xyz.nucleoid.plasmid.game.config.GameConfig; import xyz.nucleoid.plasmid.game.event.GameActivityEvents; import xyz.nucleoid.plasmid.game.event.GamePlayerEvents; import xyz.nucleoid.plasmid.game.player.PlayerOffer; @@ -105,7 +106,7 @@ public void close(GameCloseReason reason) { var players = Lists.newArrayList(this.players); - Plasmid.LOGGER.info("Game space {} (source: {}) closing for reason {}", this.metadata.id(), this.metadata.sourceConfig().source(), reason); + Plasmid.LOGGER.info("Game space {} (source: {}) closing for reason {}", this.metadata.id(), GameConfig.sourceName(this.metadata.sourceConfig()), reason); GameEvents.CLOSING.invoker().onGameSpaceClosing(this, reason); this.lifecycle.onClosing(this, reason);