From da6e6da024e7b501c16e6adfdd33ba53fd9cbddf Mon Sep 17 00:00:00 2001 From: Wizjany Date: Wed, 24 Aug 2011 18:27:18 -0400 Subject: [PATCH] Cleanup. Added toString override for polygonal regions. --- .../java/com/sk89q/worldedit/EditSession.java | 3 ++- .../java/com/sk89q/worldedit/WorldEdit.java | 3 ++- .../worldedit/bukkit/WorldEditPlugin.java | 24 +++++++------------ .../sk89q/worldedit/regions/CuboidRegion.java | 5 ++-- .../worldedit/regions/Polygonal2DRegion.java | 21 +++++++++++++++- 5 files changed, 36 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/EditSession.java b/src/main/java/com/sk89q/worldedit/EditSession.java index 4e2bca007..1f7be6319 100644 --- a/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/src/main/java/com/sk89q/worldedit/EditSession.java @@ -1162,7 +1162,8 @@ public class EditSession { return affected; } - /** + + /** * Make faces of the region (as if it was a cuboid if it's not). * * @param region diff --git a/src/main/java/com/sk89q/worldedit/WorldEdit.java b/src/main/java/com/sk89q/worldedit/WorldEdit.java index 31cac1724..445cb981d 100644 --- a/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -118,7 +118,8 @@ public class WorldEdit { else logMode = loggingAnnotation.value(); - String msg = "WorldEdit: " + player.getName() + ": " + StringUtil.joinString(args, " "); + String msg = "WorldEdit: " + player.getName() + "(in " + player.getWorld().getName() + ")" + + ": " + StringUtil.joinString(args, " "); if (logMode != null) { Vector position = player.getPosition(); final LocalSession session = getSession(player); diff --git a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 4b8579a22..bd556feee 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -32,7 +32,6 @@ import org.bukkit.event.Event.Priority; import org.bukkit.event.Event; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerListener; -import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import com.sk89q.bukkit.migration.PermissionsResolverManager; import com.sk89q.bukkit.migration.PermissionsResolverServerListener; @@ -135,16 +134,14 @@ public class WorldEditPlugin extends JavaPlugin { /** * Register the events used by WorldEdit. */ - protected void registerEvents() { - @SuppressWarnings("unused") + protected void registerEvents() { PlayerListener playerListener = new WorldEditPlayerListener(this); - @SuppressWarnings("unused") PlayerListener criticalPlayerListener = new WorldEditCriticalPlayerListener(this); - + // The permissions resolver has some hooks of its own (new PermissionsResolverServerListener(perms)).register(this); } - + /** * Register an event. * @@ -152,28 +149,25 @@ public class WorldEditPlugin extends JavaPlugin { * @param listener * @param priority */ - protected void registerEvent(String typeName, Listener listener, Priority priority) { + public void registerEvent(String typeName, Listener listener, Priority priority) { try { Event.Type type = Event.Type.valueOf(typeName); - PluginManager pm = getServer().getPluginManager(); - pm.registerEvent(type, listener, priority, this); + this.getServer().getPluginManager().registerEvent(type, listener, priority, this); } catch (IllegalArgumentException e) { - logger.info("WorldGuard: Unable to register missing event type " + typeName); + logger.info("WorldEdit: Unable to register missing event type " + typeName); } - /*getServer().getPluginManager() - .registerEvent(type, listener, priority, this);*/ } - + /** * Register an event at normal priority. * * @param type * @param listener */ - protected void registerEvent(String typeName, Listener listener) { + public void registerEvent(String typeName, Listener listener) { registerEvent(typeName, listener, Event.Priority.Normal); } - + /** * Create a default configuration file from the .jar. * diff --git a/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 4fb5adb2b..b2364689d 100644 --- a/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -344,12 +344,13 @@ public class CuboidRegion implements Region { } /** - * Returns string representation "( (x, y, z) - (x, y, z) )". + * Returns string representation in the format + * "(minX, minY, minZ) - (maxX, maxY, maxZ)". * * @return string */ @Override public String toString() { - return "( "+getMinimumPoint()+" - "+getMaximumPoint()+" )"; + return getMinimumPoint() + " - " + getMaximumPoint(); } } diff --git a/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java b/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java index ab1b0527a..3c5656d90 100644 --- a/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java +++ b/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java @@ -464,7 +464,26 @@ public class Polygonal2DRegion implements Region { return items.iterator();*/ } - + + /** + * Returns string representation in the format + * "(x1, z1) - ... - (xN, zN) * (minY - maxY)" + * + * @return string + */ + public String toString() { + StringBuilder sb = new StringBuilder(); + List pts = getPoints(); + Iterator it = pts.iterator(); + while (it.hasNext()) { + BlockVector2D current = it.next(); + sb.append("(" + current.getBlockX() + ", " + current.getBlockZ() + ")"); + if (it.hasNext()) sb.append(" - "); + } + sb.append(" * (" + minY + " - " + maxY + ")"); + return sb.toString(); + } + /** * A terrible polygonal region iterator. */