Cleanup. Added toString override for polygonal regions.

This commit is contained in:
Wizjany 2011-08-24 18:27:18 -04:00
parent 26d07b4ca4
commit da6e6da024
5 changed files with 36 additions and 20 deletions

View File

@ -1162,7 +1162,8 @@ public class EditSession {
return affected; return affected;
} }
/**
/**
* Make faces of the region (as if it was a cuboid if it's not). * Make faces of the region (as if it was a cuboid if it's not).
* *
* @param region * @param region

View File

@ -118,7 +118,8 @@ public class WorldEdit {
else else
logMode = loggingAnnotation.value(); 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) { if (logMode != null) {
Vector position = player.getPosition(); Vector position = player.getPosition();
final LocalSession session = getSession(player); final LocalSession session = getSession(player);

View File

@ -32,7 +32,6 @@ import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerListener;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.sk89q.bukkit.migration.PermissionsResolverManager; import com.sk89q.bukkit.migration.PermissionsResolverManager;
import com.sk89q.bukkit.migration.PermissionsResolverServerListener; import com.sk89q.bukkit.migration.PermissionsResolverServerListener;
@ -136,9 +135,7 @@ public class WorldEditPlugin extends JavaPlugin {
* Register the events used by WorldEdit. * Register the events used by WorldEdit.
*/ */
protected void registerEvents() { protected void registerEvents() {
@SuppressWarnings("unused")
PlayerListener playerListener = new WorldEditPlayerListener(this); PlayerListener playerListener = new WorldEditPlayerListener(this);
@SuppressWarnings("unused")
PlayerListener criticalPlayerListener = new WorldEditCriticalPlayerListener(this); PlayerListener criticalPlayerListener = new WorldEditCriticalPlayerListener(this);
// The permissions resolver has some hooks of its own // The permissions resolver has some hooks of its own
@ -152,16 +149,13 @@ public class WorldEditPlugin extends JavaPlugin {
* @param listener * @param listener
* @param priority * @param priority
*/ */
protected void registerEvent(String typeName, Listener listener, Priority priority) { public void registerEvent(String typeName, Listener listener, Priority priority) {
try { try {
Event.Type type = Event.Type.valueOf(typeName); Event.Type type = Event.Type.valueOf(typeName);
PluginManager pm = getServer().getPluginManager(); this.getServer().getPluginManager().registerEvent(type, listener, priority, this);
pm.registerEvent(type, listener, priority, this);
} catch (IllegalArgumentException e) { } 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);*/
} }
/** /**
@ -170,7 +164,7 @@ public class WorldEditPlugin extends JavaPlugin {
* @param type * @param type
* @param listener * @param listener
*/ */
protected void registerEvent(String typeName, Listener listener) { public void registerEvent(String typeName, Listener listener) {
registerEvent(typeName, listener, Event.Priority.Normal); registerEvent(typeName, listener, Event.Priority.Normal);
} }

View File

@ -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 * @return string
*/ */
@Override @Override
public String toString() { public String toString() {
return "( "+getMinimumPoint()+" - "+getMaximumPoint()+" )"; return getMinimumPoint() + " - " + getMaximumPoint();
} }
} }

View File

@ -465,6 +465,25 @@ public class Polygonal2DRegion implements Region {
return items.iterator();*/ 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<BlockVector2D> pts = getPoints();
Iterator<BlockVector2D> 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. * A terrible polygonal region iterator.
*/ */