Fix spawn location in world config should use SpawnLocation class not bukkit Location

This commit is contained in:
Ben Woo 2025-01-04 10:21:47 +08:00
parent 17bb856242
commit 5259f6a503
3 changed files with 16 additions and 4 deletions

View File

@ -14,6 +14,7 @@ import org.jetbrains.annotations.Nullable;
import org.mvplugins.multiverse.core.configuration.handle.StringPropertyHandle;
import org.mvplugins.multiverse.core.world.config.AllowedPortalType;
import org.mvplugins.multiverse.core.world.config.SpawnLocation;
import org.mvplugins.multiverse.core.world.config.WorldConfig;
/**
@ -533,7 +534,7 @@ public class MultiverseWorld {
*
* @return The spawn location of this world.
*/
public Location getSpawnLocation() {
public SpawnLocation getSpawnLocation() {
return worldConfig.getSpawnLocation();
}
@ -544,6 +545,17 @@ public class MultiverseWorld {
* @return Result of setting property.
*/
public Try<Void> setSpawnLocation(Location spawnLocation) {
return setSpawnLocation(new SpawnLocation(spawnLocation));
}
/**
* Sets the spawn location for a world.
*
* @param spawnLocation The spawn location for a world.
* @return Result of setting property.
*/
public Try<Void> setSpawnLocation(SpawnLocation spawnLocation) {
//todo: Maybe check of safe location if adjust spawn is enabled
return worldConfig.setSpawnLocation(spawnLocation);
}

View File

@ -301,11 +301,11 @@ public final class WorldConfig {
return configHandle.set(configNodes.SEED, seed);
}
public Location getSpawnLocation() {
public SpawnLocation getSpawnLocation() {
return configHandle.get(configNodes.SPAWN_LOCATION);
}
public Try<Void> setSpawnLocation(Location spawnLocation) {
public Try<Void> setSpawnLocation(SpawnLocation spawnLocation) {
return configHandle.set(configNodes.SPAWN_LOCATION, spawnLocation);
}

View File

@ -186,7 +186,7 @@ public class WorldConfigNodes {
.name(null)
.build());
final ConfigNode<Location> SPAWN_LOCATION = node(ConfigNode.builder("spawn-location", Location.class)
final ConfigNode<SpawnLocation> SPAWN_LOCATION = node(ConfigNode.builder("spawn-location", SpawnLocation.class)
.defaultValue(NullLocation.get())
.name(null)
.onSetValue((oldValue, newValue) -> {