Fix WorldEditPlugin assuming that worlds are an instance of BukkitWorld.

Fixes WORLDEDIT-3168.
Dieser Commit ist enthalten in:
sk89q 2014-07-25 17:29:36 -07:00
Ursprung 5dd7b83940
Commit e93c9c9736
3 geänderte Dateien mit 24 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -35,6 +35,27 @@ final class BukkitAdapter {
private BukkitAdapter() {
}
/**
* Convert any WorldEdit world into an equivalent wrapped Bukkit world.
*
* <p>If a matching world cannot be found, a {@link RuntimeException}
* will be thrown.</p>
*
* @param world the world
* @return a wrapped Bukkit world
*/
public static BukkitWorld asBukkitWorld(World world) {
if (world instanceof BukkitWorld) {
return (BukkitWorld) world;
} else {
BukkitWorld bukkitWorld = WorldEditPlugin.getInstance().getInternalPlatform().matchWorld(world);
if (bukkitWorld == null) {
throw new RuntimeException("World '" + world.getName() + "' has no matching version in Bukkit");
}
return bukkitWorld;
}
}
/**
* Create a WorldEdit world from a Bukkit world.
*

Datei anzeigen

@ -110,9 +110,9 @@ public class BukkitServerInterface extends ServerInterface implements MultiUserP
@Nullable
@Override
public com.sk89q.worldedit.world.World matchWorld(com.sk89q.worldedit.world.World world) {
public BukkitWorld matchWorld(com.sk89q.worldedit.world.World world) {
if (world instanceof BukkitWorld) {
return world;
return (BukkitWorld) world;
} else {
World bukkitWorld = server.getWorld(world.getName());
return bukkitWorld != null ? new BukkitWorld(bukkitWorld) : null;

Datei anzeigen

@ -412,7 +412,7 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
try {
Region region = selector.getRegion();
World world = ((BukkitWorld) session.getSelectionWorld()).getWorld();
World world = BukkitAdapter.asBukkitWorld(session.getSelectionWorld()).getWorld();
if (region instanceof CuboidRegion) {
return new CuboidSelection(world, selector, (CuboidRegion) region);