Files
LogBlock/src/main/java/de/diddiz/worldedit/RegionContainer.java
T

42 lines
1.3 KiB
Java
Raw Normal View History

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;
2015-03-22 20:15:04 +05:00
public RegionContainer(Selection sel) {
this.selection = sel;
}
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);
}
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));
}
2015-03-22 20:15:04 +05:00
public Selection getSelection() {
return selection;
}
2015-03-22 20:15:04 +05:00
public void setSelection(Selection selection) {
this.selection = selection;
}
}