// $Id$ /* * WorldEdit * Copyright (C) 2010 sk89q * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package com.sk89q.worldedit.bukkit; import java.util.List; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.World; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.Vector; public class BukkitUtil { private BukkitUtil() { } public static Location toLocation(World world, Vector loc) { return new Location(world, loc.getX(), loc.getY(), loc.getZ()); } public static BlockVector toVector(Block block) { return new BlockVector(block.getX(), block.getY(), block.getZ()); } public static Vector toVector(Location loc) { return new Vector(loc.getX(), loc.getY(), loc.getZ()); } public static Vector toVector(org.bukkit.util.Vector vector) { return new Vector(vector.getX(), vector.getY(), vector.getZ()); } public static Player matchSinglePlayer(Server server, String name) { List players = server.matchPlayer(name); if (players.size() == 0) { return null; } return players.get(0); } }