mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 10:36:06 +01:00
Copy spawn location only if seed didnt change on regen
This commit is contained in:
parent
ef0cb4b893
commit
c0f2168ba4
@ -598,11 +598,15 @@ public class WorldManager {
|
||||
LoadedMultiverseWorld world = options.world();
|
||||
List<Player> playersInWorld = world.getPlayers().getOrElse(Collections.emptyList());
|
||||
DataTransfer<LoadedMultiverseWorld> dataTransfer = transferData(options, world);
|
||||
boolean shouldKeepSpawnLocation = options.keepWorldConfig() && options.seed() == world.getSeed();
|
||||
Location spawnLocation = world.getSpawnLocation();
|
||||
|
||||
CreateWorldOptions createWorldOptions = CreateWorldOptions.worldName(world.getName())
|
||||
.environment(world.getEnvironment())
|
||||
.generateStructures(world.canGenerateStructures().getOrElse(true))
|
||||
.generator(world.getGenerator())
|
||||
.seed(options.seed())
|
||||
.useSpawnAdjust(!shouldKeepSpawnLocation && world.getAdjustSpawn())
|
||||
.worldType(world.getWorldType().getOrElse(WorldType.NORMAL));
|
||||
|
||||
return deleteWorld(world)
|
||||
@ -610,6 +614,11 @@ public class WorldManager {
|
||||
.mapAttempt(() -> createWorld(createWorldOptions).transform(RegenFailureReason.CREATE_FAILED))
|
||||
.onSuccess(newWorld -> {
|
||||
dataTransfer.pasteAllTo(newWorld);
|
||||
if (shouldKeepSpawnLocation) {
|
||||
// Special case for spawn location to prevent unsafe location if world was regen using a
|
||||
// different seed.
|
||||
newWorld.setSpawnLocation(spawnLocation);
|
||||
}
|
||||
teleportPlayersToWorld(playersInWorld, newWorld);
|
||||
saveWorldsConfig();
|
||||
});
|
||||
|
@ -66,10 +66,6 @@ class WorldConfigTest : TestWithMockBukkit() {
|
||||
val blacklists = listOf("a", "b", "c")
|
||||
assertTrue(worldConfig.setProperty("world-blacklist", blacklists).isSuccess)
|
||||
assertEquals(blacklists, worldConfig.getProperty("world-blacklist").get())
|
||||
|
||||
val location = Location(null, 1.0, 2.0, 3.0)
|
||||
assertTrue(worldConfig.setProperty("spawn-location", location).isSuccess)
|
||||
assertEquals(location, worldConfig.getProperty("spawn-location").get())
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user