28 lines
934 B
Java
28 lines
934 B
Java
package games.dmg.fantasystick.adventure;
|
|
|
|
import java.util.Objects;
|
|
import java.util.UUID;
|
|
import org.bukkit.Server;
|
|
import org.bukkit.World;
|
|
|
|
/** Readable presentation for authoritative UUID-backed adventure locations. */
|
|
public final class AdventureLocationPresentation {
|
|
private final Server server;
|
|
|
|
public AdventureLocationPresentation(Server server) {
|
|
this.server = Objects.requireNonNull(server);
|
|
}
|
|
|
|
public String format(UUID worldId, double x, double y, double z) {
|
|
Objects.requireNonNull(worldId);
|
|
World world = server.getWorld(worldId);
|
|
String worldName = world == null || world.getName() == null || world.getName().isBlank()
|
|
? "unavailable world" : world.getName();
|
|
return worldName + " (" + block(x) + ", " + block(y) + ", " + block(z) + ")";
|
|
}
|
|
|
|
private static int block(double coordinate) {
|
|
return (int) Math.floor(coordinate);
|
|
}
|
|
}
|