fix: reuse already loaded world and handle Folia unsupported world creation
This commit is contained in:
parent
4e3ccfd736
commit
cc521dc284
1 changed files with 16 additions and 1 deletions
|
|
@ -54,6 +54,11 @@ public class World {
|
||||||
|
|
||||||
if (Config.CONFIG.getBoolean("world.delete-on-reload")) {
|
if (Config.CONFIG.getBoolean("world.delete-on-reload")) {
|
||||||
deleteWorld();
|
deleteWorld();
|
||||||
|
} else if (world != null) {
|
||||||
|
// Already loaded (e.g. pre-created by a worlds plugin, required on Folia) — do not recreate.
|
||||||
|
LoParkour.log("Using already loaded world " + name);
|
||||||
|
setup();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
createWorld();
|
createWorld();
|
||||||
|
|
@ -71,6 +76,10 @@ public class World {
|
||||||
.environment(org.bukkit.World.Environment.NORMAL);
|
.environment(org.bukkit.World.Environment.NORMAL);
|
||||||
|
|
||||||
world = Bukkit.createWorld(creator);
|
world = Bukkit.createWorld(creator);
|
||||||
|
} catch (UnsupportedOperationException ex) {
|
||||||
|
LoParkour.getPlugin().getLogger().severe(
|
||||||
|
"World creation is not supported on this server (Folia). Pre-create the world '" + name
|
||||||
|
+ "' with a worlds plugin and restart.");
|
||||||
} catch (IllegalArgumentException | IllegalStateException ex) {
|
} catch (IllegalArgumentException | IllegalStateException ex) {
|
||||||
LoParkour.getPlugin().getLogger().severe(
|
LoParkour.getPlugin().getLogger().severe(
|
||||||
"Error while trying to create the parkour world — check world.name — " + ex.getMessage());
|
"Error while trying to create the parkour world — check world.name — " + ex.getMessage());
|
||||||
|
|
@ -130,7 +139,13 @@ public class World {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
Bukkit.unloadWorld(name, false);
|
Bukkit.unloadWorld(name, false);
|
||||||
|
} catch (UnsupportedOperationException ex) {
|
||||||
|
LoParkour.getPlugin().getLogger().severe(
|
||||||
|
"Cannot unload/delete world on this server (Folia) — set world.delete-on-reload to false.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try (Stream<Path> files = Files.walk(folder.toPath())) {
|
try (Stream<Path> files = Files.walk(folder.toPath())) {
|
||||||
files.sorted(Comparator.reverseOrder())
|
files.sorted(Comparator.reverseOrder())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue