-
-
Save sk89q/1d534a463206bc7d9cbf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: MyPlugin | |
version: 1.0 | |
depend: [WorldEdit] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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