blob: 940d706a325caa3560b4f287157fa417acc16182 [file] [log] [blame] [raw]
/* Copyright 2015-2020 Rivoreo
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package rivoreo.minecraft.worldmgr;
import org.bukkit.Location;
import org.bukkit.World;
public class BukkitWorldSpawnPointProperty implements BukkitWorldProperty {
public String get(World world) throws Exception {
Location location = world.getSpawnLocation();
return String.format("%d,%d,%d", location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
public void set(World world, String value) throws Exception {
int[] spawn_point = BukkitPlugin.parse_coordinate(value, 3);
if(spawn_point == null) throw new IllegalArgumentException("Invalid coordinate");
world.setSpawnLocation(spawn_point[0], spawn_point[1], spawn_point[2]);
}
}