diff --git a/src/main/java/xyz/nucleoid/fantasy/Fantasy.java b/src/main/java/xyz/nucleoid/fantasy/Fantasy.java index c718c7d..83b5882 100644 --- a/src/main/java/xyz/nucleoid/fantasy/Fantasy.java +++ b/src/main/java/xyz/nucleoid/fantasy/Fantasy.java @@ -108,7 +108,23 @@ private void tick() { * @return a future providing the created world */ public RuntimeWorldHandle openTemporaryWorld(RuntimeWorldConfig config) { - RuntimeWorld world = this.addTemporaryWorld(config); + return this.openTemporaryWorld(generateTemporaryWorldKey(), config); + } + + /** + * Creates a new temporary world with the given identifier and {@link RuntimeWorldConfig} that will not be saved and will be + * deleted when the server exits. + *
+ * The created world is returned asynchronously through a {@link RuntimeWorldHandle}.
+ * This handle can be used to acquire the {@link ServerWorld} object through {@link RuntimeWorldHandle#asWorld()},
+ * as well as to delete the world through {@link RuntimeWorldHandle#delete()}.
+ *
+ * @param key the unique identifier for this dimension
+ * @param config the config with which to construct this temporary world
+ * @return a future providing the created world
+ */
+ public RuntimeWorldHandle openTemporaryWorld(Identifier key, RuntimeWorldConfig config) {
+ RuntimeWorld world = this.addTemporaryWorld(key, config);
return new RuntimeWorldHandle(this, world);
}
@@ -147,8 +163,8 @@ private RuntimeWorld addPersistentWorld(Identifier key, RuntimeWorldConfig confi
return this.worldManager.add(worldKey, config, RuntimeWorld.Style.PERSISTENT);
}
- private RuntimeWorld addTemporaryWorld(RuntimeWorldConfig config) {
- RegistryKey