Cleaned up javadoc, deprecated duplicate methods, other cleanup

This commit is contained in:
zml2008 2012-02-20 15:14:55 -08:00
parent 6b4f872742
commit 6f4a62c7a3
52 changed files with 601 additions and 916 deletions

View File

@ -25,58 +25,58 @@ public abstract class LocalPlayer {
/** /**
* Get a player's name. * Get a player's name.
* *
* @return * @return The player's name
*/ */
public abstract String getName(); public abstract String getName();
/** /**
* Returns true if the player is inside a group. * Returns true if the player is inside a group.
* *
* @param group * @param group The group to check
* @return * @return Whether this player is in {@code group}
*/ */
public abstract boolean hasGroup(String group); public abstract boolean hasGroup(String group);
/** /**
* Get the player's position. * Get the player's position.
* *
* @return * @return The player's position
*/ */
public abstract Vector getPosition(); public abstract Vector getPosition();
/** /**
* Kick the player. * Kick the player.
* *
* @param msg * @param msg The message to kick the player with
*/ */
public abstract void kick(String msg); public abstract void kick(String msg);
/** /**
* Ban the player. * Ban the player.
* *
* @param msg * @param msg The message to ban the player with
*/ */
public abstract void ban(String msg); public abstract void ban(String msg);
/** /**
* Send the player a message; * Send the player a message;
* *
* @param msg * @param msg The message to send to the player
*/ */
public abstract void printRaw(String msg); public abstract void printRaw(String msg);
/** /**
* Get the player's list of groups. * Get the player's list of groups.
* *
* @return * @return The groups this player is in
*/ */
public abstract String[] getGroups(); public abstract String[] getGroups();
/** /**
* Returns whether a player has permission. * Returns whether a player has permission.
* *
* @param perm * @param perm The permission to check
* @return * @return Whether this player has {@code perm}
*/ */
public abstract boolean hasPermission(String perm); public abstract boolean hasPermission(String perm);

View File

@ -73,7 +73,7 @@ public Blacklist(Boolean useAsWhitelist, Logger logger) {
/** /**
* Returns whether the list is empty. * Returns whether the list is empty.
* *
* @return * @return whether the blacklist is empty
*/ */
public boolean isEmpty() { public boolean isEmpty() {
return blacklist.isEmpty(); return blacklist.isEmpty();
@ -82,8 +82,8 @@ public boolean isEmpty() {
/** /**
* Get the entries for an item or list. * Get the entries for an item or list.
* *
* @param id * @param id The item id to get blacklist information for
* @return * @return The blacklist entries for {@code id}
*/ */
public List<BlacklistEntry> getEntries(int id) { public List<BlacklistEntry> getEntries(int id) {
return blacklist.get(id); return blacklist.get(id);
@ -92,7 +92,7 @@ public List<BlacklistEntry> getEntries(int id) {
/** /**
* Get the number of individual items that have blacklist entries. * Get the number of individual items that have blacklist entries.
* *
* @return * @return The number of items in the blacklist
*/ */
public int getItemCount() { public int getItemCount() {
return blacklist.size(); return blacklist.size();
@ -101,7 +101,7 @@ public int getItemCount() {
/** /**
* Returns whether the blacklist is used as a whitelist. * Returns whether the blacklist is used as a whitelist.
* *
* @return * @return whether the blacklist is be used as a whitelist
*/ */
public boolean isWhitelist() { public boolean isWhitelist() {
return useAsWhitelist; return useAsWhitelist;
@ -110,7 +110,7 @@ public boolean isWhitelist() {
/** /**
* Get the logger. * Get the logger.
* *
* @return * @return The logger used in this blacklist
*/ */
public BlacklistLogger getLogger() { public BlacklistLogger getLogger() {
return blacklistLogger; return blacklistLogger;
@ -119,10 +119,10 @@ public BlacklistLogger getLogger() {
/** /**
* Method to handle the event. * Method to handle the event.
* *
* @param event * @param event The event to check
* @param forceRepeat * @param forceRepeat Whether to force quickly repeating notifications
* @param silent * @param silent Whether to force-deny notifications
* @return * @return Whether the event is allowed
*/ */
public boolean check(BlacklistEvent event, boolean forceRepeat, boolean silent) { public boolean check(BlacklistEvent event, boolean forceRepeat, boolean silent) {
List<BlacklistEntry> entries = getEntries(event.getType()); List<BlacklistEntry> entries = getEntries(event.getType());
@ -141,8 +141,8 @@ public boolean check(BlacklistEvent event, boolean forceRepeat, boolean silent)
/** /**
* Load the blacklist. * Load the blacklist.
* *
* @param file * @param file The file to load from
* @throws IOException * @throws IOException if an error occurred reading from the file
*/ */
public void load(File file) throws IOException { public void load(File file) throws IOException {
FileReader input = null; FileReader input = null;
@ -170,7 +170,7 @@ public void load(File file) throws IOException {
currentEntries = new ArrayList<BlacklistEntry>(); currentEntries = new ArrayList<BlacklistEntry>();
for (String item : items) { for (String item : items) {
int id = 0; int id;
try { try {
id = Integer.parseInt(item.trim()); id = Integer.parseInt(item.trim());
@ -248,7 +248,7 @@ public void load(File file) throws IOException {
if (input != null) { if (input != null) {
input.close(); input.close();
} }
} catch (IOException e2) { } catch (IOException ignore) {
} }
} }
} }
@ -256,7 +256,7 @@ public void load(File file) throws IOException {
/** /**
* Get the last event. * Get the last event.
* *
* @return * @return The last event
*/ */
public BlacklistEvent getLastEvent() { public BlacklistEvent getLastEvent() {
return lastEvent; return lastEvent;
@ -265,8 +265,8 @@ public BlacklistEvent getLastEvent() {
/** /**
* Notify administrators. * Notify administrators.
* *
* @param event * @param event The event to notify about
* @param comment * @param comment The comment to notify with
*/ */
public void notify(BlacklistEvent event, String comment) { public void notify(BlacklistEvent event, String comment) {
lastEvent = event; lastEvent = event;
@ -282,14 +282,14 @@ public void notify(BlacklistEvent event, String comment) {
/** /**
* Sends a notification to all subscribing users. * Sends a notification to all subscribing users.
* *
* @param msg * @param msg The message to broadcast
*/ */
public abstract void broadcastNotification(String msg); public abstract void broadcastNotification(String msg);
/** /**
* Forget a player. * Forget a player.
* *
* @param player * @param player The player to forget
*/ */
public void forgetPlayer(LocalPlayer player) { public void forgetPlayer(LocalPlayer player) {
lastAffected.remove(player.getName()); lastAffected.remove(player.getName());
@ -305,7 +305,8 @@ public void forgetAllPlayers() {
/** /**
* Get an item's ID from its name. * Get an item's ID from its name.
* *
* @param name * @param name the name of the item to look up
* @return the id for name if contained in ItemId, else -1
*/ */
private static int getItemID(String name) { private static int getItemID(String name) {
ItemType type = ItemType.lookup(name); ItemType type = ItemType.lookup(name);
@ -319,7 +320,8 @@ private static int getItemID(String name) {
/** /**
* Get an item's friendly name with its ID. * Get an item's friendly name with its ID.
* *
* @param id * @param id The id to look up
* @return The item's friendly name
*/ */
private static String getFriendlyItemName(int id) { private static String getFriendlyItemName(int id) {
ItemType type = ItemType.fromID(id); ItemType type = ItemType.fromID(id);

View File

@ -69,7 +69,7 @@ public class BlacklistEntry {
/** /**
* Construct the object. * Construct the object.
* *
* @param blacklist * @param blacklist The blacklist that contains this entry
*/ */
public BlacklistEntry(Blacklist blacklist) { public BlacklistEntry(Blacklist blacklist) {
this.blacklist = blacklist; this.blacklist = blacklist;
@ -112,98 +112,98 @@ public void setIgnorePermissions(String[] ignorePermissions) {
} }
/** /**
* @return * @return The actions that occur when breaking
*/ */
public String[] getBreakActions() { public String[] getBreakActions() {
return breakActions; return breakActions;
} }
/** /**
* @param actions * @param actions The actions to occur when breaking
*/ */
public void setBreakActions(String[] actions) { public void setBreakActions(String[] actions) {
this.breakActions = actions; this.breakActions = actions;
} }
/** /**
* @return * @return The actions that occur when destroying with a specific item
*/ */
public String[] getDestroyWithActions() { public String[] getDestroyWithActions() {
return destroyWithActions; return destroyWithActions;
} }
/** /**
* @param actions * @param actions The actions to occur when destroying with an item
*/ */
public void setDestroyWithActions(String[] actions) { public void setDestroyWithActions(String[] actions) {
this.destroyWithActions = actions; this.destroyWithActions = actions;
} }
/** /**
* @return * @return The actions that will occur when placing
*/ */
public String[] getPlaceActions() { public String[] getPlaceActions() {
return placeActions; return placeActions;
} }
/** /**
* @param actions * @param actions The actions to occur when placing
*/ */
public void setPlaceActions(String[] actions) { public void setPlaceActions(String[] actions) {
this.placeActions = actions; this.placeActions = actions;
} }
/** /**
* @return * @return The actions that will occur when interacting
*/ */
public String[] getInteractActions() { public String[] getInteractActions() {
return interactActions; return interactActions;
} }
/** /**
* @param actions * @param actions The actions to occur when interacting
*/ */
public void setInteractActions(String[] actions) { public void setInteractActions(String[] actions) {
this.interactActions = actions; this.interactActions = actions;
} }
/** /**
* @return * @return The actions that will occur when using
*/ */
public String[] getUseActions() { public String[] getUseActions() {
return useActions; return useActions;
} }
/** /**
* @param actions * @param actions The actions to occur when using
*/ */
public void setUseActions(String[] actions) { public void setUseActions(String[] actions) {
this.useActions = actions; this.useActions = actions;
} }
/** /**
* @return * @return The actions that will occur when dropping
*/ */
public String[] getDropActions() { public String[] getDropActions() {
return dropActions; return dropActions;
} }
/** /**
* @param actions * @param actions The actions to occur when dropping
*/ */
public void setDropActions(String[] actions) { public void setDropActions(String[] actions) {
this.dropActions = actions; this.dropActions = actions;
} }
/** /**
* @return * @return The actions that will occur when acquiring
*/ */
public String[] getAcquireActions() { public String[] getAcquireActions() {
return acquireActions; return acquireActions;
} }
/** /**
* @param actions * @param actions The actions to occur when acquiring
*/ */
public void setAcquireActions(String[] actions) { public void setAcquireActions(String[] actions) {
this.acquireActions = actions; this.acquireActions = actions;
@ -240,8 +240,8 @@ public void setComment(String comment) {
/** /**
* Returns true if this player should be ignored. * Returns true if this player should be ignored.
* *
* @param player * @param player The player to check
* @return * @return whether this player should be ignored for blacklist blocking
*/ */
public boolean shouldIgnore(LocalPlayer player) { public boolean shouldIgnore(LocalPlayer player) {
if (ignoreGroups != null) { if (ignoreGroups != null) {
@ -266,8 +266,8 @@ public boolean shouldIgnore(LocalPlayer player) {
/** /**
* Get the associated actions with an event. * Get the associated actions with an event.
* *
* @param event * @param event The event to check
* @return * @return The actions for the given event
*/ */
private String[] getActions(BlacklistEvent event) { private String[] getActions(BlacklistEvent event) {
if (event instanceof BlockBreakBlacklistEvent) { if (event instanceof BlockBreakBlacklistEvent) {
@ -299,11 +299,11 @@ private String[] getActions(BlacklistEvent event) {
/** /**
* Method to handle the event. * Method to handle the event.
* *
* @param useAsWhitelist * @param useAsWhitelist Whether this entry is buing used in a whitelist
* @param event * @param event The event to check
* @param forceRepeat * @param forceRepeat Whether to force repeating notifications even within the delay limit
* @param silent * @param silent Whether to prevent notifications from happening
* @return * @return Whether the action was allowed
*/ */
public boolean check(boolean useAsWhitelist, BlacklistEvent event, boolean forceRepeat, boolean silent) { public boolean check(boolean useAsWhitelist, BlacklistEvent event, boolean forceRepeat, boolean silent) {
LocalPlayer player = event.getPlayer(); LocalPlayer player = event.getPlayer();
@ -329,11 +329,11 @@ public boolean check(boolean useAsWhitelist, BlacklistEvent event, boolean force
String actions[] = getActions(event); String actions[] = getActions(event);
boolean ret = useAsWhitelist ? false : true; boolean ret = !useAsWhitelist;
// Nothing to do // Nothing to do
if (actions == null) { if (actions == null) {
return useAsWhitelist ? false : true; return ret;
} }
for (String action : actions) { for (String action : actions) {
@ -412,7 +412,7 @@ public boolean check(boolean useAsWhitelist, BlacklistEvent event, boolean force
/** /**
* Get an item's friendly name with its ID. * Get an item's friendly name with its ID.
* *
* @param id * @param id The id to get a name for
*/ */
private static String getFriendlyItemName(int id) { private static String getFriendlyItemName(int id) {
ItemType type = ItemType.fromID(id); ItemType type = ItemType.fromID(id);

View File

@ -39,16 +39,16 @@ public class BlacklistLogger implements BlacklistLoggerHandler {
/** /**
* Add a handler. * Add a handler.
* *
* @param handler * @param handler The handler to add
*/ */
public void addHandler(BlacklistLoggerHandler handler) { public void addHandler(BlacklistLoggerHandler handler) {
handlers.add(handler); handlers.add(handler);
} }
/** /**
* Add a handler. * Remove a handler.
* *
* @param handler * @param handler The handler to remove
*/ */
public void removeHandler(BlacklistLoggerHandler handler) { public void removeHandler(BlacklistLoggerHandler handler) {
handlers.remove(handler); handlers.remove(handler);
@ -64,7 +64,7 @@ public void clearHandlers() {
/** /**
* Log an event. * Log an event.
* *
* @param event * @param event The event to log
*/ */
public void logEvent(BlacklistEvent event, String comment) { public void logEvent(BlacklistEvent event, String comment) {
for (BlacklistLoggerHandler handler : handlers) { for (BlacklistLoggerHandler handler : handlers) {

View File

@ -32,8 +32,8 @@ public class BlacklistTrackedEvent {
/** /**
* Construct the object. * Construct the object.
* *
* @param event * @param event The event tracked
* @param time * @param time The time at which the event occurred
*/ */
public BlacklistTrackedEvent(BlacklistEvent event, long time) { public BlacklistTrackedEvent(BlacklistEvent event, long time) {
this.event = event; this.event = event;

View File

@ -39,9 +39,9 @@ public abstract class BlacklistEvent {
/** /**
* Construct the object. * Construct the object.
* *
* @param player * @param player The player associated with this event
* @param pos * @param pos The position the event occurred at
* @param type * @param type The type of item used
*/ */
public BlacklistEvent(LocalPlayer player, Vector pos, int type) { public BlacklistEvent(LocalPlayer player, Vector pos, int type) {
this.player = player; this.player = player;
@ -51,8 +51,8 @@ public BlacklistEvent(LocalPlayer player, Vector pos, int type) {
/** /**
* Get the player. * Get the player.
* *
* @return * @return The player associated with this event
*/ */
public LocalPlayer getPlayer() { public LocalPlayer getPlayer() {
return player; return player;
@ -61,16 +61,16 @@ public LocalPlayer getPlayer() {
/** /**
* Get the position. * Get the position.
* *
* @return * @return The position of this event
*/ */
public Vector getPosition() { public Vector getPosition() {
return pos; return pos;
} }
/** /**
* Get the type. * Get the item type.
* *
* @return * @return The type associated with this event
*/ */
public int getType() { public int getType() {
return type; return type;
@ -79,7 +79,7 @@ public int getType() {
/** /**
* Get a short description such as "break" or "destroy with." * Get a short description such as "break" or "destroy with."
* *
* @return * @return The event description
*/ */
public abstract String getDescription(); public abstract String getDescription();
} }

View File

@ -26,12 +26,7 @@ public class BlockBreakBlacklistEvent extends BlockBlacklistEvent {
public BlockBreakBlacklistEvent(LocalPlayer player, Vector pos, int type) { public BlockBreakBlacklistEvent(LocalPlayer player, Vector pos, int type) {
super(player, pos, type); super(player, pos, type);
} }
/**
* Get a short description such as "break" or "destroy with."
*
* @return
*/
@Override @Override
public String getDescription() { public String getDescription() {
return "break"; return "break";

View File

@ -26,12 +26,7 @@ public class BlockInteractBlacklistEvent extends BlockBlacklistEvent {
public BlockInteractBlacklistEvent(LocalPlayer player, Vector pos, int type) { public BlockInteractBlacklistEvent(LocalPlayer player, Vector pos, int type) {
super(player, pos, type); super(player, pos, type);
} }
/**
* Get a short description such as "break" or "destroy with."
*
* @return
*/
@Override @Override
public String getDescription() { public String getDescription() {
return "interact with"; return "interact with";

View File

@ -26,12 +26,7 @@ public class BlockPlaceBlacklistEvent extends BlockBlacklistEvent {
public BlockPlaceBlacklistEvent(LocalPlayer player, Vector pos, int type) { public BlockPlaceBlacklistEvent(LocalPlayer player, Vector pos, int type) {
super(player, pos, type); super(player, pos, type);
} }
/**
* Get a short description such as "break" or "destroy with."
*
* @return
*/
@Override @Override
public String getDescription() { public String getDescription() {
return "place"; return "place";

View File

@ -26,12 +26,7 @@ public class DestroyWithBlacklistEvent extends BlacklistEvent {
public DestroyWithBlacklistEvent(LocalPlayer player, Vector pos, int type) { public DestroyWithBlacklistEvent(LocalPlayer player, Vector pos, int type) {
super(player, pos, type); super(player, pos, type);
} }
/**
* Get a short description such as "break" or "destroy with."
*
* @return
*/
@Override @Override
public String getDescription() { public String getDescription() {
return "destroy with"; return "destroy with";

View File

@ -26,12 +26,7 @@ public class ItemAcquireBlacklistEvent extends ItemBlacklistEvent {
public ItemAcquireBlacklistEvent(LocalPlayer player, Vector pos, int type) { public ItemAcquireBlacklistEvent(LocalPlayer player, Vector pos, int type) {
super(player, pos, type); super(player, pos, type);
} }
/**
* Get a short description such as "break" or "destroy with."
*
* @return
*/
@Override @Override
public String getDescription() { public String getDescription() {
return "acquire"; return "acquire";

View File

@ -26,12 +26,7 @@ public class ItemDropBlacklistEvent extends ItemBlacklistEvent {
public ItemDropBlacklistEvent(LocalPlayer player, Vector pos, int type) { public ItemDropBlacklistEvent(LocalPlayer player, Vector pos, int type) {
super(player, pos, type); super(player, pos, type);
} }
/**
* Get a short description such as "break" or "destroy with."
*
* @return
*/
@Override @Override
public String getDescription() { public String getDescription() {
return "drop"; return "drop";

View File

@ -26,12 +26,7 @@ public class ItemUseBlacklistEvent extends ItemBlacklistEvent {
public ItemUseBlacklistEvent(LocalPlayer player, Vector pos, int type) { public ItemUseBlacklistEvent(LocalPlayer player, Vector pos, int type) {
super(player, pos, type); super(player, pos, type);
} }
/**
* Get a short description such as "break" or "destroy with."
*
* @return
*/
@Override @Override
public String getDescription() { public String getDescription() {
return "use"; return "use";

View File

@ -48,11 +48,6 @@ public ConsoleLoggerHandler(String worldName, Logger logger) {
this.logger = logger; this.logger = logger;
} }
/**
* Log an event.
*
* @param event
*/
public void logEvent(BlacklistEvent event, String comment) { public void logEvent(BlacklistEvent event, String comment) {
// Block break // Block break
if (event instanceof BlockBreakBlacklistEvent) { if (event instanceof BlockBreakBlacklistEvent) {
@ -113,14 +108,15 @@ public void logEvent(BlacklistEvent event, String comment) {
/** /**
* Get an item's friendly name with its ID. * Get an item's friendly name with its ID.
* *
* @param id * @param id The item id
* @return The friendly name of the item
*/ */
private static String getFriendlyItemName(int id) { private static String getFriendlyItemName(int id) {
ItemType type = ItemType.fromID(id); ItemType type = ItemType.fromID(id);
if (type != null) { if (type != null) {
return type.getName() + " (#" + id + ")"; return type.getName() + " (#" + id + ")";
} else { } else {
return "#" + id + ""; return "#" + id;
} }
} }

View File

@ -73,11 +73,12 @@ public class DatabaseLoggerHandler implements BlacklistLoggerHandler {
/** /**
* Construct the object. * Construct the object.
* *
* @param dsn * @param dsn The DSN for the connection
* @param user * @param user The username to connect with
* @param pass * @param pass The password to connect with
* @param table * @param table The table to log to
* @param worldName * @param worldName The name of the world to log
* @param logger The logger to log errors to
*/ */
public DatabaseLoggerHandler(String dsn, String user, String pass, String table, String worldName, Logger logger) { public DatabaseLoggerHandler(String dsn, String user, String pass, String table, String worldName, Logger logger) {
this.dsn = dsn; this.dsn = dsn;
@ -91,8 +92,8 @@ public DatabaseLoggerHandler(String dsn, String user, String pass, String table,
/** /**
* Gets the database connection. * Gets the database connection.
* *
* @return * @return The database connection
* @throws SQLException * @throws SQLException when the connection cannot be created
*/ */
private Connection getConnection() throws SQLException { private Connection getConnection() throws SQLException {
if (conn == null || conn.isClosed()) { if (conn == null || conn.isClosed()) {
@ -104,11 +105,11 @@ private Connection getConnection() throws SQLException {
/** /**
* Log an event to the database. * Log an event to the database.
* *
* @param event * @param event The event to log
* @param player * @param player The player associated with the event
* @param pos * @param pos The location of the event
* @param item * @param item The item used
* @param comment * @param comment The comment associated with the event
*/ */
private void logEvent(String event, LocalPlayer player, Vector pos, int item, private void logEvent(String event, LocalPlayer player, Vector pos, int item,
String comment) { String comment) {
@ -137,7 +138,7 @@ private void logEvent(String event, LocalPlayer player, Vector pos, int item,
/** /**
* Log an event. * Log an event.
* *
* @param event * @param event The event to log
*/ */
public void logEvent(BlacklistEvent event, String comment) { public void logEvent(BlacklistEvent event, String comment) {
// Block break // Block break
@ -197,7 +198,7 @@ public void close() {
if (conn != null && !conn.isClosed()) { if (conn != null && !conn.isClosed()) {
conn.close(); conn.close();
} }
} catch (SQLException e) { } catch (SQLException ignore) {
} }
} }

View File

@ -85,8 +85,9 @@ public class FileLoggerHandler implements BlacklistLoggerHandler {
/** /**
* Construct the object. * Construct the object.
* *
* @param pathPattern * @param pathPattern The pattern for the logflie path
* @param worldName * @param worldName The name of the world
* @param logger The logger used to log errors
*/ */
public FileLoggerHandler(String pathPattern, String worldName, Logger logger) { public FileLoggerHandler(String pathPattern, String worldName, Logger logger) {
this.pathPattern = pathPattern; this.pathPattern = pathPattern;
@ -97,9 +98,10 @@ public FileLoggerHandler(String pathPattern, String worldName, Logger logger) {
/** /**
* Construct the object. * Construct the object.
* *
* @param pathPattern * @param pathPattern The pattern for logfile paths
* @param cacheSize * @param cacheSize The size of the file cache
* @param worldName * @param worldName The name of the associated world
* @param logger The logger to log errors with
*/ */
public FileLoggerHandler(String pathPattern, int cacheSize, String worldName, Logger logger) { public FileLoggerHandler(String pathPattern, int cacheSize, String worldName, Logger logger) {
if (cacheSize < 1) { if (cacheSize < 1) {
@ -114,7 +116,8 @@ public FileLoggerHandler(String pathPattern, int cacheSize, String worldName, Lo
/** /**
* Build the path. * Build the path.
* *
* @return * @param playerName The name of the playername
* @return The path for the logfile
*/ */
private String buildPath(String playerName) { private String buildPath(String playerName) {
GregorianCalendar calendar = new GregorianCalendar(); GregorianCalendar calendar = new GregorianCalendar();
@ -171,8 +174,9 @@ private String buildPath(String playerName) {
/** /**
* Log a message. * Log a message.
* *
* @param player * @param player The player to log
* @param message * @param message The message to log
* @param comment The comment associated with the logged event
*/ */
private void log(LocalPlayer player, String message, String comment) { private void log(LocalPlayer player, String message, String comment) {
String path = buildPath(player.getName()); String path = buildPath(player.getName());
@ -220,7 +224,7 @@ private void log(LocalPlayer player, String message, String comment) {
Map.Entry<String,FileLoggerWriter> entry = it.next(); Map.Entry<String,FileLoggerWriter> entry = it.next();
try { try {
entry.getValue().getWriter().close(); entry.getValue().getWriter().close();
} catch (IOException e) { } catch (IOException ignore) {
} }
it.remove(); it.remove();
@ -240,8 +244,8 @@ private void log(LocalPlayer player, String message, String comment) {
/** /**
* Gets the coordinates in text form for the log. * Gets the coordinates in text form for the log.
* *
* @param pos * @param pos The position to get coordinates for
* @return * @return The position's coordinates in human-readable form
*/ */
private String getCoordinates(Vector pos) { private String getCoordinates(Vector pos) {
return "@" + pos.getBlockX() + "," + pos.getBlockY() + "," + pos.getBlockZ(); return "@" + pos.getBlockX() + "," + pos.getBlockY() + "," + pos.getBlockZ();
@ -255,55 +259,17 @@ private void logEvent(BlacklistEvent event, String text, int id, Vector pos, Str
/** /**
* Log an event. * Log an event.
* *
* @param event * @param event The event to log
*/ */
public void logEvent(BlacklistEvent event, String comment) { public void logEvent(BlacklistEvent event, String comment) {
// Block break logEvent(event, event.getDescription(), event.getType(), event.getPosition(), comment);
if (event instanceof BlockBreakBlacklistEvent) {
BlockBreakBlacklistEvent evt = (BlockBreakBlacklistEvent)event;
logEvent(event, "break", evt.getType(), evt.getPosition(), comment);
// Block place
} else if (event instanceof BlockPlaceBlacklistEvent) {
BlockPlaceBlacklistEvent evt = (BlockPlaceBlacklistEvent)event;
logEvent(event, "place", evt.getType(), evt.getPosition(), comment);
// Block interact
} else if (event instanceof BlockInteractBlacklistEvent) {
BlockInteractBlacklistEvent evt = (BlockInteractBlacklistEvent)event;
logEvent(event, "interact with", evt.getType(), evt.getPosition(), comment);
// Destroy with
} else if (event instanceof DestroyWithBlacklistEvent) {
DestroyWithBlacklistEvent evt = (DestroyWithBlacklistEvent)event;
logEvent(event, "destroy with", evt.getType(), evt.getPosition(), comment);
// Acquire
} else if (event instanceof ItemAcquireBlacklistEvent) {
ItemAcquireBlacklistEvent evt = (ItemAcquireBlacklistEvent)event;
logEvent(event, "acquire", evt.getType(), evt.getPosition(), comment);
// Drop
} else if (event instanceof ItemDropBlacklistEvent) {
ItemDropBlacklistEvent evt = (ItemDropBlacklistEvent)event;
logEvent(event, "drop", evt.getType(), evt.getPosition(), comment);
// Use
} else if (event instanceof ItemUseBlacklistEvent) {
ItemUseBlacklistEvent evt = (ItemUseBlacklistEvent)event;
logEvent(event, "use", evt.getType(), evt.getPosition(), comment);
// Unknown
} else {
log(event.getPlayer(), "Unknown event: "
+ event.getClass().getCanonicalName(), comment);
}
} }
/** /**
* Get an item's friendly name with its ID. * Get an item's friendly name with its ID.
* *
* @param id * @param id The id to get a friendly name for
* @return The friendly name
*/ */
private static String getFriendlyItemName(int id) { private static String getFriendlyItemName(int id) {
ItemType type = ItemType.fromID(id); ItemType type = ItemType.fromID(id);
@ -321,7 +287,7 @@ public void close() {
for (Map.Entry<String,FileLoggerWriter> entry : writers.entrySet()) { for (Map.Entry<String,FileLoggerWriter> entry : writers.entrySet()) {
try { try {
entry.getValue().getWriter().close(); entry.getValue().getWriter().close();
} catch (IOException e) { } catch (IOException ignore) {
} }
} }

View File

@ -42,8 +42,8 @@ public class FileLoggerWriter implements Comparable<FileLoggerWriter> {
/** /**
* Construct the object. * Construct the object.
* *
* @param path * @param path The path to write to
* @param writer * @param writer The writer for the file
*/ */
public FileLoggerWriter(String path, BufferedWriter writer) { public FileLoggerWriter(String path, BufferedWriter writer) {
this.path = path; this.path = path;
@ -54,14 +54,14 @@ public FileLoggerWriter(String path, BufferedWriter writer) {
/** /**
* File path. * File path.
* *
* @return * @return The path the logger is logging to
*/ */
public String getPath() { public String getPath() {
return path; return path;
} }
/** /**
* @return the writer * @return the writer being logged to
*/ */
public BufferedWriter getWriter() { public BufferedWriter getWriter() {
return writer; return writer;
@ -81,12 +81,6 @@ public void updateLastUse() {
lastUse = System.currentTimeMillis(); lastUse = System.currentTimeMillis();
} }
/**
* Comparison function.
*
* @param other
* @return
*/
public int compareTo(FileLoggerWriter other) { public int compareTo(FileLoggerWriter other) {
if (lastUse > other.lastUse) { if (lastUse > other.lastUse) {
return 1; return 1;

View File

@ -57,6 +57,7 @@ public void kick(String msg) {
@Override @Override
public void ban(String msg) { public void ban(String msg) {
player.setBanned(true);
player.kickPlayer(msg); player.kickPlayer(msg);
} }

View File

@ -50,8 +50,8 @@ private BukkitUtil() {
/** /**
* Converts the location of a Bukkit block to a WorldEdit vector. * Converts the location of a Bukkit block to a WorldEdit vector.
* *
* @param block * @param block The block to convert
* @return * @return The block's location as a BlockVector
*/ */
public static BlockVector toVector(Block block) { public static BlockVector toVector(Block block) {
return new BlockVector(block.getX(), block.getY(), block.getZ()); return new BlockVector(block.getX(), block.getY(), block.getZ());
@ -60,8 +60,8 @@ public static BlockVector toVector(Block block) {
/** /**
* Converts a Bukkit location to a WorldEdit vector. * Converts a Bukkit location to a WorldEdit vector.
* *
* @param loc * @param loc A Bukkit Location
* @return * @return A Vector with the location's x, y, and z values
*/ */
public static Vector toVector(Location loc) { public static Vector toVector(Location loc) {
return new Vector(loc.getX(), loc.getY(), loc.getZ()); return new Vector(loc.getX(), loc.getY(), loc.getZ());
@ -70,8 +70,8 @@ public static Vector toVector(Location loc) {
/** /**
* Converts a Bukkit vector to a WorldEdit vector. * Converts a Bukkit vector to a WorldEdit vector.
* *
* @param vector * @param vector The Bukkit vector
* @return * @return A WorldEdit vector with the same values as the Bukkit vector.
*/ */
public static Vector toVector(org.bukkit.util.Vector vector) { public static Vector toVector(org.bukkit.util.Vector vector) {
return new Vector(vector.getX(), vector.getY(), vector.getZ()); return new Vector(vector.getX(), vector.getY(), vector.getZ());
@ -80,9 +80,9 @@ public static Vector toVector(org.bukkit.util.Vector vector) {
/** /**
* Converts a WorldEdit vector to a Bukkit location. * Converts a WorldEdit vector to a Bukkit location.
* *
* @param world * @param world The World to create the new Location with
* @param vec * @param vec The vector to use for coordinates
* @return * @return The Vector as a location with a World of world
*/ */
public static Location toLocation(World world, Vector vec) { public static Location toLocation(World world, Vector vec) {
return new Location(world, vec.getX(), vec.getY(), vec.getZ()); return new Location(world, vec.getX(), vec.getY(), vec.getZ());
@ -91,10 +91,12 @@ public static Location toLocation(World world, Vector vec) {
/** /**
* Matches one player based on name. * Matches one player based on name.
* *
* @param server * @param server The server to check
* @param name * @param name The name to attempt to match
* @return * @deprecated see {@link WorldGuardPlugin#matchSinglePlayer(org.bukkit.command.CommandSender, String)}
* @return The matched player if any, otherwise null
*/ */
@Deprecated
public static Player matchSinglePlayer(Server server, String name) { public static Player matchSinglePlayer(Server server, String name) {
List<Player> players = server.matchPlayer(name); List<Player> players = server.matchPlayer(name);
if (players.size() == 0) { if (players.size() == 0) {
@ -106,8 +108,10 @@ public static Player matchSinglePlayer(Server server, String name) {
/** /**
* Drops a sign item and removes a sign. * Drops a sign item and removes a sign.
* *
* @param block * @param block The block
* @deprecated see {@link org.bukkit.block.Block#breakNaturally()}
*/ */
@Deprecated
public static void dropSign(Block block) { public static void dropSign(Block block) {
block.setTypeId(0); block.setTypeId(0);
block.getWorld().dropItemNaturally(block.getLocation(), block.getWorld().dropItemNaturally(block.getLocation(),

View File

@ -109,7 +109,7 @@ public class ConfigurationManager {
/** /**
* Construct the object. * Construct the object.
* *
* @param plugin * @param plugin The plugin instance
*/ */
public ConfigurationManager(WorldGuardPlugin plugin) { public ConfigurationManager(WorldGuardPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
@ -152,10 +152,7 @@ public void load() {
get(world); get(world);
} }
try { config.setHeader(CONFIG_HEADER);
config.setHeader(CONFIG_HEADER);
} catch (Throwable t) {
}
if (!config.save()) { if (!config.save()) {
plugin.getLogger().severe("Error saving configuration!"); plugin.getLogger().severe("Error saving configuration!");
@ -172,8 +169,8 @@ public void unload() {
/** /**
* Get the configuration for a world. * Get the configuration for a world.
* *
* @param world * @param world The world to get the configuration for
* @return * @return {@code world}'s configuration
*/ */
public WorldConfiguration get(World world) { public WorldConfiguration get(World world) {
String worldName = world.getName(); String worldName = world.getName();
@ -190,7 +187,7 @@ public WorldConfiguration get(World world) {
/** /**
* Forget a player. * Forget a player.
* *
* @param player * @param player The player to forget about
*/ */
public void forgetPlayer(LocalPlayer player) { public void forgetPlayer(LocalPlayer player) {
for (Map.Entry<String, WorldConfiguration> entry for (Map.Entry<String, WorldConfiguration> entry
@ -210,7 +207,7 @@ public void forgetPlayer(LocalPlayer player) {
/** /**
* Enable god mode for a player. * Enable god mode for a player.
* *
* @param player * @param player The player to enable god mode for.
*/ */
@Deprecated @Deprecated
public void enableGodMode(Player player) { public void enableGodMode(Player player) {
@ -220,7 +217,7 @@ public void enableGodMode(Player player) {
/** /**
* Disable god mode for a player. * Disable god mode for a player.
* *
* @param player * @param player The player to disable godmode for
*/ */
@Deprecated @Deprecated
public void disableGodMode(Player player) { public void disableGodMode(Player player) {
@ -230,8 +227,8 @@ public void disableGodMode(Player player) {
/** /**
* Check to see if god mode is enabled for a player. * Check to see if god mode is enabled for a player.
* *
* @param player * @param player The player to check
* @return * @return Whether the player has godmode through WorldGuard or CommandBook
*/ */
public boolean hasGodMode(Player player) { public boolean hasGodMode(Player player) {
if (hasCommandBookGodMode) { if (hasCommandBookGodMode) {
@ -246,7 +243,7 @@ public boolean hasGodMode(Player player) {
/** /**
* Enable amphibious mode for a player. * Enable amphibious mode for a player.
* *
* @param player * @param player The player to enable amphibious mode for
*/ */
public void enableAmphibiousMode(Player player) { public void enableAmphibiousMode(Player player) {
hasAmphibious.add(player.getName()); hasAmphibious.add(player.getName());
@ -255,17 +252,17 @@ public void enableAmphibiousMode(Player player) {
/** /**
* Disable amphibious mode for a player. * Disable amphibious mode for a player.
* *
* @param player * @param player The player to disable amphibious mode for
*/ */
public void disableAmphibiousMode(Player player) { public void disableAmphibiousMode(Player player) {
hasAmphibious.remove(player.getName()); hasAmphibious.remove(player.getName());
} }
/** /**
* Check to see if amphibious mode is enabled for a player. * Check to see if amphibious mode is enabled for a player.
* *
* @param player * @param player The player to check
* @return * @return Whether {@code player} has amphibious mode
*/ */
public boolean hasAmphibiousMode(Player player) { public boolean hasAmphibiousMode(Player player) {
return hasAmphibious.contains(player.getName()); return hasAmphibious.contains(player.getName());

View File

@ -49,7 +49,7 @@ public class FlagStateManager implements Runnable {
/** /**
* Construct the object. * Construct the object.
* *
* @param plugin * @param plugin The plugin instance
*/ */
public FlagStateManager(WorldGuardPlugin plugin) { public FlagStateManager(WorldGuardPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
@ -99,10 +99,10 @@ public void run() {
/** /**
* Process healing for a player. * Process healing for a player.
* *
* @param applicable * @param applicable The set of applicable regions
* @param player * @param player The player to process healing flags on
* @param state * @param state The player's state
*/ */
private void processHeal(ApplicableRegionSet applicable, Player player, private void processHeal(ApplicableRegionSet applicable, Player player,
PlayerFlagState state) { PlayerFlagState state) {
@ -141,9 +141,9 @@ private void processHeal(ApplicableRegionSet applicable, Player player,
/** /**
* Process restoring hunger for a player. * Process restoring hunger for a player.
* *
* @param applicable * @param applicable The set of applicable regions
* @param player * @param player The player to process hunger flags on
* @param state * @param state The player's state
*/ */
private void processFeed(ApplicableRegionSet applicable, Player player, private void processFeed(ApplicableRegionSet applicable, Player player,
PlayerFlagState state) { PlayerFlagState state) {
@ -178,7 +178,7 @@ private void processFeed(ApplicableRegionSet applicable, Player player,
/** /**
* Forget a player. * Forget a player.
* *
* @param player * @param player The player to forget
*/ */
public synchronized void forget(Player player) { public synchronized void forget(Player player) {
states.remove(player.getName()); states.remove(player.getName());
@ -192,10 +192,11 @@ public synchronized void forgetAll() {
} }
/** /**
* Get a player's flag state. * Get a player's flag state. A new state will be created if there is no existing
* state for the player.
* *
* @param player * @param player The player to get a state for
* @return * @return The {@code player}'s state
*/ */
public synchronized PlayerFlagState getState(Player player) { public synchronized PlayerFlagState getState(Player player) {
PlayerFlagState state = states.get(player.getName()); PlayerFlagState state = states.get(player.getName());

View File

@ -42,7 +42,7 @@ public class LegacyWorldGuardMigration {
/** /**
* Port over the blacklist. * Port over the blacklist.
* *
* @param plugin * @param plugin The plugin instance
*/ */
public static void migrateBlacklist(WorldGuardPlugin plugin) { public static void migrateBlacklist(WorldGuardPlugin plugin) {
World mainWorld = plugin.getServer().getWorlds().get(0); World mainWorld = plugin.getServer().getWorlds().get(0);
@ -75,7 +75,7 @@ public static void migrateBlacklist(WorldGuardPlugin plugin) {
/** /**
* Migrate region settings. * Migrate region settings.
* *
* @param plugin * @param plugin The plugin instance
*/ */
public static void migrateRegions(WorldGuardPlugin plugin) { public static void migrateRegions(WorldGuardPlugin plugin) {
try { try {
@ -109,8 +109,8 @@ public static void migrateRegions(WorldGuardPlugin plugin) {
/** /**
* Copies a file. * Copies a file.
* *
* @param from * @param from The source file
* @param to * @param to The destination file
* @return true if successful * @return true if successful
*/ */
private static boolean copyFile(File from, File to) { private static boolean copyFile(File from, File to) {
@ -131,20 +131,20 @@ private static boolean copyFile(File from, File to) {
out.close(); out.close();
return true; return true;
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ignore) {
} catch (IOException e) { } catch (IOException ignore) {
} finally { } finally {
if (in != null) { if (in != null) {
try { try {
in.close(); in.close();
} catch (IOException e) { } catch (IOException ignore) {
} }
} }
if (out != null) { if (out != null) {
try { try {
out.close(); out.close();
} catch (IOException e) { } catch (IOException ignore) {
} }
} }
} }

View File

@ -127,7 +127,7 @@ private void appendGlobalConfiguration(ConfigurationManager config) {
configLog.put(field.getName(), val); configLog.put(field.getName(), val);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
} catch (IllegalAccessException e) { } catch (IllegalAccessException ignore) {
} }
} }
@ -274,7 +274,7 @@ private void appendWorldConfigurations(WorldGuardPlugin plugin, List<World> worl
configLog.put(field.getName(), String.valueOf(val)); configLog.put(field.getName(), String.valueOf(val));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
} catch (IllegalAccessException e) { } catch (IllegalAccessException ignore) {
} }
} }
@ -324,7 +324,7 @@ public void write(File file) throws IOException {
if (writer != null) { if (writer != null) {
try { try {
writer.close(); writer.close();
} catch (IOException e) { } catch (IOException ignore) {
} }
} }
} }

View File

@ -28,12 +28,12 @@ public class SpongeUtil {
/** /**
* Remove water around a sponge. * Remove water around a sponge.
* *
* @param plugin * @param plugin The plugin instace
* @param world * @param world The world the sponge isin
* @param ox * @param ox The x coordinate of the 'sponge' block
* @param oy * @param oy The y coordinate of the 'sponge' block
* @param oz * @param oz The z coordinate of the 'sponge' block
*/ */
public static void clearSpongeWater(WorldGuardPlugin plugin, World world, int ox, int oy, int oz) { public static void clearSpongeWater(WorldGuardPlugin plugin, World world, int ox, int oy, int oz) {
ConfigurationManager cfg = plugin.getGlobalStateManager(); ConfigurationManager cfg = plugin.getGlobalStateManager();
@ -53,11 +53,11 @@ public static void clearSpongeWater(WorldGuardPlugin plugin, World world, int ox
/** /**
* Add water around a sponge. * Add water around a sponge.
* *
* @param plugin * @param plugin The plugin instance
* @param world * @param world The world the sponge is located in
* @param ox * @param ox The x coordinate of the 'sponge' block
* @param oy * @param oy The y coordinate of the 'sponge' block
* @param oz * @param oz The z coordinate of the 'sponge' block
*/ */
public static void addSpongeWater(WorldGuardPlugin plugin, World world, int ox, int oy, int oz) { public static void addSpongeWater(WorldGuardPlugin plugin, World world, int ox, int oy, int oz) {
ConfigurationManager cfg = plugin.getGlobalStateManager(); ConfigurationManager cfg = plugin.getGlobalStateManager();

View File

@ -67,7 +67,6 @@ public class WorldConfiguration {
private String worldName; private String worldName;
private YAMLProcessor parentConfig; private YAMLProcessor parentConfig;
private YAMLProcessor config; private YAMLProcessor config;
private File configFile;
private File blacklistFile; private File blacklistFile;
private Blacklist blacklist; private Blacklist blacklist;
@ -159,7 +158,7 @@ public class WorldConfiguration {
*/ */
public WorldConfiguration(WorldGuardPlugin plugin, String worldName, YAMLProcessor parentConfig) { public WorldConfiguration(WorldGuardPlugin plugin, String worldName, YAMLProcessor parentConfig) {
File baseFolder = new File(plugin.getDataFolder(), "worlds/" + worldName); File baseFolder = new File(plugin.getDataFolder(), "worlds/" + worldName);
configFile = new File(baseFolder, "config.yml"); File configFile = new File(baseFolder, "config.yml");
blacklistFile = new File(baseFolder, "blacklist.txt"); blacklistFile = new File(baseFolder, "blacklist.txt");
this.plugin = plugin; this.plugin = plugin;
@ -169,7 +168,7 @@ public WorldConfiguration(WorldGuardPlugin plugin, String worldName, YAMLProcess
plugin.createDefaultConfiguration(configFile, "config_world.yml"); plugin.createDefaultConfiguration(configFile, "config_world.yml");
plugin.createDefaultConfiguration(blacklistFile, "blacklist.txt"); plugin.createDefaultConfiguration(blacklistFile, "blacklist.txt");
config = new YAMLProcessor(this.configFile, true, YAMLFormat.EXTENDED); config = new YAMLProcessor(configFile, true, YAMLFormat.EXTENDED);
loadConfiguration(); loadConfiguration();
plugin.getLogger().info("Loaded configuration for world '" + worldName + '"'); plugin.getLogger().info("Loaded configuration for world '" + worldName + '"');
@ -470,10 +469,7 @@ private void loadConfiguration() {
} }
} }
try { config.setHeader(CONFIG_HEADER);
config.setHeader(CONFIG_HEADER);
} catch (Throwable t) {
}
config.save(); config.save();
} }

View File

@ -18,7 +18,6 @@
*/ */
package com.sk89q.worldguard.bukkit; package com.sk89q.worldguard.bukkit;
import static com.sk89q.worldguard.bukkit.BukkitUtil.dropSign;
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector; import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -69,7 +68,7 @@ public class WorldGuardBlockListener implements Listener {
/** /**
* Construct the object. * Construct the object.
* *
* @param plugin * @param plugin The plugin instance
*/ */
public WorldGuardBlockListener(WorldGuardPlugin plugin) { public WorldGuardBlockListener(WorldGuardPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
@ -85,8 +84,8 @@ public void registerEvents() {
/** /**
* Get the world configuration given a world. * Get the world configuration given a world.
* *
* @param world * @param world The world to get the configuration for.
* @return * @return The configuration for {@code world}
*/ */
protected WorldConfiguration getWorldConfig(World world) { protected WorldConfiguration getWorldConfig(World world) {
return plugin.getGlobalStateManager().get(world); return plugin.getGlobalStateManager().get(world);
@ -95,14 +94,14 @@ protected WorldConfiguration getWorldConfig(World world) {
/** /**
* Get the world configuration given a player. * Get the world configuration given a player.
* *
* @param player * @param player The player to get the wold from
* @return * @return The {@link WorldConfiguration} for the player's world
*/ */
protected WorldConfiguration getWorldConfig(Player player) { protected WorldConfiguration getWorldConfig(Player player) {
return plugin.getGlobalStateManager().get(player.getWorld()); return getWorldConfig(player.getWorld());
} }
/** /*
* Called when a block is damaged. * Called when a block is damaged.
*/ */
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -125,7 +124,7 @@ public void onBlockDamage(BlockDamageEvent event) {
} }
} }
/** /*
* Called when a block is broken. * Called when a block is broken.
*/ */
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -178,7 +177,7 @@ public void onBlockBreak(BlockBreakEvent event) {
} }
} }
/** /*
* Called when fluids flow. * Called when fluids flow.
*/ */
@EventHandler @EventHandler
@ -275,7 +274,7 @@ public void onBlockFromTo(BlockFromToEvent event) {
} }
} }
/** /*
* Called when a block gets ignited. * Called when a block gets ignited.
*/ */
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -377,7 +376,7 @@ public void onBlockIgnite(BlockIgniteEvent event) {
} }
/** /*
* Called when a block is destroyed from burning. * Called when a block is destroyed from burning.
*/ */
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -433,7 +432,7 @@ public void onBlockBurn(BlockBurnEvent event) {
} }
} }
/** /*
* Called when block physics occurs. * Called when block physics occurs.
*/ */
@EventHandler @EventHandler
@ -469,7 +468,7 @@ public void onBlockPhysics(BlockPhysicsEvent event) {
} }
} }
/** /*
* Called when a player places a block. * Called when a player places a block.
*/ */
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -524,7 +523,7 @@ public void onBlockPlace(BlockPlaceEvent event) {
} }
} }
/** /*
* Called when redstone changes. * Called when redstone changes.
*/ */
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -560,7 +559,7 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event) {
} }
} }
/** /*
* Called when a sign is changed. * Called when a sign is changed.
*/ */
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -573,7 +572,7 @@ public void onSignChange(SignChangeEvent event) {
if (event.getLine(0).equalsIgnoreCase("[Lock]")) { if (event.getLine(0).equalsIgnoreCase("[Lock]")) {
if (wcfg.isChestProtectedPlacement(event.getBlock(), player)) { if (wcfg.isChestProtectedPlacement(event.getBlock(), player)) {
player.sendMessage(ChatColor.DARK_RED + "You do not own the adjacent chest."); player.sendMessage(ChatColor.DARK_RED + "You do not own the adjacent chest.");
dropSign(event.getBlock()); event.getBlock().breakNaturally();
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -582,7 +581,7 @@ public void onSignChange(SignChangeEvent event) {
player.sendMessage(ChatColor.RED player.sendMessage(ChatColor.RED
+ "The [Lock] sign must be a sign post, not a wall sign."); + "The [Lock] sign must be a sign post, not a wall sign.");
dropSign(event.getBlock()); event.getBlock().breakNaturally();
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -591,7 +590,7 @@ public void onSignChange(SignChangeEvent event) {
player.sendMessage(ChatColor.RED player.sendMessage(ChatColor.RED
+ "The first owner line must be your name."); + "The first owner line must be your name.");
dropSign(event.getBlock()); event.getBlock().breakNaturally();
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -603,7 +602,7 @@ public void onSignChange(SignChangeEvent event) {
player.sendMessage(ChatColor.RED player.sendMessage(ChatColor.RED
+ "That is not a safe block that you're putting this sign on."); + "That is not a safe block that you're putting this sign on.");
dropSign(event.getBlock()); event.getBlock().breakNaturally();
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -616,8 +615,8 @@ public void onSignChange(SignChangeEvent event) {
if (event.getLine(0).equalsIgnoreCase("[Lock]")) { if (event.getLine(0).equalsIgnoreCase("[Lock]")) {
player.sendMessage(ChatColor.RED player.sendMessage(ChatColor.RED
+ "WorldGuard's sign chest protection is disabled."); + "WorldGuard's sign chest protection is disabled.");
dropSign(event.getBlock()); event.getBlock().breakNaturally();
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -657,7 +656,7 @@ public void onLeavesDecay(LeavesDecayEvent event) {
} }
} }
/** /*
* Called when a block is formed based on world conditions. * Called when a block is formed based on world conditions.
*/ */
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -701,7 +700,7 @@ public void onBlockForm(BlockFormEvent event) {
} }
} }
/** /*
* Called when a block spreads based on world conditions. * Called when a block spreads based on world conditions.
*/ */
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -745,7 +744,7 @@ public void onBlockSpread(BlockSpreadEvent event) {
} }
} }
/** /*
* Called when a block fades. * Called when a block fades.
*/ */
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -784,7 +783,7 @@ public void onBlockFade(BlockFadeEvent event) {
} }
} }
/** /*
* Called when a piston extends * Called when a piston extends
*/ */
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -810,7 +809,7 @@ public void onBlockPistonExtend(BlockPistonExtendEvent event) {
} }
} }
/** /*
* Called when a piston retracts * Called when a piston retracts
*/ */
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -826,6 +825,7 @@ public void onBlockPistonRetract(BlockPistonRetractEvent event) {
if (!(plugin.getGlobalRegionManager().allows(DefaultFlag.PISTONS, event.getRetractLocation())) if (!(plugin.getGlobalRegionManager().allows(DefaultFlag.PISTONS, event.getRetractLocation()))
|| !(plugin.getGlobalRegionManager().allows(DefaultFlag.PISTONS, event.getBlock().getLocation()))) { || !(plugin.getGlobalRegionManager().allows(DefaultFlag.PISTONS, event.getBlock().getLocation()))) {
event.setCancelled(true); event.setCancelled(true);
return;
} }
} }
} }

View File

@ -85,7 +85,7 @@ public class WorldGuardEntityListener implements Listener {
/** /**
* Construct the object; * Construct the object;
* *
* @param plugin * @param plugin The plugin instance
*/ */
public WorldGuardEntityListener(WorldGuardPlugin plugin) { public WorldGuardEntityListener(WorldGuardPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
@ -98,9 +98,6 @@ public void registerEvents() {
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
} }
/**
* Called when an entity interacts with another object.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onEntityInteract(EntityInteractEvent event) { public void onEntityInteract(EntityInteractEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
@ -116,9 +113,6 @@ public void onEntityInteract(EntityInteractEvent event) {
} }
} }
/**
* Called when an entity dies.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onEntityDeath(EntityDeathEvent event) { public void onEntityDeath(EntityDeathEvent event) {
WorldConfiguration wcfg = plugin.getGlobalStateManager().get(event.getEntity().getWorld()); WorldConfiguration wcfg = plugin.getGlobalStateManager().get(event.getEntity().getWorld());
@ -128,20 +122,11 @@ public void onEntityDeath(EntityDeathEvent event) {
event.setDroppedExp(0); event.setDroppedExp(0);
} }
try { if (event instanceof PlayerDeathEvent && wcfg.disableDeathMessages) {
if (event instanceof PlayerDeathEvent && wcfg.disableDeathMessages) { ((PlayerDeathEvent) event).setDeathMessage("");
((PlayerDeathEvent) event).setDeathMessage("");
}
} catch (Throwable t) {
// old CraftBukkit, eat it
} }
} }
/**
* Called on entity damage by a block.
*
* @param event
*/
private void onEntityDamageByBlock(EntityDamageByBlockEvent event) { private void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
Entity defender = event.getEntity(); Entity defender = event.getEntity();
DamageCause type = event.getCause(); DamageCause type = event.getCause();
@ -191,11 +176,6 @@ private void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
} }
} }
/**
* Called on entity damage by an entity.
*
* @param event
*/
private void onEntityDamageByEntity(EntityDamageByEntityEvent event) { private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (event.getCause() == DamageCause.PROJECTILE) { if (event.getCause() == DamageCause.PROJECTILE) {
onEntityDamageByProjectile(event); onEntityDamageByProjectile(event);
@ -346,11 +326,6 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
} }
} }
/**
* Called on entity damage by a projectile.
*
* @param event
*/
private void onEntityDamageByProjectile(EntityDamageByEntityEvent event) { private void onEntityDamageByProjectile(EntityDamageByEntityEvent event) {
Entity defender = event.getEntity(); Entity defender = event.getEntity();
Entity attacker = ((Projectile) event.getDamager()).getShooter(); Entity attacker = ((Projectile) event.getDamager()).getShooter();
@ -400,9 +375,6 @@ private void onEntityDamageByProjectile(EntityDamageByEntityEvent event) {
} }
/**
* Called on entity damage.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
@ -481,9 +453,6 @@ public void onEntityDamage(EntityDamageEvent event) {
} }
} }
/**
* Called on entity combust.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onEntityCombust(EntityCombustEvent event) { public void onEntityCombust(EntityCombustEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
@ -505,7 +474,7 @@ public void onEntityCombust(EntityCombustEvent event) {
} }
} }
/** /*
* Called on entity explode. * Called on entity explode.
*/ */
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -622,7 +591,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
} }
/** /*
* Called on explosion prime * Called on explosion prime
*/ */
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -642,9 +611,6 @@ public void onExplosionPrime(ExplosionPrimeEvent event) {
} }
/**
* Called on creature spawn.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onCreatureSpawn(CreatureSpawnEvent event) { public void onCreatureSpawn(CreatureSpawnEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
@ -688,9 +654,6 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
} }
} }
/**
* Called on pig zap.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onPigZap(PigZapEvent event) { public void onPigZap(PigZapEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
@ -705,9 +668,6 @@ public void onPigZap(PigZapEvent event) {
} }
} }
/**
* Called on creeper power.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onCreeperPower(CreeperPowerEvent event) { public void onCreeperPower(CreeperPowerEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
@ -722,9 +682,6 @@ public void onCreeperPower(CreeperPowerEvent event) {
} }
} }
/**
* Called when a painting is removed.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onPaintingBreak(PaintingBreakEvent breakEvent) { public void onPaintingBreak(PaintingBreakEvent breakEvent) {
if (breakEvent.isCancelled()) { if (breakEvent.isCancelled()) {
@ -765,9 +722,6 @@ public void onPaintingBreak(PaintingBreakEvent breakEvent) {
} }
} }
/**
* Called on painting place.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onPaintingPlace(PaintingPlaceEvent event) { public void onPaintingPlace(PaintingPlaceEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
@ -799,9 +753,6 @@ public void onPaintingPlace(PaintingPlaceEvent event) {
} }
} }
/**
* Called on entity health regain.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onEntityRegainHealth(EntityRegainHealthEvent event) { public void onEntityRegainHealth(EntityRegainHealthEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
@ -822,6 +773,8 @@ public void onEntityRegainHealth(EntityRegainHealthEvent event) {
/** /**
* Called when an enderman picks up or puts down a block and some other cases. * Called when an enderman picks up or puts down a block and some other cases.
*
* @param event Relevant event details
*/ */
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onEndermanPickup(EntityChangeBlockEvent event) { public void onEndermanPickup(EntityChangeBlockEvent event) {
@ -885,8 +838,8 @@ public void onFoodLevelChange(FoodLevelChangeEvent event) {
* the region denies invincibility, the player must have an extra permission * the region denies invincibility, the player must have an extra permission
* to override it. (worldguard.god.override-regions) * to override it. (worldguard.god.override-regions)
* *
* @param player * @param player The player to check
* @return * @return Whether {@code player} is invincible
*/ */
private boolean isInvincible(Player player) { private boolean isInvincible(Player player) {
ConfigurationManager cfg = plugin.getGlobalStateManager(); ConfigurationManager cfg = plugin.getGlobalStateManager();
@ -895,7 +848,7 @@ private boolean isInvincible(Player player) {
boolean god = cfg.hasGodMode(player); boolean god = cfg.hasGodMode(player);
if (wcfg.useRegions) { if (wcfg.useRegions) {
Boolean flag = RegionQueryUtil.isAllowedInvinciblity(plugin, player); Boolean flag = RegionQueryUtil.isAllowedInvinciblity(plugin, player);
boolean allowed = flag == null || flag == true; boolean allowed = flag == null || flag;
boolean invincible = RegionQueryUtil.isInvincible(plugin, player); boolean invincible = RegionQueryUtil.isInvincible(plugin, player);
if (allowed) { if (allowed) {

View File

@ -96,11 +96,6 @@ public void registerEvents() {
} }
class PlayerMoveHandler implements Listener { class PlayerMoveHandler implements Listener {
/**
* Called when a player attempts to move.
*
* @param event
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onPlayerMove(PlayerMoveEvent event) { public void onPlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -218,10 +213,6 @@ public void onPlayerMove(PlayerMoveEvent event) {
} }
} }
/**
* Called when a player joins a server.
*/
@SuppressWarnings("deprecation")
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -273,9 +264,6 @@ public void onPlayerJoin(PlayerJoinEvent event) {
} }
} }
/**
* Called when a player leaves a server.
*/
@EventHandler @EventHandler
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -318,9 +306,6 @@ public void onPlayerQuit(PlayerQuitEvent event) {
plugin.forgetPlayer(player); plugin.forgetPlayer(player);
} }
/**
* Called when a player interacts with an item.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -355,7 +340,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {
/** /**
* Called when a player left clicks air. * Called when a player left clicks air.
* *
* @param event * @param event Thrown event
*/ */
private void handleAirLeftClick(PlayerInteractEvent event) { private void handleAirLeftClick(PlayerInteractEvent event) {
// I don't think we have to do anything here yet. // I don't think we have to do anything here yet.
@ -365,7 +350,7 @@ private void handleAirLeftClick(PlayerInteractEvent event) {
/** /**
* Called when a player left clicks a block. * Called when a player left clicks a block.
* *
* @param event * @param event Thrown event
*/ */
private void handleBlockLeftClick(PlayerInteractEvent event) { private void handleBlockLeftClick(PlayerInteractEvent event) {
if (event.isCancelled()) return; if (event.isCancelled()) return;
@ -428,7 +413,7 @@ private void handleBlockLeftClick(PlayerInteractEvent event) {
/** /**
* Called when a player right clicks air. * Called when a player right clicks air.
* *
* @param event * @param event Thrown event
*/ */
private void handleAirRightClick(PlayerInteractEvent event) { private void handleAirRightClick(PlayerInteractEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
@ -457,7 +442,7 @@ private void handleAirRightClick(PlayerInteractEvent event) {
/** /**
* Called when a player right clicks a block. * Called when a player right clicks a block.
* *
* @param event * @param event Thrown event
*/ */
private void handleBlockRightClick(PlayerInteractEvent event) { private void handleBlockRightClick(PlayerInteractEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
@ -730,7 +715,7 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
/** /**
* Called when a player steps on a pressure plate or tramples crops. * Called when a player steps on a pressure plate or tramples crops.
* *
* @param event * @param event Thrown event
*/ */
private void handlePhysicalInteract(PlayerInteractEvent event) { private void handlePhysicalInteract(PlayerInteractEvent event) {
if (event.isCancelled()) return; if (event.isCancelled()) return;
@ -832,9 +817,6 @@ public void onPlayerItem(PlayerItemEvent event) {
} }
}*/ }*/
/**
* Called when a player attempts to drop an item.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onPlayerDropItem(PlayerDropItemEvent event) { public void onPlayerDropItem(PlayerDropItemEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
@ -856,9 +838,6 @@ public void onPlayerDropItem(PlayerDropItemEvent event) {
} }
} }
/**
* Called when a player attempts to pickup an item.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onPlayerPickupItem(PlayerPickupItemEvent event) { public void onPlayerPickupItem(PlayerPickupItemEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
@ -880,9 +859,7 @@ public void onPlayerPickupItem(PlayerPickupItemEvent event) {
} }
} }
/**
* Called when a bucket is filled.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onPlayerBucketFill(PlayerBucketFillEvent event) { public void onPlayerBucketFill(PlayerBucketFillEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -916,9 +893,6 @@ public void onPlayerBucketFill(PlayerBucketFillEvent event) {
} }
} }
/**
* Called when a bucket is empty.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) { public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -943,10 +917,7 @@ public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
} }
} }
} }
/**
* Called when a player is respawned.
*/
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerRespawn(PlayerRespawnEvent event) { public void onPlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -969,9 +940,6 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
} }
} }
/**
* Called when a player changes their held item.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onItemHeldChange(PlayerItemHeldEvent event) { public void onItemHeldChange(PlayerItemHeldEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -990,9 +958,6 @@ public void onItemHeldChange(PlayerItemHeldEvent event) {
} }
} }
/**
* Called when a player enters a bed.
*/
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onPlayerBedEnter(PlayerBedEnterEvent event) { public void onPlayerBedEnter(PlayerBedEnterEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
@ -1019,9 +984,6 @@ public void onPlayerBedEnter(PlayerBedEnterEvent event) {
} }
} }
/**
* Called on command run.
*/
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();

View File

@ -29,8 +29,6 @@
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.logging.Filter;
import java.util.logging.Logger;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import com.sk89q.bukkit.util.CommandsManagerRegistration; import com.sk89q.bukkit.util.CommandsManagerRegistration;
@ -43,6 +41,7 @@
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -217,16 +216,16 @@ public boolean onCommand(CommandSender sender, Command cmd, String label,
/** /**
* Get the GlobalRegionManager. * Get the GlobalRegionManager.
* *
* @return * @return The plugin's global region manager
*/ */
public GlobalRegionManager getGlobalRegionManager() { public GlobalRegionManager getGlobalRegionManager() {
return globalRegionManager; return globalRegionManager;
} }
/** /**
* Get the WorldGuardConfiguraton. * Get the WorldGuard Configuration.
* *
* @return * @return ConfigurationManager
* @deprecated Use {@link #getGlobalStateManager()} instead * @deprecated Use {@link #getGlobalStateManager()} instead
*/ */
@Deprecated @Deprecated
@ -237,27 +236,28 @@ public ConfigurationManager getGlobalConfiguration() {
/** /**
* Gets the flag state manager. * Gets the flag state manager.
* *
* @return * @return The flag state manager
*/ */
public FlagStateManager getFlagStateManager() { public FlagStateManager getFlagStateManager() {
return flagStateManager; return flagStateManager;
} }
/** /**
* Get the WorldGuardConfiguraton. * Get the global ConfigurationManager.
* * USe this to access global configuration values and per-world configuration values.
* @return * @return The global ConfigurationManager
*/ */
public ConfigurationManager getGlobalStateManager() { public ConfigurationManager getGlobalStateManager() {
return configuration; return configuration;
} }
/** /**
* Check whether a player is in a group. * Check whether a player is in a group.
* This calls the corresponding method in PermissionsResolverManager
* *
* @param player * @param player The player to check
* @param group * @param group The group
* @return * @return whether {@code player} is in {@code group}
*/ */
public boolean inGroup(Player player, String group) { public boolean inGroup(Player player, String group) {
try { try {
@ -270,9 +270,9 @@ public boolean inGroup(Player player, String group) {
/** /**
* Get the groups of a player. * Get the groups of a player.
* * This calls the corresponding method in PermissionsResolverManager.
* @param player * @param player The player to check
* @return * @return The names of each group the playe is in.
*/ */
public String[] getGroups(Player player) { public String[] getGroups(Player player) {
try { try {
@ -287,37 +287,39 @@ public String[] getGroups(Player player) {
* Gets the name of a command sender. This is a unique name and this * Gets the name of a command sender. This is a unique name and this
* method should never return a "display name". * method should never return a "display name".
* *
* @param sender * @param sender The sender to get the name of
* @return * @return The unique name of the sender.
*/ */
public String toUniqueName(CommandSender sender) { public String toUniqueName(CommandSender sender) {
if (sender instanceof Player) { if (sender instanceof ConsoleCommandSender) {
return ((Player) sender).getName();
} else {
return "*Console*"; return "*Console*";
} else {
return sender.getName();
} }
} }
/** /**
* Gets the name of a command sender. This play be a display name. * Gets the name of a command sender. This play be a display name.
* *
* @param sender * @param sender The CommandSender to get the name of.
* @return * @return The name of the given sender
*/ */
public String toName(CommandSender sender) { public String toName(CommandSender sender) {
if (sender instanceof Player) { if (sender instanceof ConsoleCommandSender) {
return ((Player) sender).getName();
} else {
return "*Console*"; return "*Console*";
} else if (sender instanceof Player) {
return ((Player) sender).getDisplayName();
} else {
return sender.getName();
} }
} }
/** /**
* Checks permissions. * Checks permissions.
* *
* @param sender * @param sender The sender to check the permission on.
* @param perm * @param perm The permission to check the permission on.
* @return * @return whether {@code sender} has {@code perm}
*/ */
public boolean hasPermission(CommandSender sender, String perm) { public boolean hasPermission(CommandSender sender, String perm) {
if (sender.isOp()) { if (sender.isOp()) {
@ -343,9 +345,9 @@ public boolean hasPermission(CommandSender sender, String perm) {
/** /**
* Checks permissions and throws an exception if permission is not met. * Checks permissions and throws an exception if permission is not met.
* *
* @param sender * @param sender The sender to check the permission on.
* @param perm * @param perm The permission to check the permission on.
* @throws CommandPermissionsException * @throws CommandPermissionsException if {@code sender} doesn't have {@code perm}
*/ */
public void checkPermission(CommandSender sender, String perm) public void checkPermission(CommandSender sender, String perm)
throws CommandPermissionsException { throws CommandPermissionsException {
@ -357,9 +359,9 @@ public void checkPermission(CommandSender sender, String perm)
/** /**
* Checks to see if the sender is a player, otherwise throw an exception. * Checks to see if the sender is a player, otherwise throw an exception.
* *
* @param sender * @param sender The {@link CommandSender} to check
* @return * @return {@code sender} casted to a player
* @throws CommandException * @throws CommandException if {@code sender} isn't a {@link Player}
*/ */
public Player checkPlayer(CommandSender sender) public Player checkPlayer(CommandSender sender)
throws CommandException { throws CommandException {
@ -373,8 +375,13 @@ public Player checkPlayer(CommandSender sender)
/** /**
* Match player names. * Match player names.
* *
* @param filter * The filter string uses the following format:
* @return * @[name] looks up all players with the exact {@code name}
* *[name] matches any player whose name contains {@code name}
* [name] matches any player whose name starts with {@code name}
*
* @param filter The filter string to check.
* @return A {@link List} of players who match {@code filter}
*/ */
public List<Player> matchPlayerNames(String filter) { public List<Player> matchPlayerNames(String filter) {
Player[] players = getServer().getOnlinePlayers(); Player[] players = getServer().getOnlinePlayers();
@ -426,9 +433,9 @@ public List<Player> matchPlayerNames(String filter) {
* Checks if the given list of players is greater than size 0, otherwise * Checks if the given list of players is greater than size 0, otherwise
* throw an exception. * throw an exception.
* *
* @param players * @param players The {@link List} to check
* @return * @return {@code players} as an {@link Iterable}
* @throws CommandException * @throws CommandException If {@code players} is empty
*/ */
protected Iterable<Player> checkPlayerMatch(List<Player> players) protected Iterable<Player> checkPlayerMatch(List<Player> players)
throws CommandException { throws CommandException {
@ -441,12 +448,19 @@ protected Iterable<Player> checkPlayerMatch(List<Player> players)
} }
/** /**
* Checks permissions and throws an exception if permission is not met. * Matches players based on the specified filter string
* *
* @param source * The filter string format is as follows:
* @param filter * * returns all the players currently online
* If {@code sender} is a {@link Player}:
* #world returns all players in the world that {@code sender} is in
* #near reaturns all players within 30 blocks of {@code sender}'s location
* Otherwise, the format is as specified in {@link #matchPlayerNames(String)}
*
* @param source The CommandSender who is trying to find a player
* @param filter The filter string for players
* @return iterator for players * @return iterator for players
* @throws CommandException no matches found * @throws CommandException if no matches are found
*/ */
public Iterable<Player> matchPlayers(CommandSender source, String filter) public Iterable<Player> matchPlayers(CommandSender source, String filter)
throws CommandException { throws CommandException {
@ -507,10 +521,11 @@ public Iterable<Player> matchPlayers(CommandSender source, String filter)
/** /**
* Match only a single player. * Match only a single player.
* *
* @param sender * @param sender The {@link CommandSender} who is requesting a player match
* @param filter * @param filter The filter string.
* @return * @see #matchPlayers(org.bukkit.entity.Player) for filter string syntax
* @throws CommandException * @return The single player
* @throws CommandException If more than one player match was found
*/ */
public Player matchSinglePlayer(CommandSender sender, String filter) public Player matchSinglePlayer(CommandSender sender, String filter)
throws CommandException { throws CommandException {
@ -532,11 +547,14 @@ public Player matchSinglePlayer(CommandSender sender, String filter)
/** /**
* Match only a single player or console. * Match only a single player or console.
* *
* @param sender * The filter string syntax is as follows:
* @param filter * #console, *console, or ! return the server console
* @return * All syntax from {@link #matchSinglePlayer(org.bukkit.command.CommandSender, String)}
* @throws CommandException * @param sender The sender trying to match a CommandSender
* @param filter The filter string
* @return The resulting CommandSender
* @throws CommandException if either zero or more than one player matched.
*/ */
public CommandSender matchPlayerOrConsole(CommandSender sender, String filter) public CommandSender matchPlayerOrConsole(CommandSender sender, String filter)
throws CommandException { throws CommandException {
@ -554,20 +572,27 @@ public CommandSender matchPlayerOrConsole(CommandSender sender, String filter)
/** /**
* Get a single player as an iterator for players. * Get a single player as an iterator for players.
* *
* @param player * @param player The player to return in an Iterable
* @return iterator for players * @return iterator for player
*/ */
public Iterable<Player> matchPlayers(Player player) { public Iterable<Player> matchPlayers(Player player) {
return Arrays.asList(new Player[] {player}); return Arrays.asList(player);
} }
/** /**
* Match a world. * Match a world.
* @param sender *
* * The filter string syntax is as follows:
* @param filter * #main returns the main world
* @return * #normal returns the first world with a normal environment
* @throws CommandException * #nether return the first world with a nether environment
* #player:[name] returns the world that a player named {@code name} is located in, if the player is online.
* [name] A world with the name {@code name}
*
* @param sender The sender requesting a match
* @param filter The filter string
* @return The resulting world
* @throws CommandException if no world matches
*/ */
public World matchWorld(CommandSender sender, String filter) throws CommandException { public World matchWorld(CommandSender sender, String filter) throws CommandException {
List<World> worlds = getServer().getWorlds(); List<World> worlds = getServer().getWorlds();
@ -625,8 +650,8 @@ public World matchWorld(CommandSender sender, String filter) throws CommandExcep
/** /**
* Gets a copy of the WorldEdit plugin. * Gets a copy of the WorldEdit plugin.
* *
* @return * @return The WorldEditPlugin instance
* @throws CommandException * @throws CommandException If there is no WorldEditPlugin available
*/ */
public WorldEditPlugin getWorldEdit() throws CommandException { public WorldEditPlugin getWorldEdit() throws CommandException {
Plugin worldEdit = getServer().getPluginManager().getPlugin("WorldEdit"); Plugin worldEdit = getServer().getPluginManager().getPlugin("WorldEdit");
@ -644,8 +669,8 @@ public WorldEditPlugin getWorldEdit() throws CommandException {
/** /**
* Wrap a player as a LocalPlayer. * Wrap a player as a LocalPlayer.
* *
* @param player * @param player The player to wrap
* @return * @return The wrapped player
*/ */
public LocalPlayer wrapPlayer(Player player) { public LocalPlayer wrapPlayer(Player player) {
return new BukkitPlayer(this, player); return new BukkitPlayer(this, player);
@ -654,8 +679,8 @@ public LocalPlayer wrapPlayer(Player player) {
/** /**
* Create a default configuration file from the .jar. * Create a default configuration file from the .jar.
* *
* @param actual * @param actual The destination file
* @param defaultName * @param defaultName The name of the file inside the jar's defaults folder
*/ */
public void createDefaultConfiguration(File actual, public void createDefaultConfiguration(File actual,
String defaultName) { String defaultName) {
@ -701,14 +726,14 @@ public void createDefaultConfiguration(File actual,
if (input != null) { if (input != null) {
input.close(); input.close();
} }
} catch (IOException e) { } catch (IOException ignore) {
} }
try { try {
if (output != null) { if (output != null) {
output.close(); output.close();
} }
} catch (IOException e) { } catch (IOException ignore) {
} }
} }
} }
@ -716,12 +741,16 @@ public void createDefaultConfiguration(File actual,
/** /**
* Notifies all with the notify permission. * Notifies all with the notify permission.
* * This will check both superperms and WEPIF,
* @param msg * but makes sure WEPIF checks don't result in duplicate notifications
*
* @param msg The notification to broadcast
*/ */
public void broadcastNotification(String msg) { public void broadcastNotification(String msg) {
getServer().broadcast(msg, "worldguard.notify");
for (Player player : getServer().getOnlinePlayers()) { for (Player player : getServer().getOnlinePlayers()) {
if (hasPermission(player, "worldguard.notify")) { if (hasPermission(player, "worldguard.notify") &&
!player.hasPermission("worldguard.notify")) { // Make sure the player wasn't already broadcasted to.
player.sendMessage(msg); player.sendMessage(msg);
} }
} }
@ -731,7 +760,7 @@ public void broadcastNotification(String msg) {
/** /**
* Forgets a player. * Forgets a player.
* *
* @param player * @param player The player to remove state information for
*/ */
public void forgetPlayer(Player player) { public void forgetPlayer(Player player) {
flagStateManager.forget(player); flagStateManager.forget(player);
@ -741,9 +770,10 @@ public void forgetPlayer(Player player) {
* Checks to see if a player can build at a location. This will return * Checks to see if a player can build at a location. This will return
* true if region protection is disabled. * true if region protection is disabled.
* *
* @param player * @param player The player to check.
* @param loc * @param loc The location to check at.
* @return * @see GlobalRegionManager#canBuild(org.bukkit.entity.Player, org.bukkit.Location)
* @return whether {@code player} can build at {@code loc}
*/ */
public boolean canBuild(Player player, Location loc) { public boolean canBuild(Player player, Location loc) {
return getGlobalRegionManager().canBuild(player, loc); return getGlobalRegionManager().canBuild(player, loc);
@ -753,9 +783,10 @@ public boolean canBuild(Player player, Location loc) {
* Checks to see if a player can build at a location. This will return * Checks to see if a player can build at a location. This will return
* true if region protection is disabled. * true if region protection is disabled.
* *
* @param player * @param player The player to check
* @param block * @param block The block to check at.
* @return * @see GlobalRegionManager#canBuild(org.bukkit.entity.Player, org.bukkit.block.Block)
* @return whether {@code player} can build at {@code block}'s location
*/ */
public boolean canBuild(Player player, Block block) { public boolean canBuild(Player player, Block block) {
return getGlobalRegionManager().canBuild(player, block); return getGlobalRegionManager().canBuild(player, block);
@ -778,9 +809,17 @@ public RegionManager getRegionManager(World world) {
/** /**
* Replace macros in the text. * Replace macros in the text.
* *
* @param sender * The macros replaced are as follows:
* @param message * %name%: The name of {@code sender}. See {@link #toName(org.bukkit.command.CommandSender)}
* @return * %id%: The unique name of the sender. See {@link #toUniqueName(org.bukkit.command.CommandSender)}
* %online%: The number of players currently online on the server
* If {@code sender} is a Player:
* %world%: The name of the world {@code sender} is located in
* %health%: The health of {@code sender}. See {@link org.bukkit.entity.Player#getHealth()}
*
* @param sender The sender to check
* @param message The message to replace macros in
* @return The message with macros replaced
*/ */
public String replaceMacros(CommandSender sender, String message) { public String replaceMacros(CommandSender sender, String message) {
Player[] online = getServer().getOnlinePlayers(); Player[] online = getServer().getOnlinePlayers();

View File

@ -24,11 +24,15 @@ public void registerEvents() {
@EventHandler @EventHandler
public void onPluginEnable(PluginEnableEvent event) { public void onPluginEnable(PluginEnableEvent event) {
plugin.getGlobalStateManager().updateCommandBookGodMode(); if (event.getPlugin().getDescription().getName().equalsIgnoreCase("CommandBook")) {
plugin.getGlobalStateManager().updateCommandBookGodMode();
}
} }
@EventHandler @EventHandler
public void onPluginDisable(PluginDisableEvent event) { public void onPluginDisable(PluginDisableEvent event) {
plugin.getGlobalStateManager().updateCommandBookGodMode(); if (event.getPlugin().getDescription().getName().equalsIgnoreCase("CommandBook")) {
plugin.getGlobalStateManager().updateCommandBookGodMode();
}
} }
} }

View File

@ -44,9 +44,6 @@ public void registerEvents() {
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
} }
/**
* Called when a vehicle is destroyed.
*/
@EventHandler @EventHandler
public void onVehicleDestroy(VehicleDestroyEvent event) { public void onVehicleDestroy(VehicleDestroyEvent event) {
Vehicle vehicle = event.getVehicle(); Vehicle vehicle = event.getVehicle();
@ -74,9 +71,6 @@ public void onVehicleDestroy(VehicleDestroyEvent event) {
} }
} }
/**
* Called when a vehicle moves.
*/
@EventHandler @EventHandler
public void onVehicleMove(VehicleMoveEvent event) { public void onVehicleMove(VehicleMoveEvent event) {
Vehicle vehicle = event.getVehicle(); Vehicle vehicle = event.getVehicle();

View File

@ -42,7 +42,7 @@ public class WorldGuardWeatherListener implements Listener {
/** /**
* Construct the object; * Construct the object;
* *
* @param plugin * @param plugin The plugin instance
*/ */
public WorldGuardWeatherListener(WorldGuardPlugin plugin) { public WorldGuardWeatherListener(WorldGuardPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;

View File

@ -19,7 +19,7 @@ public class WorldGuardWorldListener implements Listener {
/** /**
* Construct the object; * Construct the object;
* *
* @param plugin * @param plugin The plugin instance
*/ */
public WorldGuardWorldListener(WorldGuardPlugin plugin) { public WorldGuardWorldListener(WorldGuardPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
@ -32,9 +32,6 @@ public void registerEvents() {
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
} }
/**
* Called when a chunk is loaded.
*/
@EventHandler @EventHandler
public void onChunkLoad(ChunkLoadEvent event) { public void onChunkLoad(ChunkLoadEvent event) {
ConfigurationManager cfg = plugin.getGlobalStateManager(); ConfigurationManager cfg = plugin.getGlobalStateManager();
@ -56,14 +53,19 @@ public void onChunkLoad(ChunkLoadEvent event) {
} }
} }
/**
* Called when a world is loaded.
*/
@EventHandler @EventHandler
public void onWorldLoad(WorldLoadEvent event) { public void onWorldLoad(WorldLoadEvent event) {
initWorld(event.getWorld()); initWorld(event.getWorld());
} }
/**
* Initialize the settings for the specified world
* @see WorldConfiguration#alwaysRaining
* @see WorldConfiguration#disableWeather
* @see WorldConfiguration#alwaysThundering
* @see WorldConfiguration#disableThunder
* @param world The specified world
*/
public void initWorld(World world) { public void initWorld(World world) {
ConfigurationManager cfg = plugin.getGlobalStateManager(); ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(world); WorldConfiguration wcfg = cfg.get(world);

View File

@ -58,7 +58,7 @@
import com.sk89q.worldguard.protection.databases.migrators.AbstractDatabaseMigrator; import com.sk89q.worldguard.protection.databases.migrators.AbstractDatabaseMigrator;
import com.sk89q.worldguard.protection.databases.migrators.MigrationException; import com.sk89q.worldguard.protection.databases.migrators.MigrationException;
import com.sk89q.worldguard.protection.databases.migrators.MigratorKey; import com.sk89q.worldguard.protection.databases.migrators.MigratorKey;
import com.sk89q.worldguard.util.RegionUtil; import com.sk89q.worldguard.protection.databases.RegionDBUtil;
public class RegionCommands { public class RegionCommands {
private final WorldGuardPlugin plugin; private final WorldGuardPlugin plugin;
@ -118,7 +118,7 @@ public void define(CommandContext args, CommandSender sender) throws CommandExce
// Get the list of region owners // Get the list of region owners
if (args.argsLength() > 1) { if (args.argsLength() > 1) {
region.setOwners(RegionUtil.parseDomainString(args.getSlice(1), 1)); region.setOwners(RegionDBUtil.parseDomainString(args.getSlice(1), 1));
} }
mgr.addRegion(region); mgr.addRegion(region);
@ -191,7 +191,7 @@ public void redefine(CommandContext args, CommandSender sender) throws CommandEx
region.setPriority(existing.getPriority()); region.setPriority(existing.getPriority());
try { try {
region.setParent(existing.getParent()); region.setParent(existing.getParent());
} catch (CircularInheritanceException e) { } catch (CircularInheritanceException ignore) {
} }
mgr.addRegion(region); mgr.addRegion(region);
@ -256,7 +256,7 @@ public void claim(CommandContext args, CommandSender sender) throws CommandExcep
// Get the list of region owners // Get the list of region owners
if (args.argsLength() > 1) { if (args.argsLength() > 1) {
region.setOwners(RegionUtil.parseDomainString(args.getSlice(1), 1)); region.setOwners(RegionDBUtil.parseDomainString(args.getSlice(1), 1));
} }
WorldConfiguration wcfg = plugin.getGlobalStateManager().get(player.getWorld()); WorldConfiguration wcfg = plugin.getGlobalStateManager().get(player.getWorld());
@ -494,8 +494,8 @@ public void list(CommandContext args, CommandSender sender) throws CommandExcept
if (!own) if (!own)
plugin.checkPermission(sender, "worldguard.region.list"); plugin.checkPermission(sender, "worldguard.region.list");
if (args.argsLength() > 0 + argl) { if (args.argsLength() > argl) {
page = Math.max(0, args.getInteger(0 + argl) - 1); page = Math.max(0, args.getInteger(argl) - 1);
} }
if (args.argsLength() > 1 + argl) { if (args.argsLength() > 1 + argl) {
@ -513,8 +513,8 @@ public void list(CommandContext args, CommandSender sender) throws CommandExcept
String[] regionIDList = new String[size]; String[] regionIDList = new String[size];
int index = 0; int index = 0;
boolean show = false; boolean show;
String prefix = ""; String prefix;
for (String id : regions.keySet()) { for (String id : regions.keySet()) {
show = false; show = false;
prefix = ""; prefix = "";
@ -780,7 +780,7 @@ public void setParent(CommandContext args, CommandSender sender) throws CommandE
if (args.argsLength() == 1) { if (args.argsLength() == 1) {
try { try {
region.setParent(null); region.setParent(null);
} catch (CircularInheritanceException e) { } catch (CircularInheritanceException ignore) {
} }
sender.sendMessage(ChatColor.YELLOW sender.sendMessage(ChatColor.YELLOW
@ -982,17 +982,17 @@ public void migratedb(CommandContext args, CommandSender sender) throws CommandE
AbstractDatabaseMigrator migrator = cls.getConstructor(WorldGuardPlugin.class).newInstance(plugin); AbstractDatabaseMigrator migrator = cls.getConstructor(WorldGuardPlugin.class).newInstance(plugin);
migrator.migrate(); migrator.migrate();
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException ignore) {
} catch (SecurityException e) { } catch (SecurityException ignore) {
} catch (InstantiationException e) { } catch (InstantiationException ignore) {
} catch (IllegalAccessException e) { } catch (IllegalAccessException ignore) {
} catch (InvocationTargetException e) { } catch (InvocationTargetException ignore) {
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException ignore) {
} catch (MigrationException e) { } catch (MigrationException e) {
throw new CommandException("Error migrating database: " + e.getMessage()); throw new CommandException("Error migrating database: " + e.getMessage());
} }
sender.sendMessage(ChatColor.YELLOW + "Regions have been migrated successfuly.\n" + sender.sendMessage(ChatColor.YELLOW + "Regions have been migrated successfully.\n" +
"If you wish to use the destination format as your new backend, please update your config and reload WorldGuard."); "If you wish to use the destination format as your new backend, please update your config and reload WorldGuard.");
} }
} }

View File

@ -34,7 +34,7 @@
import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion; import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.databases.ProtectionDatabaseException; import com.sk89q.worldguard.protection.databases.ProtectionDatabaseException;
import com.sk89q.worldguard.util.RegionUtil; import com.sk89q.worldguard.protection.databases.RegionDBUtil;
// @TODO: A lot of code duplication here! Need to fix. // @TODO: A lot of code duplication here! Need to fix.
@ -70,7 +70,7 @@ public void addMember(CommandContext args, CommandSender sender) throws CommandE
plugin.checkPermission(sender, "worldguard.region.addmember." + id.toLowerCase()); plugin.checkPermission(sender, "worldguard.region.addmember." + id.toLowerCase());
} }
RegionUtil.addToDomain(region.getMembers(), args.getPaddedSlice(2, 0), 0); RegionDBUtil.addToDomain(region.getMembers(), args.getPaddedSlice(2, 0), 0);
sender.sendMessage(ChatColor.YELLOW sender.sendMessage(ChatColor.YELLOW
+ "Region '" + id + "' updated."); + "Region '" + id + "' updated.");
@ -102,7 +102,7 @@ public void addOwner(CommandContext args, CommandSender sender) throws CommandEx
Boolean flag = region.getFlag(DefaultFlag.BUYABLE); Boolean flag = region.getFlag(DefaultFlag.BUYABLE);
DefaultDomain owners = region.getOwners(); DefaultDomain owners = region.getOwners();
if (flag != null && flag == true && owners != null && owners.size() == 0) { if (flag != null && flag && owners != null && owners.size() == 0) {
if (!plugin.hasPermission(player, "worldguard.region.unlimited")) { if (!plugin.hasPermission(player, "worldguard.region.unlimited")) {
int maxRegionCount = plugin.getGlobalStateManager().get(world).getMaxRegionCount(player); int maxRegionCount = plugin.getGlobalStateManager().get(world).getMaxRegionCount(player);
if (maxRegionCount >= 0 && mgr.getRegionCountOfPlayer(localPlayer) if (maxRegionCount >= 0 && mgr.getRegionCountOfPlayer(localPlayer)
@ -121,7 +121,7 @@ public void addOwner(CommandContext args, CommandSender sender) throws CommandEx
} }
} }
RegionUtil.addToDomain(region.getOwners(), args.getPaddedSlice(2, 0), 0); RegionDBUtil.addToDomain(region.getOwners(), args.getPaddedSlice(2, 0), 0);
sender.sendMessage(ChatColor.YELLOW sender.sendMessage(ChatColor.YELLOW
+ "Region '" + id + "' updated."); + "Region '" + id + "' updated.");
@ -159,7 +159,7 @@ public void removeMember(CommandContext args, CommandSender sender) throws Comma
plugin.checkPermission(sender, "worldguard.region.removemember." + id.toLowerCase()); plugin.checkPermission(sender, "worldguard.region.removemember." + id.toLowerCase());
} }
RegionUtil.removeFromDomain(region.getMembers(), args.getPaddedSlice(2, 0), 0); RegionDBUtil.removeFromDomain(region.getMembers(), args.getPaddedSlice(2, 0), 0);
sender.sendMessage(ChatColor.YELLOW sender.sendMessage(ChatColor.YELLOW
+ "Region '" + id + "' updated."); + "Region '" + id + "' updated.");
@ -198,7 +198,7 @@ public void removeOwner(CommandContext args,
plugin.checkPermission(sender, "worldguard.region.removeowner." + id.toLowerCase()); plugin.checkPermission(sender, "worldguard.region.removeowner." + id.toLowerCase());
} }
RegionUtil.removeFromDomain(region.getOwners(), args.getPaddedSlice(2, 0), 0); RegionDBUtil.removeFromDomain(region.getOwners(), args.getPaddedSlice(2, 0), 0);
sender.sendMessage(ChatColor.YELLOW sender.sendMessage(ChatColor.YELLOW
+ "Region '" + id + "' updated."); + "Region '" + id + "' updated.");

View File

@ -31,9 +31,9 @@ public interface ChestProtection {
/** /**
* Returns whether a block is protected. * Returns whether a block is protected.
* *
* @param block * @param block The block to check
* @param player * @param player The player to check
* @return * @return Whether the block is protected for player
*/ */
public boolean isProtected(Block block, Player player); public boolean isProtected(Block block, Player player);
@ -41,26 +41,27 @@ public interface ChestProtection {
* Returns whether a location where a chest block is trying to be created * Returns whether a location where a chest block is trying to be created
* is protected. * is protected.
* *
* @param block * @param block The block to check
* @param player * @param player The player to check
* @return * @return Whether {@code player} can place a block at the specified block
*/ */
public boolean isProtectedPlacement(Block block, Player player); public boolean isProtectedPlacement(Block block, Player player);
/** /**
* Returns whether an adjacent chest is protected. * Returns whether an adjacent chest is protected.
* *
* @param searchBlock * @param searchBlock The block to check
* @param player * @param player The player to check
* @return * @return Whether {@code searchBlock} is protected from access by {@code player}
*/ */
public boolean isAdjacentChestProtected(Block searchBlock, Player player); public boolean isAdjacentChestProtected(Block searchBlock, Player player);
/** /**
* Returns whether a material is a chest. * Returns whether a material is a chest.
* *
* @param material * @param material The material to check
* @return * @deprecated see {@link #isChest(int)}
* @return {@link #isChest(int)}
*/ */
@Deprecated @Deprecated
public boolean isChest(Material material); public boolean isChest(Material material);
@ -68,8 +69,8 @@ public interface ChestProtection {
/** /**
* Returns whether a material is a chest. * Returns whether a material is a chest.
* *
* @param type * @param type The type to check
* @return * @return Whether type is a 'chest' (block that can be protected)
*/ */
public boolean isChest(int type); public boolean isChest(int type);

View File

@ -127,23 +127,23 @@ public boolean isAdjacentChestProtected(Block searchBlock, Player player) {
side = searchBlock; side = searchBlock;
res = isProtected(side, player); res = isProtected(side, player);
if (res != null && res == true) return res; if (res != null && res) return res;
side = searchBlock.getRelative(-1, 0, 0); side = searchBlock.getRelative(-1, 0, 0);
res = isProtected(side, player); res = isProtected(side, player);
if (res != null && res == true) return res; if (res != null && res) return res;
side = searchBlock.getRelative(1, 0, 0); side = searchBlock.getRelative(1, 0, 0);
res = isProtected(side, player); res = isProtected(side, player);
if (res != null && res == true) return res; if (res != null && res) return res;
side = searchBlock.getRelative(0, 0, -1); side = searchBlock.getRelative(0, 0, -1);
res = isProtected(side, player); res = isProtected(side, player);
if (res != null && res == true) return res; if (res != null && res) return res;
side = searchBlock.getRelative(0, 0, 1); side = searchBlock.getRelative(0, 0, 1);
res = isProtected(side, player); res = isProtected(side, player);
if (res != null && res == true) return res; if (res != null && res) return res;
return false; return false;
} }

View File

@ -6,8 +6,8 @@ public interface Domain {
/** /**
* Returns true if a domain contains a player. * Returns true if a domain contains a player.
* *
* @param player * @param player The player to check
* @return * @return whether this domain contains {@code player}
*/ */
public boolean contains(LocalPlayer player); public boolean contains(LocalPlayer player);
} }

View File

@ -53,8 +53,8 @@ public class ApplicableRegionSet implements Iterable<ProtectedRegion> {
/** /**
* Construct the object. * Construct the object.
* *
* @param applicable * @param applicable The regions contained in this set
* @param globalRegion * @param globalRegion The global region, set aside for special handling.
*/ */
public ApplicableRegionSet(Collection<ProtectedRegion> applicable, public ApplicableRegionSet(Collection<ProtectedRegion> applicable,
ProtectedRegion globalRegion) { ProtectedRegion globalRegion) {
@ -65,7 +65,7 @@ public ApplicableRegionSet(Collection<ProtectedRegion> applicable,
/** /**
* Checks if a player can build in an area. * Checks if a player can build in an area.
* *
* @param player * @param player The player to chec
* @return build ability * @return build ability
*/ */
public boolean canBuild(LocalPlayer player) { public boolean canBuild(LocalPlayer player) {
@ -75,7 +75,7 @@ public boolean canBuild(LocalPlayer player) {
/** /**
* Checks if a player can use buttons and such in an area. * Checks if a player can use buttons and such in an area.
* *
* @param player * @param player The player to check
* @return able to use items * @return able to use items
*/ */
public boolean canUse(LocalPlayer player) { public boolean canUse(LocalPlayer player) {
@ -151,7 +151,7 @@ public boolean isMemberOfAll(LocalPlayer player) {
* @param flag flag to check * @param flag flag to check
* @param player null to not check owners and members * @param player null to not check owners and members
* @param groupPlayer player to use for the group flag check * @param groupPlayer player to use for the group flag check
* @return * @return the allow/deny state for the flag
*/ */
private boolean internalGetState(StateFlag flag, LocalPlayer player, private boolean internalGetState(StateFlag flag, LocalPlayer player,
LocalPlayer groupPlayer) { LocalPlayer groupPlayer) {
@ -275,16 +275,16 @@ private boolean internalGetState(StateFlag flag, LocalPlayer player,
found = true; found = true;
} }
return found == false ? def : return !found ? def :
(allowed || (player != null && needsClear.size() == 0)); (allowed || (player != null && needsClear.size() == 0));
} }
/** /**
* Clear a region's parents for isFlagAllowed(). * Clear a region's parents for isFlagAllowed().
* *
* @param needsClear * @param needsClear The regions that should be cleared
* @param hasCleared * @param hasCleared The regions already cleared
* @param region * @param region The region to start from
*/ */
private void clearParents(Set<ProtectedRegion> needsClear, private void clearParents(Set<ProtectedRegion> needsClear,
Set<ProtectedRegion> hasCleared, ProtectedRegion region) { Set<ProtectedRegion> hasCleared, ProtectedRegion region) {
@ -299,6 +299,11 @@ private void clearParents(Set<ProtectedRegion> needsClear,
} }
} }
/**
* @see #getFlag(com.sk89q.worldguard.protection.flags.Flag, com.sk89q.worldguard.LocalPlayer)
* @param flag flag to check
* @return value of the flag
*/
public <T extends Flag<V>, V> V getFlag(T flag) { public <T extends Flag<V>, V> V getFlag(T flag) {
return getFlag(flag, null); return getFlag(flag, null);
} }
@ -308,6 +313,7 @@ public <T extends Flag<V>, V> V getFlag(T flag) {
* (use {@link #allows(StateFlag, LocalPlayer)} for that). * (use {@link #allows(StateFlag, LocalPlayer)} for that).
* *
* @param flag flag to check * @param flag flag to check
* @param groupPlayer player to check {@link RegionGroup}s against
* @return value of the flag * @return value of the flag
* @throws IllegalArgumentException if a StateFlag is given * @throws IllegalArgumentException if a StateFlag is given
*/ */
@ -372,9 +378,9 @@ public <T extends Flag<V>, V> V getFlag(T flag, LocalPlayer groupPlayer) {
/** /**
* Clear a region's parents for getFlag(). * Clear a region's parents for getFlag().
* *
* @param needsClear * @param needsClear The regions that should be cleared
* @param hasCleared * @param hasCleared The regions already cleared
* @param region * @param region The region to start from
*/ */
private void clearParents(Map<ProtectedRegion, ?> needsClear, private void clearParents(Map<ProtectedRegion, ?> needsClear,
Set<ProtectedRegion> hasCleared, ProtectedRegion region) { Set<ProtectedRegion> hasCleared, ProtectedRegion region) {
@ -392,7 +398,7 @@ private void clearParents(Map<ProtectedRegion, ?> needsClear,
/** /**
* Get the number of regions that are included. * Get the number of regions that are included.
* *
* @return * @return the size of this ApplicbleRegionSet
*/ */
public int size() { public int size() {
return applicable.size(); return applicable.size();
@ -400,8 +406,6 @@ public int size() {
/** /**
* Get an iterator of affected regions. * Get an iterator of affected regions.
*
* @return
*/ */
public Iterator<ProtectedRegion> iterator() { public Iterator<ProtectedRegion> iterator() {
return applicable.iterator(); return applicable.iterator();

View File

@ -73,7 +73,7 @@ public class GlobalRegionManager {
/** /**
* Construct the object. * Construct the object.
* *
* @param plugin * @param plugin The plugin instance
*/ */
public GlobalRegionManager(WorldGuardPlugin plugin) { public GlobalRegionManager(WorldGuardPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
@ -93,8 +93,8 @@ public void unload() {
/** /**
* Get the path for a world's regions file. * Get the path for a world's regions file.
* *
* @param name * @param name The name of the world
* @return * @return The region file path for a world's region file
*/ */
protected File getPath(String name) { protected File getPath(String name) {
return new File(plugin.getDataFolder(), return new File(plugin.getDataFolder(),
@ -104,13 +104,12 @@ protected File getPath(String name) {
/** /**
* Unload region information for a world. * Unload region information for a world.
* *
* @param name * @param name The name of the world to unload
*/ */
public void unload(String name) { public void unload(String name) {
RegionManager manager = managers.get(name); RegionManager manager = managers.remove(name);
if (manager != null) { if (manager != null) {
managers.remove(name);
lastModified.remove(name); lastModified.remove(name);
} }
} }
@ -126,12 +125,12 @@ public void unloadAll() {
/** /**
* Load region information for a world. * Load region information for a world.
* *
* @param world * @param world The world to load a RegionManager for
* @return * @return the loaded RegionManager
*/ */
public RegionManager load(World world) { public RegionManager load(World world) {
String name = world.getName(); String name = world.getName();
ProtectionDatabase database = null; ProtectionDatabase database;
File file = null; File file = null;
try { try {
@ -209,7 +208,7 @@ public void reloadChanged() {
load(world); load(world);
} }
} }
} catch (Exception e) { } catch (Exception ignore) {
} }
} }
} }
@ -217,8 +216,8 @@ public void reloadChanged() {
/** /**
* Get the region manager for a particular world. * Get the region manager for a particular world.
* *
* @param world * @param world The world to get a RegionManager for
* @return * @return The region manager.
*/ */
public RegionManager get(World world) { public RegionManager get(World world) {
RegionManager manager = managers.get(world.getName()); RegionManager manager = managers.get(world.getName());
@ -233,9 +232,9 @@ public RegionManager get(World world) {
/** /**
* Returns whether the player can bypass. * Returns whether the player can bypass.
* *
* @param player * @param player The player to check
* @param world * @param world The world to check for
* @return * @return Whether {@code player} has bypass permission for {@code world}
*/ */
public boolean hasBypass(LocalPlayer player, World world) { public boolean hasBypass(LocalPlayer player, World world) {
return player.hasPermission("worldguard.region.bypass." return player.hasPermission("worldguard.region.bypass."
@ -245,21 +244,21 @@ public boolean hasBypass(LocalPlayer player, World world) {
/** /**
* Returns whether the player can bypass. * Returns whether the player can bypass.
* *
* @param player * @param player The player to check
* @param world * @param world The world to check
* @return * @return Whether {@code player} has bypass permission for {@code world}
*/ */
public boolean hasBypass(Player player, World world) { public boolean hasBypass(Player player, World world) {
return plugin.hasPermission(player, "worldguard.region.bypass." return plugin.hasPermission(player, "worldguard.region.bypass."
+ world.getName()); + world.getName());
} }
/** /**
* Check if a player has permission to build at a block. * Check if a player has permission to build at a block.
* *
* @param player * @param player The player to check
* @param block * @param block The block to check at
* @return * @return Whether {@code player} can build at {@code block}'s location
*/ */
public boolean canBuild(Player player, Block block) { public boolean canBuild(Player player, Block block) {
return canBuild(player, block.getLocation()); return canBuild(player, block.getLocation());
@ -268,9 +267,9 @@ public boolean canBuild(Player player, Block block) {
/** /**
* Check if a player has permission to build at a location. * Check if a player has permission to build at a location.
* *
* @param player * @param player The player to check
* @param loc * @param loc The location to check
* @return * @return Whether {@code player} can build at {@code loc}
*/ */
public boolean canBuild(Player player, Location loc) { public boolean canBuild(Player player, Location loc) {
World world = loc.getWorld(); World world = loc.getWorld();
@ -294,6 +293,14 @@ public boolean canBuild(Player player, Location loc) {
return true; return true;
} }
/**
* Checks to see whether a flag is allowed.
*
* @see #allows(com.sk89q.worldguard.protection.flags.StateFlag, org.bukkit.Location, com.sk89q.worldguard.LocalPlayer)
* @param flag The flag to check
* @param loc The location to check the flag at
* @return Whether the flag is allowed
*/
public boolean allows(StateFlag flag, Location loc) { public boolean allows(StateFlag flag, Location loc) {
return allows(flag, loc, null); return allows(flag, loc, null);
} }
@ -301,9 +308,10 @@ public boolean allows(StateFlag flag, Location loc) {
/** /**
* Checks to see whether a flag is allowed. * Checks to see whether a flag is allowed.
* *
* @param flag * @param flag The flag to check
* @param loc * @param loc The location to check the flag at
* @return * @param player The player to check for the flag's {@link com.sk89q.worldguard.protection.flags.RegionGroup}
* @return Whether the flag is allowed
*/ */
public boolean allows(StateFlag flag, Location loc, LocalPlayer player) { public boolean allows(StateFlag flag, Location loc, LocalPlayer player) {
World world = loc.getWorld(); World world = loc.getWorld();

View File

@ -78,7 +78,8 @@ public class CSVDatabase extends AbstractProtectionDatabase {
* Construct the database with a path to a file. No file is read or * Construct the database with a path to a file. No file is read or
* written at this time. * written at this time.
* *
* @param file * @param file The file in CSV format containing the region database
* @param logger The logger to log errors to
*/ */
public CSVDatabase(File file, Logger logger) { public CSVDatabase(File file, Logger logger) {
this.file = file; this.file = file;
@ -92,9 +93,6 @@ public void save() throws ProtectionDatabaseException {
throw new UnsupportedOperationException("CSV format is no longer implemented"); throw new UnsupportedOperationException("CSV format is no longer implemented");
} }
/**
* Load the database from file.
*/
public void load() throws ProtectionDatabaseException { public void load() throws ProtectionDatabaseException {
Map<String,ProtectedRegion> regions = Map<String,ProtectedRegion> regions =
new HashMap<String,ProtectedRegion>(); new HashMap<String,ProtectedRegion>();
@ -208,8 +206,8 @@ public void load() throws ProtectionDatabaseException {
/** /**
* Used to parse the specified domain in the CSV file. * Used to parse the specified domain in the CSV file.
* *
* @param data * @param data The domain data as a string
* @return * @return The domain data as a DefaultDomain
*/ */
private DefaultDomain parseDomains(String data) { private DefaultDomain parseDomains(String data) {
if (data == null) { if (data == null) {
@ -251,7 +249,7 @@ private DefaultDomain parseDomains(String data) {
/** /**
* Used to parse the list of flags. * Used to parse the list of flags.
* *
* @param data * @param data The flag data in string format
*/ */
private void parseFlags(ProtectedRegion region, String data) { private void parseFlags(ProtectedRegion region, String data) {
if (data == null) { if (data == null) {
@ -336,8 +334,8 @@ private String writeFlag(State state, String flag) {
/** /**
* Returns a null if a string is null or empty. * Returns a null if a string is null or empty.
* *
* @param str * @param str The string to format
* @return * @return null if the string is empty or null, otherwise the provided string
*/ */
protected String nullEmptyString(String str) { protected String nullEmptyString(String str) {
if (str == null) { if (str == null) {
@ -349,18 +347,10 @@ protected String nullEmptyString(String str) {
} }
} }
/**
* Get a list of protected regions.
*
* @return
*/
public Map<String,ProtectedRegion> getRegions() { public Map<String,ProtectedRegion> getRegions() {
return regions; return regions;
} }
/**
* Get a list of protected regions.
*/
public void setRegions(Map<String,ProtectedRegion> regions) { public void setRegions(Map<String,ProtectedRegion> regions) {
this.regions = regions; this.regions = regions;
} }

View File

@ -34,39 +34,39 @@ public interface ProtectionDatabase {
* Load the list of regions. The method should not modify the list returned * Load the list of regions. The method should not modify the list returned
* by getRegions() unless the load finishes successfully. * by getRegions() unless the load finishes successfully.
* *
* @throws ProtectionDatabaseException * @throws ProtectionDatabaseException when an error occurs
*/ */
public void load() throws ProtectionDatabaseException; public void load() throws ProtectionDatabaseException;
/** /**
* Save the list of regions. * Save the list of regions.
* *
* @throws ProtectionDatabaseException * @throws ProtectionDatabaseException when an error occurs
*/ */
public void save() throws ProtectionDatabaseException; public void save() throws ProtectionDatabaseException;
/** /**
* Load the list of regions into a region manager. * Load the list of regions into a region manager.
* *
* @param manager * @param manager The manager to load regions into
* @throws ProtectionDatabaseException * @throws ProtectionDatabaseException when an error occurs
*/ */
public void load(RegionManager manager) throws ProtectionDatabaseException; public void load(RegionManager manager) throws ProtectionDatabaseException;
/** /**
* Save the list of regions from a region manager. * Save the list of regions from a region manager.
* *
* @param manager * @param manager The manager to load regions into
* @throws ProtectionDatabaseException * @throws ProtectionDatabaseException when an error occurs
*/ */
public void save(RegionManager manager) throws ProtectionDatabaseException; public void save(RegionManager manager) throws ProtectionDatabaseException;
/** /**
* Get a list of regions. * Get a list of regions.
* *
* @return * @return the regions loaded by this ProtectionDatabase
*/ */
public Map<String,ProtectedRegion> getRegions(); public Map<String,ProtectedRegion> getRegions();
/** /**
* Set the list of regions. * Set the list of regions.
* *
* @param regions * @param regions The regions to be applied to this ProtectionDatabase
*/ */
public void setRegions(Map<String,ProtectedRegion> regions); public void setRegions(Map<String,ProtectedRegion> regions);
} }

View File

@ -32,18 +32,18 @@
* @author sk89q * @author sk89q
*/ */
public class RegionDBUtil { public class RegionDBUtil {
private static Pattern groupPattern = Pattern.compile("^[gG]:(.+)$"); private static Pattern groupPattern = Pattern.compile("(?i)^[G]:(.+)$");
private RegionDBUtil() { private RegionDBUtil() {
} }
/** /**
* Parse a group/player DefaultDomain specification for areas. * Add the given names to {@code domain}
* *
* @param domain * @param domain The domain to add to
* @param split * @param split The {@link String[]} containing names to add to {@code domain}
* @param startIndex * @param startIndex The beginning index in the array
*/ */
public static void addToDomain(DefaultDomain domain, String[] split, public static void addToDomain(DefaultDomain domain, String[] split,
int startIndex) { int startIndex) {
@ -59,11 +59,11 @@ public static void addToDomain(DefaultDomain domain, String[] split,
} }
/** /**
* Parse a group/player DefaultDomain specification for areas. * Remove the given names from {@code domain}
* *
* @param domain * @param domain The domain to remove from
* @param split * @param split The {@link String[]} containing names to remove from {@code domain}
* @param startIndex * @param startIndex The beginning index in the array
*/ */
public static void removeFromDomain(DefaultDomain domain, String[] split, public static void removeFromDomain(DefaultDomain domain, String[] split,
int startIndex) { int startIndex) {
@ -81,9 +81,9 @@ public static void removeFromDomain(DefaultDomain domain, String[] split,
/** /**
* Parse a group/player DefaultDomain specification for areas. * Parse a group/player DefaultDomain specification for areas.
* *
* @param split * @param split The array of names to add
* @param startIndex * @param startIndex The beginning index in the array
* @return * @return The resulting DefaultDomain
*/ */
public static DefaultDomain parseDomainString(String[] split, int startIndex) { public static DefaultDomain parseDomainString(String[] split, int startIndex) {
DefaultDomain domain = new DefaultDomain(); DefaultDomain domain = new DefaultDomain();
@ -104,8 +104,8 @@ public static DefaultDomain parseDomainString(String[] split, int startIndex) {
/** /**
* Creates a comma separated list of PreparedStatement place holders * Creates a comma separated list of PreparedStatement place holders
* *
* @param length * @param length The number of wildcards to create
* @return * @return A string with {@code length} wildcards for usage in a PreparedStatement
*/ */
public static String preparePlaceHolders(int length) { public static String preparePlaceHolders(int length) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -121,9 +121,9 @@ public static String preparePlaceHolders(int length) {
/** /**
* Adds all of the parsed values to the PreparedStatement * Adds all of the parsed values to the PreparedStatement
* *
* @param preparedStatement * @param preparedStatement The preparedStanement to add to
* @param values * @param values The values to set
* @throws SQLException * @throws SQLException see {@link PreparedStatement#setString(int, String)}
*/ */
public static void setValues(PreparedStatement preparedStatement, String... values) throws SQLException { public static void setValues(PreparedStatement preparedStatement, String... values) throws SQLException {
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {

View File

@ -49,46 +49,28 @@ public class FlatRegionManager extends RegionManager {
/** /**
* Construct the manager. * Construct the manager.
* *
* @param regionloader * @param regionLoader The loader for regions
*/ */
public FlatRegionManager(ProtectionDatabase regionloader) { public FlatRegionManager(ProtectionDatabase regionLoader) {
super(regionloader); super(regionLoader);
regions = new TreeMap<String, ProtectedRegion>(); regions = new TreeMap<String, ProtectedRegion>();
} }
/**
* Get a list of protected regions.
*
* @return
*/
@Override @Override
public Map<String, ProtectedRegion> getRegions() { public Map<String, ProtectedRegion> getRegions() {
return regions; return regions;
} }
/**
* Set a list of protected regions.
*/
@Override @Override
public void setRegions(Map<String, ProtectedRegion> regions) { public void setRegions(Map<String, ProtectedRegion> regions) {
this.regions = new TreeMap<String, ProtectedRegion>(regions); this.regions = new TreeMap<String, ProtectedRegion>(regions);
} }
/**
* Adds a region.
*
* @param region
*/
@Override @Override
public void addRegion(ProtectedRegion region) { public void addRegion(ProtectedRegion region) {
regions.put(region.getId().toLowerCase(), region); regions.put(region.getId().toLowerCase(), region);
} }
/**
* Removes a region and its children.
*
* @param id
*/
@Override @Override
public void removeRegion(String id) { public void removeRegion(String id) {
ProtectedRegion region = regions.get(id.toLowerCase()); ProtectedRegion region = regions.get(id.toLowerCase());
@ -110,33 +92,16 @@ public void removeRegion(String id) {
} }
} }
/**
* Return whether a region exists by an ID.
*
* @param id
* @return
*/
@Override @Override
public boolean hasRegion(String id) { public boolean hasRegion(String id) {
return regions.containsKey(id.toLowerCase()); return regions.containsKey(id.toLowerCase());
} }
/**
* Get a region by its ID.
*
* @param id
*/
@Override @Override
public ProtectedRegion getRegion(String id) { public ProtectedRegion getRegion(String id) {
return regions.get(id.toLowerCase()); return regions.get(id.toLowerCase());
} }
/**
* Get an object for a point for rules to be applied with.
*
* @param pt
* @return
*/
@Override @Override
public ApplicableRegionSet getApplicableRegions(Vector pt) { public ApplicableRegionSet getApplicableRegions(Vector pt) {
TreeSet<ProtectedRegion> appRegions = TreeSet<ProtectedRegion> appRegions =
@ -182,12 +147,6 @@ public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
return new ApplicableRegionSet(intersectRegions, regions.get("__global__")); return new ApplicableRegionSet(intersectRegions, regions.get("__global__"));
}*/ }*/
/**
* Get a list of region IDs that contain a point.
*
* @param pt
* @return
*/
@Override @Override
public List<String> getApplicableRegionsIDs(Vector pt) { public List<String> getApplicableRegionsIDs(Vector pt) {
List<String> applicable = new ArrayList<String>(); List<String> applicable = new ArrayList<String>();
@ -201,11 +160,6 @@ public List<String> getApplicableRegionsIDs(Vector pt) {
return applicable; return applicable;
} }
/**
* Get an object for a region for rules to be applied with.
*
* @return
*/
@Override @Override
public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) { public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
@ -223,13 +177,6 @@ public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
return new ApplicableRegionSet(intersectRegions, regions.get("__global__")); return new ApplicableRegionSet(intersectRegions, regions.get("__global__"));
} }
/**
* Returns true if the provided region overlaps with any other region that
* is not owned by the player.
*
* @param player
* @return
*/
@Override @Override
public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer player) { public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer player) {
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>(); List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
@ -252,11 +199,6 @@ public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer pl
return intersectRegions.size() > 0; return intersectRegions.size() > 0;
} }
/**
* Get the number of regions.
*
* @return
*/
@Override @Override
public int size() { public int size() {
return regions.size(); return regions.size();

View File

@ -18,10 +18,8 @@
*/ */
package com.sk89q.worldguard.protection.managers; package com.sk89q.worldguard.protection.managers;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
@ -56,29 +54,21 @@ public class PRTreeRegionManager extends RegionManager {
/** /**
* Construct the manager. * Construct the manager.
* *
* @param regionloader * @param regionLoader The region loader to use
* @throws IOException * @throws ProtectionDatabaseException when an error occurs while loading
*/ */
public PRTreeRegionManager(ProtectionDatabase regionloader) throws ProtectionDatabaseException { public PRTreeRegionManager(ProtectionDatabase regionLoader) throws ProtectionDatabaseException {
super(regionloader); super(regionLoader);
regions = new TreeMap<String, ProtectedRegion>(); regions = new TreeMap<String, ProtectedRegion>();
tree = new PRTree<ProtectedRegion>(converter, BRANCH_FACTOR); tree = new PRTree<ProtectedRegion>(converter, BRANCH_FACTOR);
this.load(); this.load();
} }
/**
* Get a list of protected regions.
*
* @return
*/
@Override @Override
public Map<String, ProtectedRegion> getRegions() { public Map<String, ProtectedRegion> getRegions() {
return regions; return regions;
} }
/**
* Set a list of protected regions.
*/
@Override @Override
public void setRegions(Map<String, ProtectedRegion> regions) { public void setRegions(Map<String, ProtectedRegion> regions) {
this.regions = new TreeMap<String, ProtectedRegion>(regions); this.regions = new TreeMap<String, ProtectedRegion>(regions);
@ -86,11 +76,6 @@ public void setRegions(Map<String, ProtectedRegion> regions) {
tree.load(regions.values()); tree.load(regions.values());
} }
/**
* Adds a region.
*
* @param region
*/
@Override @Override
public void addRegion(ProtectedRegion region) { public void addRegion(ProtectedRegion region) {
regions.put(region.getId().toLowerCase(), region); regions.put(region.getId().toLowerCase(), region);
@ -98,32 +83,16 @@ public void addRegion(ProtectedRegion region) {
tree.load(regions.values()); tree.load(regions.values());
} }
/**
* Return whether a region exists by an ID.
*
* @param id
* @return
*/
@Override @Override
public boolean hasRegion(String id) { public boolean hasRegion(String id) {
return regions.containsKey(id.toLowerCase()); return regions.containsKey(id.toLowerCase());
} }
/**
* Get a region by its ID.
*
* @param id
*/
@Override @Override
public ProtectedRegion getRegion(String id) { public ProtectedRegion getRegion(String id) {
return regions.get(id.toLowerCase()); return regions.get(id.toLowerCase());
} }
/**
* Removes a region and its children.
*
* @param id
*/
@Override @Override
public void removeRegion(String id) { public void removeRegion(String id) {
ProtectedRegion region = regions.get(id.toLowerCase()); ProtectedRegion region = regions.get(id.toLowerCase());
@ -132,9 +101,7 @@ public void removeRegion(String id) {
if (region != null) { if (region != null) {
List<String> removeRegions = new ArrayList<String>(); List<String> removeRegions = new ArrayList<String>();
Iterator<ProtectedRegion> iter = regions.values().iterator(); for (ProtectedRegion curRegion : regions.values()) {
while (iter.hasNext()) {
ProtectedRegion curRegion = iter.next();
if (curRegion.getParent() == region) { if (curRegion.getParent() == region) {
removeRegions.add(curRegion.getId().toLowerCase()); removeRegions.add(curRegion.getId().toLowerCase());
} }
@ -149,12 +116,6 @@ public void removeRegion(String id) {
tree.load(regions.values()); tree.load(regions.values());
} }
/**
* Get an object for a point for rules to be applied with.
*
* @param pt
* @return
*/
@Override @Override
public ApplicableRegionSet getApplicableRegions(Vector pt) { public ApplicableRegionSet getApplicableRegions(Vector pt) {
List<ProtectedRegion> appRegions = List<ProtectedRegion> appRegions =
@ -189,12 +150,6 @@ public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
return new ApplicableRegionSet(intersectRegions, regions.get("__global__")); return new ApplicableRegionSet(intersectRegions, regions.get("__global__"));
} }
/**
* Get a list of region IDs that contain a point.
*
* @param pt
* @return
*/
@Override @Override
public List<String> getApplicableRegionsIDs(Vector pt) { public List<String> getApplicableRegionsIDs(Vector pt) {
List<String> applicable = new ArrayList<String>(); List<String> applicable = new ArrayList<String>();
@ -211,13 +166,6 @@ public List<String> getApplicableRegionsIDs(Vector pt) {
return applicable; return applicable;
} }
/**
* Returns true if the provided region overlaps with any other region that
* is not owned by the player.
*
* @param player
* @return
*/
@Override @Override
public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer player) { public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer player) {
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>(); List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
@ -240,11 +188,6 @@ public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer pl
return intersectRegions.size() > 0; return intersectRegions.size() > 0;
} }
/**
* Get the number of regions.
*
* @return
*/
@Override @Override
public int size() { public int size() {
return regions.size(); return regions.size();

View File

@ -45,7 +45,7 @@ public abstract class RegionManager {
/** /**
* Construct the object. * Construct the object.
* *
* @param loader * @param loader The loader for this region
*/ */
public RegionManager(ProtectionDatabase loader) { public RegionManager(ProtectionDatabase loader) {
this.loader = loader; this.loader = loader;
@ -55,7 +55,7 @@ public RegionManager(ProtectionDatabase loader) {
* Load the list of regions. If the regions do not load properly, then * Load the list of regions. If the regions do not load properly, then
* the existing list should be used (as stored previously). * the existing list should be used (as stored previously).
* *
* @throws IOException thrown on load error * @throws ProtectionDatabaseException when an error occurs
*/ */
public void load() throws ProtectionDatabaseException { public void load() throws ProtectionDatabaseException {
loader.load(this); loader.load(this);
@ -64,7 +64,7 @@ public void load() throws ProtectionDatabaseException {
/** /**
* Save the list of regions. * Save the list of regions.
* *
* @throws IOException thrown on save eIf checking multiple flags for a single locationror * @throws ProtectionDatabaseException when an error occurs while saving
*/ */
public void save() throws ProtectionDatabaseException { public void save() throws ProtectionDatabaseException {
loader.save(this); loader.save(this);

View File

@ -36,9 +36,9 @@ public class ProtectedCuboidRegion extends ProtectedRegion {
/** /**
* Construct a new instance of this cuboid region. * Construct a new instance of this cuboid region.
* *
* @param id * @param id The region id
* @param pt1 * @param pt1 The first point of this region
* @param pt2 * @param pt2 The second point of this region
*/ */
public ProtectedCuboidRegion(String id, BlockVector pt1, BlockVector pt2) { public ProtectedCuboidRegion(String id, BlockVector pt1, BlockVector pt2) {
super(id); super(id);
@ -48,8 +48,8 @@ public ProtectedCuboidRegion(String id, BlockVector pt1, BlockVector pt2) {
/** /**
* Given any two points, sets the minimum and maximum points * Given any two points, sets the minimum and maximum points
* *
* @param pt1 * @param pt1 The first point of this region
* @param pt2 * @param pt2 The second point of this region
*/ */
private void setMinMaxPoints(BlockVector pt1, BlockVector pt2) { private void setMinMaxPoints(BlockVector pt1, BlockVector pt2) {
List<Vector> points = new ArrayList<Vector>(); List<Vector> points = new ArrayList<Vector>();
@ -61,7 +61,7 @@ private void setMinMaxPoints(BlockVector pt1, BlockVector pt2) {
/** /**
* Set the lower point of the cuboid. * Set the lower point of the cuboid.
* *
* @param pt * @param pt The point to set as the minimum point
*/ */
public void setMinimumPoint(BlockVector pt) { public void setMinimumPoint(BlockVector pt) {
setMinMaxPoints(pt, max); setMinMaxPoints(pt, max);
@ -70,7 +70,7 @@ public void setMinimumPoint(BlockVector pt) {
/** /**
* Set the upper point of the cuboid. * Set the upper point of the cuboid.
* *
* @param pt * @param pt The point to set as the maximum point
*/ */
public void setMaximumPoint(BlockVector pt) { public void setMaximumPoint(BlockVector pt) {
setMinMaxPoints(min, pt); setMinMaxPoints(min, pt);
@ -91,9 +91,6 @@ public List<BlockVector2D> getPoints() {
return pts; return pts;
} }
/**
* Checks to see if a point is inside this region.
*/
@Override @Override
public boolean contains(Vector pt) { public boolean contains(Vector pt) {
final double x = pt.getX(); final double x = pt.getX();
@ -157,29 +154,17 @@ public List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> region
return intersectingRegions; return intersectingRegions;
} }
/**
* Return the type of region as a user-friendly name.
*
* @return type of region
*/
@Override @Override
public String getTypeName() { public String getTypeName() {
return "cuboid"; return "cuboid";
} }
/**
* Get the number of Blocks in this region
*
* @return
*/
@Override @Override
public int volume() { public int volume() {
int xLength = max.getBlockX() - min.getBlockX() + 1; int xLength = max.getBlockX() - min.getBlockX() + 1;
int yLength = max.getBlockY() - min.getBlockY() + 1; int yLength = max.getBlockY() - min.getBlockY() + 1;
int zLength = max.getBlockZ() - min.getBlockZ() + 1; int zLength = max.getBlockZ() - min.getBlockZ() + 1;
int volume = xLength * yLength * zLength; return xLength * yLength * zLength;
return volume;
} }
} }

View File

@ -42,9 +42,9 @@ public ProtectedPolygonalRegion(String id, List<BlockVector2D> points, int minY,
/** /**
* Sets the min and max points from all the 2d points and the min/max Y values * Sets the min and max points from all the 2d points and the min/max Y values
* *
* @param points2D * @param points2D A {@link List} of points that this region should contain
* @param minY * @param minY The minimum y coordinate
* @param maxY * @param maxY The maximum y coordinate
*/ */
private void setMinMaxPoints(List<BlockVector2D> points2D, int minY, int maxY) { private void setMinMaxPoints(List<BlockVector2D> points2D, int minY, int maxY) {
List<Vector> points = new ArrayList<Vector>(); List<Vector> points = new ArrayList<Vector>();
@ -156,11 +156,6 @@ public String getTypeName() {
return "polygon"; return "polygon";
} }
/**
* Get the number of Blocks in this region
*
* @return
*/
@Override @Override
public int volume() { public int volume() {
int volume = 0; int volume = 0;

View File

@ -78,7 +78,7 @@ public abstract class ProtectedRegion implements Comparable<ProtectedRegion> {
/** /**
* Construct a new instance of this region. * Construct a new instance of this region.
* *
* @param id * @param id The id (name) of this region.
*/ */
public ProtectedRegion(String id) { public ProtectedRegion(String id) {
this.id = id; this.id = id;
@ -87,7 +87,7 @@ public ProtectedRegion(String id) {
/** /**
* Sets the minimum and maximum points of the bounding box for a region * Sets the minimum and maximum points of the bounding box for a region
* *
* @param points * @param points The points to set. Must have at least one element.
*/ */
protected void setMinMaxPoints(List<Vector> points) { protected void setMinMaxPoints(List<Vector> points) {
int minX = points.get(0).getBlockX(); int minX = points.get(0).getBlockX();
@ -116,6 +116,8 @@ protected void setMinMaxPoints(List<Vector> points) {
} }
/** /**
* Gets the id of this region
*
* @return the id * @return the id
*/ */
public String getId() { public String getId() {
@ -166,7 +168,7 @@ public ProtectedRegion getParent() {
* in circular inheritance. * in circular inheritance.
* *
* @param parent the curParent to setFlag * @param parent the curParent to setFlag
* @throws CircularInheritanceException * @throws CircularInheritanceException when circular inheritance is detected
*/ */
public void setParent(ProtectedRegion parent) throws CircularInheritanceException { public void setParent(ProtectedRegion parent) throws CircularInheritanceException {
if (parent == null) { if (parent == null) {
@ -303,9 +305,9 @@ public boolean isMemberOnly(LocalPlayer player) {
/** /**
* Get a flag's value. * Get a flag's value.
* *
* @param <T> * @param <T> The flag type
* @param <V> * @param <V> The type of the flag's value
* @param flag * @param flag The flag to check
* @return value or null if isn't defined * @return value or null if isn't defined
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -323,10 +325,10 @@ public <T extends Flag<V>, V> V getFlag(T flag) {
/** /**
* Set a flag's value. * Set a flag's value.
* *
* @param <T> * @param <T> The flag type
* @param <V> * @param <V> The type of the flag's value
* @param flag * @param flag The flag to check
* @param val * @param val The value to set
*/ */
public <T extends Flag<V>, V> void setFlag(T flag, V val) { public <T extends Flag<V>, V> void setFlag(T flag, V val) {
if (val == null) { if (val == null) {
@ -339,7 +341,7 @@ public <T extends Flag<V>, V> void setFlag(T flag, V val) {
/** /**
* Get the map of flags. * Get the map of flags.
* *
* @return * @return The map of flags currently used for this region
*/ */
public Map<Flag<?>, Object> getFlags() { public Map<Flag<?>, Object> getFlags() {
return flags; return flags;
@ -348,7 +350,7 @@ public Map<Flag<?>, Object> getFlags() {
/** /**
* Get the map of flags. * Get the map of flags.
* *
* @param flags * @param flags The flags to set
*/ */
public void setFlags(Map<Flag<?>, Object> flags) { public void setFlags(Map<Flag<?>, Object> flags) {
this.flags = flags; this.flags = flags;
@ -357,30 +359,30 @@ public void setFlags(Map<Flag<?>, Object> flags) {
/** /**
* Gets the 2D points for this region * Gets the 2D points for this region
* *
* @return * @return The points for this region as (x, z) coordinates
*/ */
public abstract List<BlockVector2D> getPoints(); public abstract List<BlockVector2D> getPoints();
/** /**
* Get the number of blocks in this region * Get the number of blocks in this region
* *
* @return * @return the volume of this region in blocks
*/ */
public abstract int volume(); public abstract int volume();
/** /**
* Check to see if a point is inside this region. * Check to see if a point is inside this region.
* *
* @param pt * @param pt The point to check
* @return * @return Whether {@code pt} is in this region
*/ */
public abstract boolean contains(Vector pt); public abstract boolean contains(Vector pt);
/** /**
* Check to see if a point is inside this region. * Check to see if a point is inside this region.
* *
* @param pt * @param pt The point to check
* @return * @return Whether {@code pt} is in this region
*/ */
public boolean contains(BlockVector2D pt) { public boolean contains(BlockVector2D pt) {
return contains(new Vector(pt.getBlockX(), min.getBlockY(), pt.getBlockZ())); return contains(new Vector(pt.getBlockX(), min.getBlockY(), pt.getBlockZ()));
@ -389,10 +391,10 @@ public boolean contains(BlockVector2D pt) {
/** /**
* Check to see if a point is inside this region. * Check to see if a point is inside this region.
* *
* @param x * @param x The x coordinate to check
* @param y * @param y The y coordinate to check
* @param z * @param z The z coordinate to check
* @return * @return Whether this region contains the points at the given coordinate
*/ */
public boolean contains(int x, int y, int z) { public boolean contains(int x, int y, int z) {
return contains(new Vector(x, y, z)); return contains(new Vector(x, y, z));
@ -419,8 +421,7 @@ public boolean containsAny(List<BlockVector2D> pts) {
* Orders primarily by the priority, descending<br> * Orders primarily by the priority, descending<br>
* Orders secondarily by the id, ascending * Orders secondarily by the id, ascending
* *
* @param other * @param other The region to compare to
* @return
*/ */
public int compareTo(ProtectedRegion other) { public int compareTo(ProtectedRegion other) {
if (priority > other.priority) { if (priority > other.priority) {
@ -442,9 +443,9 @@ public int compareTo(ProtectedRegion other) {
/** /**
* Get a list of intersecting regions. * Get a list of intersecting regions.
* *
* @param regions * @param regions The list of regions to source from
* @return * @return The elements of {@code regions} that intersect with this region
* @throws UnsupportedIntersectionException * @throws UnsupportedIntersectionException if an invalid intersection is detected
*/ */
public abstract List<ProtectedRegion> getIntersectingRegions( public abstract List<ProtectedRegion> getIntersectingRegions(
List<ProtectedRegion> regions) List<ProtectedRegion> regions)
@ -454,7 +455,8 @@ public abstract List<ProtectedRegion> getIntersectingRegions(
* Checks if the bounding box of a region intersects with with the bounding * Checks if the bounding box of a region intersects with with the bounding
* box of this region * box of this region
* *
* @param region * @param region The region to check
* @return whether the given region intersects
*/ */
protected boolean intersectsBoundingBox(ProtectedRegion region) { protected boolean intersectsBoundingBox(ProtectedRegion region) {
BlockVector rMaxPoint = region.getMaximumPoint(); BlockVector rMaxPoint = region.getMaximumPoint();
@ -477,8 +479,8 @@ protected boolean intersectsBoundingBox(ProtectedRegion region) {
/** /**
* Compares all edges of two regions to see if any of them intersect * Compares all edges of two regions to see if any of them intersect
* *
* @param region * @param region The region to check
* @return * @return whether any edges of a region intersect
*/ */
protected boolean intersectsEdges(ProtectedRegion region) { protected boolean intersectsEdges(ProtectedRegion region) {
List<BlockVector2D> pts1 = getPoints(); List<BlockVector2D> pts1 = getPoints();
@ -511,16 +513,14 @@ protected boolean intersectsEdges(ProtectedRegion region) {
/** /**
* Checks to see if the given ID is accurate. * Checks to see if the given ID is accurate.
* *
* @param id * @param id The id to check
* @return * @see #idPattern
* @return Whether the region id given is valid
*/ */
public static boolean isValidId(String id) { public static boolean isValidId(String id) {
return idPattern.matcher(id).matches(); return idPattern.matcher(id).matches();
} }
/**
* Returns the hash code.
*/
@Override @Override
public int hashCode(){ public int hashCode(){
return id.hashCode(); return id.hashCode();
@ -542,7 +542,6 @@ public boolean equals(Object obj) {
/** /**
* Thrown when setting a curParent would create a circular inheritance * Thrown when setting a curParent would create a circular inheritance
* situation. * situation.
*
*/ */
public static class CircularInheritanceException extends Exception { public static class CircularInheritanceException extends Exception {
private static final long serialVersionUID = 7479613488496776022L; private static final long serialVersionUID = 7479613488496776022L;

View File

@ -25,17 +25,24 @@ public class ArrayReader<T> {
public ArrayReader(T[] arr) { public ArrayReader(T[] arr) {
this.arr = arr; this.arr = arr;
} }
/**
* Gets an element from the array
* @param index The index to get an element at
* @return The element at {@code index} if the index is within bounds, otherwise null
*/
public T get(int index) { public T get(int index) {
if (arr.length > index) { return get(index, null);
return arr[index];
} else {
return null;
}
} }
/**
* Gets an element from the array
* @param index The index to get an element at
* @param def the default value, used when the given index is out of bounds
* @return The element at {@code index} if the index is within bounds, otherwise the default value
*/
public T get(int index, T def) { public T get(int index, T def) {
if (arr.length > index) { if (index >= 0 && arr.length > index) {
return arr[index]; return arr[index];
} else { } else {
return def; return def;

View File

@ -1,41 +0,0 @@
/*
* WorldGuard
* Copyright (C) 2011 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.util;
import java.lang.reflect.Field;
/**
* @author zml2008
*/
public class ReflectionUtil {
@SuppressWarnings("unchecked")
public static <T> T getField(Object from, String name) {
Class<?> checkClass = from.getClass();
do {
try {
Field field = checkClass.getDeclaredField(name);
field.setAccessible(true);
return (T) field.get(from);
} catch (NoSuchFieldException e) {
} catch (IllegalAccessException e) {
}
} while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null));
return null;
}
}

View File

@ -19,83 +19,58 @@
package com.sk89q.worldguard.util; package com.sk89q.worldguard.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.sk89q.worldguard.domains.DefaultDomain; import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.databases.RegionDBUtil;
/** /**
* Various utility functions for regions. * Various utility functions for regions.
* *
* @author sk89q * @author sk89q
*/ */
@Deprecated
public class RegionUtil { public class RegionUtil {
private static Pattern groupPattern = Pattern.compile("^[gG]:(.+)$");
private RegionUtil() { private RegionUtil() {
} }
/** /**
* Parse a group/player DefaultDomain specification for areas. * Parse a group/player DefaultDomain specification for areas.
* *
* @param domain * @param domain The domain
* @param split * @param split The arguments
* @param startIndex * @param startIndex The index to start at
* @deprecated see {@link RegionDBUtil#addToDomain(com.sk89q.worldguard.domains.DefaultDomain, String[], int)}
*/ */
@Deprecated
public static void addToDomain(DefaultDomain domain, String[] split, public static void addToDomain(DefaultDomain domain, String[] split,
int startIndex) { int startIndex) {
for (int i = startIndex; i < split.length; i++) { RegionDBUtil.addToDomain(domain, split, startIndex);
String s = split[i];
Matcher m = groupPattern.matcher(s);
if (m.matches()) {
domain.addGroup(m.group(1));
} else {
domain.addPlayer(s);
}
}
} }
/** /**
* Parse a group/player DefaultDomain specification for areas. * Parse a group/player DefaultDomain specification for areas.
* *
* @param domain * @param domain The domain to add to
* @param split * @param split The arguments
* @param startIndex * @param startIndex The index to start at
* @deprecated see {@link RegionDBUtil#removeFromDomain(com.sk89q.worldguard.domains.DefaultDomain, String[], int)}
*/ */
@Deprecated
public static void removeFromDomain(DefaultDomain domain, String[] split, public static void removeFromDomain(DefaultDomain domain, String[] split,
int startIndex) { int startIndex) {
for (int i = startIndex; i < split.length; i++) { RegionDBUtil.removeFromDomain(domain, split, startIndex);
String s = split[i];
Matcher m = groupPattern.matcher(s);
if (m.matches()) {
domain.removeGroup(m.group(1));
} else {
domain.removePlayer(s);
}
}
} }
/** /**
* Parse a group/player DefaultDomain specification for areas. * Parse a group/player DefaultDomain specification for areas.
* *
* @param split * @param split The arguments
* @param startIndex * @param startIndex The index to start at
* @return * @deprecated see {@link RegionDBUtil#parseDomainString(String[], int)}
* @return the parsed domain
*/ */
@Deprecated
public static DefaultDomain parseDomainString(String[] split, int startIndex) { public static DefaultDomain parseDomainString(String[] split, int startIndex) {
DefaultDomain domain = new DefaultDomain(); return RegionDBUtil.parseDomainString(split, startIndex);
for (int i = startIndex; i < split.length; i++) {
String s = split[i];
Matcher m = groupPattern.matcher(s);
if (m.matches()) {
domain.addGroup(m.group(1));
} else {
domain.addPlayer(s);
}
}
return domain;
} }
} }