Skip to content

Instantly share code, notes, and snippets.

@sk89q

sk89q/depend.yml Secret

Created March 15, 2013 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sk89q/1d534a463206bc7d9cbf to your computer and use it in GitHub Desktop.
Save sk89q/1d534a463206bc7d9cbf to your computer and use it in GitHub Desktop.
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