mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 10:36:06 +01:00
Improve and fix minor migration regressions
This commit is contained in:
parent
fcbaffc821
commit
13b9419b85
@ -19,6 +19,6 @@ public class LongMigratorAction implements MigratorAction {
|
||||
@Override
|
||||
public void migrate(ConfigurationSection config) {
|
||||
config.set(path, ACFUtil.parseLong(config.getString(path)));
|
||||
Logging.info("Converted %s to integer %s", path, config.getLong(path));
|
||||
Logging.info("Converted %s to long %s", path, config.getLong(path));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.onarandombox.MultiverseCore.configuration.migration;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class NullStringMigratorAction implements MigratorAction {
|
||||
|
||||
public static NullStringMigratorAction of(String path) {
|
||||
return new NullStringMigratorAction(path);
|
||||
}
|
||||
|
||||
private final String path;
|
||||
|
||||
protected NullStringMigratorAction(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void migrate(ConfigurationSection config) {
|
||||
config.set(path, "null".equals(config.getString(path)) ? "" : config.getString(path));
|
||||
Logging.info("Converted %s to %s", path, config.getString(path));
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import com.onarandombox.MultiverseCore.configuration.migration.ConfigMigrator;
|
||||
import com.onarandombox.MultiverseCore.configuration.migration.IntegerMigratorAction;
|
||||
import com.onarandombox.MultiverseCore.configuration.migration.LongMigratorAction;
|
||||
import com.onarandombox.MultiverseCore.configuration.migration.MoveMigratorAction;
|
||||
import com.onarandombox.MultiverseCore.configuration.migration.NullStringMigratorAction;
|
||||
import com.onarandombox.MultiverseCore.configuration.migration.VersionMigrator;
|
||||
import com.onarandombox.MultiverseCore.world.configuration.AllowedPortalType;
|
||||
import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld;
|
||||
@ -59,38 +60,39 @@ public final class WorldConfig {
|
||||
.addAction(BooleanMigratorAction.of("auto-load"))
|
||||
.addAction(MoveMigratorAction.of("bedRespawn", "bed-respawn"))
|
||||
.addAction(BooleanMigratorAction.of("bed-respawn"))
|
||||
.addAction(MoveMigratorAction.of("difficulty", "difficulty"))
|
||||
//.addAction(MoveMigratorAction.of("difficulty", "difficulty"))
|
||||
.addAction(MoveMigratorAction.of("entryfee.amount", "entry-fee.amount"))
|
||||
.addAction(MoveMigratorAction.of("entryfee.currency", "entry-fee.currency"))
|
||||
.addAction(MoveMigratorAction.of("environment", "environment"))
|
||||
.addAction(MoveMigratorAction.of("gamemode", "gamemode"))
|
||||
.addAction(MoveMigratorAction.of("generator", "generator"))
|
||||
.addAction(MoveMigratorAction.of("hidden", "hidden"))
|
||||
//.addAction(MoveMigratorAction.of("environment", "environment"))
|
||||
.addAction(MoveMigratorAction.of("gameMode", "gamemode"))
|
||||
//.addAction(MoveMigratorAction.of("generator", "generator"))
|
||||
.addAction(NullStringMigratorAction.of("generator"))
|
||||
//.addAction(MoveMigratorAction.of("hidden", "hidden"))
|
||||
.addAction(BooleanMigratorAction.of("hidden"))
|
||||
.addAction(MoveMigratorAction.of("hunger", "hunger"))
|
||||
//.addAction(MoveMigratorAction.of("hunger", "hunger"))
|
||||
.addAction(BooleanMigratorAction.of("hunger"))
|
||||
.addAction(MoveMigratorAction.of("keepSpawnInMemory", "keep-spawn-in-memory"))
|
||||
.addAction(BooleanMigratorAction.of("keep-spawn-in-memory"))
|
||||
.addAction(MoveMigratorAction.of("playerLimit", "player-limit"))
|
||||
.addAction(IntegerMigratorAction.of("player-limit"))
|
||||
.addAction(MoveMigratorAction.of("portalForm", "portal-form"))
|
||||
.addAction(MoveMigratorAction.of("pvp", "pvp"))
|
||||
//.addAction(MoveMigratorAction.of("pvp", "pvp"))
|
||||
.addAction(BooleanMigratorAction.of("pvp"))
|
||||
.addAction(MoveMigratorAction.of("respawnWorld", "respawn-world"))
|
||||
.addAction(MoveMigratorAction.of("scale", "scale"))
|
||||
.addAction(MoveMigratorAction.of("seed", "seed"))
|
||||
//.addAction(MoveMigratorAction.of("scale", "scale"))
|
||||
//.addAction(MoveMigratorAction.of("seed", "seed"))
|
||||
.addAction(LongMigratorAction.of("seed"))
|
||||
.addAction(MoveMigratorAction.of("spawnLocation", "spawn-location"))
|
||||
.addAction(MoveMigratorAction.of("spawning.animals.spawn", "spawning.animals.spawn"))
|
||||
//.addAction(MoveMigratorAction.of("spawning.animals.spawn", "spawning.animals.spawn"))
|
||||
.addAction(BooleanMigratorAction.of("spawning.animals.spawn"))
|
||||
.addAction(MoveMigratorAction.of("spawning.animals.amount", "spawning.animals.tick-rate"))
|
||||
.addAction(IntegerMigratorAction.of("spawning.animals.tick-rate"))
|
||||
.addAction(MoveMigratorAction.of("spawning.animals.exceptions", "spawning.animals.exceptions"))
|
||||
.addAction(MoveMigratorAction.of("spawning.monsters.spawn", "spawning.monsters.spawn"))
|
||||
//.addAction(MoveMigratorAction.of("spawning.animals.exceptions", "spawning.animals.exceptions"))
|
||||
//.addAction(MoveMigratorAction.of("spawning.monsters.spawn", "spawning.monsters.spawn"))
|
||||
.addAction(BooleanMigratorAction.of("spawning.monsters.spawn"))
|
||||
.addAction(MoveMigratorAction.of("spawning.monsters.amount", "spawning.monsters.tick-rate"))
|
||||
.addAction(IntegerMigratorAction.of("spawning.monsters.tick-rate"))
|
||||
.addAction(MoveMigratorAction.of("spawning.monsters.exceptions", "spawning.monsters.exceptions"))
|
||||
//.addAction(MoveMigratorAction.of("spawning.monsters.exceptions", "spawning.monsters.exceptions"))
|
||||
.addAction(MoveMigratorAction.of("worldBlacklist", "world-blacklist"))
|
||||
.addAction(new LegacyAliasMigrator())
|
||||
.build();
|
||||
|
@ -2,6 +2,7 @@ package org.mvplugins.multiverse.core.world
|
||||
|
||||
import com.onarandombox.MultiverseCore.worldnew.config.SpawnLocation
|
||||
import com.onarandombox.MultiverseCore.worldnew.config.WorldsConfigManager
|
||||
import org.bukkit.World.Environment
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.mvplugins.multiverse.core.TestWithMockBukkit
|
||||
@ -39,7 +40,18 @@ class WorldConfigMangerTest : TestWithMockBukkit() {
|
||||
|
||||
assertTrue(worldConfigManager.load().isSuccess)
|
||||
assertTrue(worldConfigManager.save().isSuccess)
|
||||
//compareConfigFile("worlds2.yml", "/migrated_worlds.yml")
|
||||
|
||||
val endWorldConfig = worldConfigManager.getWorldConfig("world_the_end")
|
||||
assertNotNull(endWorldConfig)
|
||||
|
||||
assertEquals("&aworld the end", endWorldConfig.alias)
|
||||
assertEquals(Environment.THE_END, endWorldConfig.environment)
|
||||
|
||||
val worldConfig = worldConfigManager.getWorldConfig("world")
|
||||
assertNotNull(worldConfig)
|
||||
|
||||
assertEquals(-5176596003035866649, worldConfig.seed)
|
||||
assertEquals(listOf("test"), worldConfig.worldBlacklist)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -81,5 +81,5 @@ world:
|
||||
tick-rate: -1
|
||||
exceptions: []
|
||||
world-blacklist:
|
||||
- test
|
||||
- test
|
||||
version: 1.0
|
||||
|
Loading…
Reference in New Issue
Block a user