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;
}
/**
/**
* Make faces of the region (as if it was a cuboid if it's not).
*
* @param region

View File

@ -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);

View File

@ -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.
*

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

View File

@ -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<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.
*/