2013-01-12 16:00:22 +05:00
|
|
|
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 {
|
|
|
|
|
|
2015-03-22 20:15:04 +05:00
|
|
|
private Selection selection;
|
2013-01-12 16:00:22 +05:00
|
|
|
|
2015-03-22 20:15:04 +05:00
|
|
|
public RegionContainer(Selection sel) {
|
|
|
|
|
this.selection = sel;
|
|
|
|
|
}
|
2013-01-12 16:00:22 +05:00
|
|
|
|
2015-03-22 20:15:04 +05:00
|
|
|
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);
|
|
|
|
|
}
|
2013-01-12 16:00:22 +05:00
|
|
|
|
2015-03-22 20:15:04 +05:00
|
|
|
public static RegionContainer fromCorners(World world, Location first, Location second) {
|
|
|
|
|
return new RegionContainer(new CuboidSelection(world, first, second));
|
|
|
|
|
}
|
2013-01-12 16:00:22 +05:00
|
|
|
|
2015-03-22 20:15:04 +05:00
|
|
|
public Selection getSelection() {
|
|
|
|
|
return selection;
|
|
|
|
|
}
|
2013-01-12 16:00:22 +05:00
|
|
|
|
2015-03-22 20:15:04 +05:00
|
|
|
public void setSelection(Selection selection) {
|
|
|
|
|
this.selection = selection;
|
|
|
|
|
}
|
2013-01-12 16:00:22 +05:00
|
|
|
}
|