From cd54bb6f0906d46e021d8fc0f66a231a3585ad55 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sat, 26 Mar 2011 19:26:40 -0700 Subject: [PATCH] Added native data getter methods to Bukkit selection API. --- .../bukkit/selections/Polygonal2DSelection.java | 6 ++++++ .../bukkit/selections/RegionSelection.java | 11 +++++++++++ .../worldedit/bukkit/selections/Selection.java | 15 +++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/src/com/sk89q/worldedit/bukkit/selections/Polygonal2DSelection.java b/src/com/sk89q/worldedit/bukkit/selections/Polygonal2DSelection.java index 08dc89553..817b59850 100644 --- a/src/com/sk89q/worldedit/bukkit/selections/Polygonal2DSelection.java +++ b/src/com/sk89q/worldedit/bukkit/selections/Polygonal2DSelection.java @@ -19,7 +19,9 @@ package com.sk89q.worldedit.bukkit.selections; +import java.util.List; import org.bukkit.World; +import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldedit.regions.*; public class Polygonal2DSelection extends RegionSelection { @@ -31,4 +33,8 @@ public class Polygonal2DSelection extends RegionSelection { this.world = world; this.poly2d = region; } + + public List getNativePoints() { + return poly2d.getPoints(); + } } diff --git a/src/com/sk89q/worldedit/bukkit/selections/RegionSelection.java b/src/com/sk89q/worldedit/bukkit/selections/RegionSelection.java index 78c95cbe3..a26916db1 100644 --- a/src/com/sk89q/worldedit/bukkit/selections/RegionSelection.java +++ b/src/com/sk89q/worldedit/bukkit/selections/RegionSelection.java @@ -23,6 +23,7 @@ import static com.sk89q.worldedit.bukkit.BukkitUtil.toLocation; import static com.sk89q.worldedit.bukkit.BukkitUtil.toVector; import org.bukkit.Location; import org.bukkit.World; +import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.regions.Region; public abstract class RegionSelection implements Selection { @@ -40,11 +41,21 @@ public abstract class RegionSelection implements Selection { return toLocation(world, region.getMinimumPoint()); } + @Override + public Vector getNativeMinimumPoint() { + return region.getMinimumPoint(); + } + @Override public Location getMaximumPoint() { return toLocation(world, region.getMaximumPoint()); } + @Override + public Vector getNativeMaximumPoint() { + return region.getMaximumPoint(); + } + @Override public World getWorld() { return world; diff --git a/src/com/sk89q/worldedit/bukkit/selections/Selection.java b/src/com/sk89q/worldedit/bukkit/selections/Selection.java index 47a4264b1..2b9ac6460 100644 --- a/src/com/sk89q/worldedit/bukkit/selections/Selection.java +++ b/src/com/sk89q/worldedit/bukkit/selections/Selection.java @@ -21,6 +21,7 @@ package com.sk89q.worldedit.bukkit.selections; import org.bukkit.Location; import org.bukkit.World; +import com.sk89q.worldedit.Vector; public interface Selection { /** @@ -30,6 +31,13 @@ public interface Selection { */ public Location getMinimumPoint(); + /** + * Get the lower point of a region. + * + * @return min. point + */ + public Vector getNativeMinimumPoint(); + /** * Get the upper point of a region. * @@ -37,6 +45,13 @@ public interface Selection { */ public Location getMaximumPoint(); + /** + * Get the upper point of a region. + * + * @return max. point + */ + public Vector getNativeMaximumPoint(); + /** * Get the world. *