WorldEdit restored to soft dependency instead of dependency

This commit is contained in:
Ammar Askar
2013-01-12 16:02:33 +05:00
parent 83de6fc329
commit 5d0c3216c2
6 changed files with 100 additions and 64 deletions
@@ -0,0 +1,41 @@
package de.diddiz.worldedit;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
import com.sk89q.worldedit.bukkit.selections.Selection;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class RegionContainer {
private Selection selection;
public RegionContainer(Selection sel) {
this.selection = sel;
}
public static RegionContainer fromPlayerSelection(Player player, Plugin plugin) {
final Selection selection = ((WorldEditPlugin) plugin).getSelection(player);
if (selection == null) {
throw new IllegalArgumentException("No selection defined");
}
if (!(selection instanceof CuboidSelection)) {
throw new IllegalArgumentException("You have to define a cuboid selection");
}
return new RegionContainer(selection);
}
public static RegionContainer fromCorners(World world, Location first, Location second) {
return new RegionContainer(new CuboidSelection(world, first, second));
}
public Selection getSelection() {
return selection;
}
public void setSelection(Selection selection) {
this.selection = selection;
}
}