Skip to content

Instantly share code, notes, and snippets.

@sk89q sk89q/depend.yml Secret
Created Mar 15, 2013

What would you like to do?
name: MyPlugin
version: 1.0
depend: [WorldEdit]
import com.sk89q.worldedit.bukkit.*;
import com.sk89q.worldedit.bukkit.selections.*;
WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
Selection selection = worldEditPlugin.getSelection(player);
if (selection != null) {
World world = selection.getWorld();
Location min = selection.getMinimumPoint();
Location max = selection.getMaximumPoint();
// Do something with min/max
} else {
// No selection available
import com.sk89q.worldedit.BlockVector2D; // Required for polygon points
if (selection instanceof CuboidSelection) { // Is it a cuboid?
CuboidSelection cuboid = (CuboidSelection) selection;
} else if (selection instanceof Polygonal2DSelection) { // Is it a polygon?
Polygonal2DSelection polygon = (Polygonal2DSelection) selection;
List<BlockVector2D> points = getNativePoints();
// Points are BlockVector2Ds, which are immutable
// (you can't change their X, Y, Z without getting a new object)
for (BlockVector2D point : points) {
double x = point.getX();
double z = point.getZ();
// Or as an int
getBlockX(), getBlockZ()
} else {
// It's a different shape
name: MyPlugin
version: 1.0
softdepend: [WorldEdit]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.