diff --git a/src/main/java/com/sk89q/worldguard/blacklist/Blacklist.java b/src/main/java/com/sk89q/worldguard/blacklist/Blacklist.java index 11aa5814..74bab4b2 100644 --- a/src/main/java/com/sk89q/worldguard/blacklist/Blacklist.java +++ b/src/main/java/com/sk89q/worldguard/blacklist/Blacklist.java @@ -45,7 +45,7 @@ public abstract class Blacklist { * Logger. */ private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard"); - + /** * List of entries by block ID. */ @@ -73,7 +73,7 @@ public Blacklist(Boolean useAsWhitelist) { /** * Returns whether the list is empty. - * + * * @return */ public boolean isEmpty() { @@ -82,35 +82,35 @@ public boolean isEmpty() { /** * Get the entries for an item or list. - * - * @param id - * @return + * + * @param id + * @return */ public List getEntries(int id) { return blacklist.get(id); } - + /** * Get the number of individual items that have blacklist entries. - * + * * @return */ public int getItemCount() { return blacklist.size(); } - + /** * Returns whether the blacklist is used as a whitelist. - * + * * @return */ public boolean isWhitelist() { return useAsWhitelist; } - + /** * Get the logger. - * + * * @return */ public BlacklistLogger getLogger() { @@ -119,7 +119,7 @@ public BlacklistLogger getLogger() { /** * Method to handle the event. - * + * * @param event * @param forceRepeat * @param silent @@ -253,36 +253,36 @@ public void load(File file) throws IOException { } } } - + /** * Get the last event. - * + * * @return */ public BlacklistEvent getLastEvent() { return lastEvent; } - + /** * Notify administrators. - * + * * @param event - * @param comment + * @param comment */ public void notify(BlacklistEvent event, String comment) { lastEvent = event; - - broadcastNotification(ChatColor.GRAY + "WG: " + + broadcastNotification(ChatColor.GRAY + "WG: " + ChatColor.LIGHT_PURPLE + event.getPlayer().getName() + ChatColor.GOLD + " (" + event.getDescription() + ") " + ChatColor.WHITE + getFriendlyItemName(event.getType()) + (comment != null ? " (" + comment + ")" : "") + "."); } - + /** * Sends a notification to all subscribing users. - * + * * @param msg */ public abstract void broadcastNotification(String msg); @@ -305,7 +305,7 @@ public void forgetAllPlayers() { /** * Get an item's ID from its name. - * + * * @param name */ private static int getItemID(String name) { @@ -319,7 +319,7 @@ private static int getItemID(String name) { /** * Get an item's friendly name with its ID. - * + * * @param id */ private static String getFriendlyItemName(int id) { diff --git a/src/main/java/com/sk89q/worldguard/blacklist/BlacklistEntry.java b/src/main/java/com/sk89q/worldguard/blacklist/BlacklistEntry.java index cc2fda7f..122cd769 100644 --- a/src/main/java/com/sk89q/worldguard/blacklist/BlacklistEntry.java +++ b/src/main/java/com/sk89q/worldguard/blacklist/BlacklistEntry.java @@ -54,7 +54,7 @@ public class BlacklistEntry { * List of permissions to not affect. */ private Set ignorePermissions; - + private String[] breakActions; private String[] destroyWithActions; private String[] placeActions; @@ -62,13 +62,13 @@ public class BlacklistEntry { private String[] useActions; private String[] dropActions; private String[] acquireActions; - + private String message; private String comment; /** * Construct the object. - * + * * @param blacklist */ public BlacklistEntry(Blacklist blacklist) { @@ -262,35 +262,35 @@ public boolean shouldIgnore(LocalPlayer player) { return false; } - + /** * Get the associated actions with an event. - * + * * @param event * @return */ private String[] getActions(BlacklistEvent event) { if (event instanceof BlockBreakBlacklistEvent) { return breakActions; - + } else if (event instanceof BlockPlaceBlacklistEvent) { return placeActions; - + } else if (event instanceof BlockInteractBlacklistEvent) { return interactActions; - + } else if (event instanceof DestroyWithBlacklistEvent) { return destroyWithActions; - + } else if (event instanceof ItemAcquireBlacklistEvent) { return acquireActions; - + } else if (event instanceof ItemDropBlacklistEvent) { return dropActions; - + } else if (event instanceof ItemUseBlacklistEvent) { return useActions; - + } else { return null; } @@ -298,8 +298,8 @@ private String[] getActions(BlacklistEvent event) { /** * Method to handle the event. - * - * @param useAsWhitelist + * + * @param useAsWhitelist * @param event * @param forceRepeat * @param silent @@ -307,7 +307,7 @@ private String[] getActions(BlacklistEvent event) { */ public boolean check(boolean useAsWhitelist, BlacklistEvent event, boolean forceRepeat, boolean silent) { LocalPlayer player = event.getPlayer(); - + if (shouldIgnore(player)) { return true; } @@ -328,21 +328,21 @@ public boolean check(boolean useAsWhitelist, BlacklistEvent event, boolean force String actions[] = getActions(event); - + boolean ret = useAsWhitelist ? false : true; - + // Nothing to do if (actions == null) { return useAsWhitelist ? false : true; } - + for (String action : actions) { // Deny if (action.equalsIgnoreCase("deny")) { if (silent) { return false; } - + ret = false; // Allow @@ -358,7 +358,7 @@ public boolean check(boolean useAsWhitelist, BlacklistEvent event, boolean force if (silent) { continue; } - + if (this.message != null) { player.kick(String.format(this.message, getFriendlyItemName(event.getType()))); @@ -372,7 +372,7 @@ public boolean check(boolean useAsWhitelist, BlacklistEvent event, boolean force if (silent) { continue; } - + if (this.message != null) { player.ban("Banned: " + String.format(this.message, getFriendlyItemName(event.getType()))); @@ -381,12 +381,12 @@ public boolean check(boolean useAsWhitelist, BlacklistEvent event, boolean force + event.getDescription() + " " + getFriendlyItemName(event.getType())); } - + } else if (!silent && (!repeating || forceRepeat)) { // Notify if (action.equalsIgnoreCase("notify")) { blacklist.notify(event, comment); - + // Log } else if (action.equalsIgnoreCase("log")) { blacklist.getLogger().logEvent(event, comment); @@ -411,7 +411,7 @@ public boolean check(boolean useAsWhitelist, BlacklistEvent event, boolean force /** * Get an item's friendly name with its ID. - * + * * @param id */ private static String getFriendlyItemName(int id) { diff --git a/src/main/java/com/sk89q/worldguard/blacklist/BlacklistLogger.java b/src/main/java/com/sk89q/worldguard/blacklist/BlacklistLogger.java index 9c330e9b..8409489e 100644 --- a/src/main/java/com/sk89q/worldguard/blacklist/BlacklistLogger.java +++ b/src/main/java/com/sk89q/worldguard/blacklist/BlacklistLogger.java @@ -60,7 +60,7 @@ public void removeHandler(BlacklistLoggerHandler handler) { public void clearHandlers() { handlers.clear(); } - + /** * Log an event. * diff --git a/src/main/java/com/sk89q/worldguard/blacklist/BlacklistTrackedEvent.java b/src/main/java/com/sk89q/worldguard/blacklist/BlacklistTrackedEvent.java index cc7979b8..c6f08cf9 100644 --- a/src/main/java/com/sk89q/worldguard/blacklist/BlacklistTrackedEvent.java +++ b/src/main/java/com/sk89q/worldguard/blacklist/BlacklistTrackedEvent.java @@ -31,8 +31,8 @@ public class BlacklistTrackedEvent { /** * Construct the object. - * - * @param event + * + * @param event * @param time */ public BlacklistTrackedEvent(BlacklistEvent event, long time) { diff --git a/src/main/java/com/sk89q/worldguard/blacklist/loggers/BlacklistLoggerHandler.java b/src/main/java/com/sk89q/worldguard/blacklist/loggers/BlacklistLoggerHandler.java index b9582b48..4113f721 100644 --- a/src/main/java/com/sk89q/worldguard/blacklist/loggers/BlacklistLoggerHandler.java +++ b/src/main/java/com/sk89q/worldguard/blacklist/loggers/BlacklistLoggerHandler.java @@ -34,7 +34,7 @@ public interface BlacklistLoggerHandler { * @param comment */ public void logEvent(BlacklistEvent event, String comment); - + /** * Close the logger. */ diff --git a/src/main/java/com/sk89q/worldguard/blacklist/loggers/ConsoleLoggerHandler.java b/src/main/java/com/sk89q/worldguard/blacklist/loggers/ConsoleLoggerHandler.java index 5212dfb4..ca0c8d6c 100644 --- a/src/main/java/com/sk89q/worldguard/blacklist/loggers/ConsoleLoggerHandler.java +++ b/src/main/java/com/sk89q/worldguard/blacklist/loggers/ConsoleLoggerHandler.java @@ -41,13 +41,13 @@ public class ConsoleLoggerHandler implements BlacklistLoggerHandler { * Logger. */ private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard"); - - + + private String worldName; - + public ConsoleLoggerHandler(String worldName) { - this.worldName = worldName; + this.worldName = worldName; } /** @@ -62,49 +62,49 @@ public void logEvent(BlacklistEvent event, String comment) { logger.log(Level.INFO, "WorldGuard: [" + worldName + "] " + event.getPlayer().getName() + " tried to break " + getFriendlyItemName(evt.getType()) + (comment != null ? " (" + comment + ")" : "")); - + // Block place } else if (event instanceof BlockPlaceBlacklistEvent) { BlockPlaceBlacklistEvent evt = (BlockPlaceBlacklistEvent)event; logger.log(Level.INFO, "WorldGuard: [" + worldName + "] " + event.getPlayer().getName() + " tried to place " + getFriendlyItemName(evt.getType()) + (comment != null ? " (" + comment + ")" : "")); - + // Block interact } else if (event instanceof BlockInteractBlacklistEvent) { BlockInteractBlacklistEvent evt = (BlockInteractBlacklistEvent)event; logger.log(Level.INFO, "WorldGuard: [" + worldName + "] " + event.getPlayer().getName() + " tried to interact with " + getFriendlyItemName(evt.getType()) + (comment != null ? " (" + comment + ")" : "")); - + // Destroy with } else if (event instanceof DestroyWithBlacklistEvent) { DestroyWithBlacklistEvent evt = (DestroyWithBlacklistEvent)event; logger.log(Level.INFO, "WorldGuard: [" + worldName + "] " + event.getPlayer().getName() + " tried to destroy with " + getFriendlyItemName(evt.getType()) + (comment != null ? " (" + comment + ")" : "")); - + // Acquire } else if (event instanceof ItemAcquireBlacklistEvent) { ItemAcquireBlacklistEvent evt = (ItemAcquireBlacklistEvent)event; logger.log(Level.INFO, "WorldGuard: [" + worldName + "] " + event.getPlayer().getName() + " tried to acquire " + getFriendlyItemName(evt.getType()) + (comment != null ? " (" + comment + ")" : "")); - + // Drop } else if (event instanceof ItemDropBlacklistEvent) { ItemDropBlacklistEvent evt = (ItemDropBlacklistEvent)event; logger.log(Level.INFO, "WorldGuard: [" + worldName + "] " + event.getPlayer().getName() + " tried to drop " + getFriendlyItemName(evt.getType()) + (comment != null ? " (" + comment + ")" : "")); - + // Use } else if (event instanceof ItemUseBlacklistEvent) { ItemUseBlacklistEvent evt = (ItemUseBlacklistEvent)event; logger.log(Level.INFO, "WorldGuard: [" + worldName + "] " + event.getPlayer().getName() + " tried to use " + getFriendlyItemName(evt.getType()) + (comment != null ? " (" + comment + ")" : "")); - + // Unknown } else { logger.log(Level.INFO, "WorldGuard: [" + worldName + "] " + event.getPlayer().getName() @@ -114,7 +114,7 @@ public void logEvent(BlacklistEvent event, String comment) { /** * Get an item's friendly name with its ID. - * + * * @param id */ private static String getFriendlyItemName(int id) { diff --git a/src/main/java/com/sk89q/worldguard/blacklist/loggers/DatabaseLoggerHandler.java b/src/main/java/com/sk89q/worldguard/blacklist/loggers/DatabaseLoggerHandler.java index 4b024c57..bfe313c5 100644 --- a/src/main/java/com/sk89q/worldguard/blacklist/loggers/DatabaseLoggerHandler.java +++ b/src/main/java/com/sk89q/worldguard/blacklist/loggers/DatabaseLoggerHandler.java @@ -74,12 +74,12 @@ public class DatabaseLoggerHandler implements BlacklistLoggerHandler { /** * Construct the object. - * + * * @param dsn * @param user * @param pass - * @param table - * @param worldName + * @param table + * @param worldName */ public DatabaseLoggerHandler(String dsn, String user, String pass, String table, String worldName) { this.dsn = dsn; @@ -91,7 +91,7 @@ public DatabaseLoggerHandler(String dsn, String user, String pass, String table, /** * Gets the database connection. - * + * * @return * @throws SQLException */ @@ -104,7 +104,7 @@ private Connection getConnection() throws SQLException { /** * Log an event to the database. - * + * * @param event * @param name * @param x @@ -136,7 +136,7 @@ private void logEvent(String event, LocalPlayer player, Vector pos, int item, + e.getMessage()); } } - + /** * Log an event. * @@ -148,43 +148,43 @@ public void logEvent(BlacklistEvent event, String comment) { BlockBreakBlacklistEvent evt = (BlockBreakBlacklistEvent)event; logEvent("BREAK", evt.getPlayer(), evt.getPosition(), evt.getType(), comment); - + // Block place } else if (event instanceof BlockPlaceBlacklistEvent) { BlockPlaceBlacklistEvent evt = (BlockPlaceBlacklistEvent)event; logEvent("PLACE", evt.getPlayer(), evt.getPosition(), evt.getType(), comment); - + // Block interact } else if (event instanceof BlockInteractBlacklistEvent) { BlockInteractBlacklistEvent evt = (BlockInteractBlacklistEvent)event; logEvent("INTERACT", evt.getPlayer(), evt.getPosition(), evt.getType(), comment); - + // Destroy with } else if (event instanceof DestroyWithBlacklistEvent) { DestroyWithBlacklistEvent evt = (DestroyWithBlacklistEvent)event; logEvent("DESTROY_WITH", evt.getPlayer(), evt.getPosition(), evt.getType(), comment); - + // Acquire } else if (event instanceof ItemAcquireBlacklistEvent) { ItemAcquireBlacklistEvent evt = (ItemAcquireBlacklistEvent)event; logEvent("ACQUIRE", evt.getPlayer(), evt.getPlayer().getPosition(), evt.getType(), comment); - + // Drop } else if (event instanceof ItemDropBlacklistEvent) { ItemDropBlacklistEvent evt = (ItemDropBlacklistEvent)event; logEvent("DROP", evt.getPlayer(), evt.getPlayer().getPosition(), evt.getType(), comment); - + // Use } else if (event instanceof ItemUseBlacklistEvent) { ItemUseBlacklistEvent evt = (ItemUseBlacklistEvent)event; logEvent("USE", evt.getPlayer(), evt.getPlayer().getPosition(), evt.getType(), comment); - + // Unknown } else { logEvent("UNKNOWN", event.getPlayer(), event.getPlayer().getPosition(), @@ -201,7 +201,7 @@ public void close() { conn.close(); } } catch (SQLException e) { - + } } } diff --git a/src/main/java/com/sk89q/worldguard/blacklist/loggers/FileLoggerHandler.java b/src/main/java/com/sk89q/worldguard/blacklist/loggers/FileLoggerHandler.java index ed1eced7..9d638769 100644 --- a/src/main/java/com/sk89q/worldguard/blacklist/loggers/FileLoggerHandler.java +++ b/src/main/java/com/sk89q/worldguard/blacklist/loggers/FileLoggerHandler.java @@ -88,7 +88,7 @@ public class FileLoggerHandler implements BlacklistLoggerHandler { * Construct the object. * * @param pathPattern - * @param worldName + * @param worldName */ public FileLoggerHandler(String pathPattern, String worldName) { this.pathPattern = pathPattern; @@ -100,7 +100,7 @@ public FileLoggerHandler(String pathPattern, String worldName) { * * @param pathPattern * @param cacheSize - * @param worldName + * @param worldName */ public FileLoggerHandler(String pathPattern, int cacheSize, String worldName) { if (cacheSize < 1) { @@ -113,7 +113,7 @@ public FileLoggerHandler(String pathPattern, int cacheSize, String worldName) { /** * Build the path. - * + * * @return */ private String buildPath(String playerName) { @@ -159,18 +159,18 @@ private String buildPath(String playerName) { } else if (group.matches("%s")) { rep = String.format("%02d", calendar.get(Calendar.SECOND)); } - + m.appendReplacement(buffer, rep); } m.appendTail(buffer); - + return buffer.toString(); } /** * Log a message. - * + * * @param player * @param message */ @@ -180,7 +180,7 @@ private void log(LocalPlayer player, String message, String comment) { String date = dateFormat.format(new Date()); String line = "[" + date + "] " + player.getName() + ": " + message + (comment != null ? " (" + comment + ")" : "") + "\r\n"; - + FileLoggerWriter writer = writers.get(path); // Writer already exists! @@ -202,7 +202,7 @@ private void log(LocalPlayer player, String message, String comment) { if (parent != null && !parent.exists()) { parent.mkdirs(); } - + FileWriter stream = new FileWriter(path, true); BufferedWriter out = new BufferedWriter(stream); out.write(line); @@ -239,19 +239,19 @@ private void log(LocalPlayer player, String message, String comment) { /** * Gets the coordinates in text form for the log. - * + * * @param pos * @return */ private String getCoordinates(Vector pos) { return "@" + pos.getBlockX() + "," + pos.getBlockY() + "," + pos.getBlockZ(); } - + private void logEvent(BlacklistEvent event, String text, int id, Vector pos, String comment) { log(event.getPlayer(), "Tried to " + text + " " + getFriendlyItemName(id) + " " + getCoordinates(pos), comment); } - + /** * Log an event. * @@ -262,37 +262,37 @@ public void logEvent(BlacklistEvent event, String 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: " diff --git a/src/main/java/com/sk89q/worldguard/blacklist/loggers/FileLoggerWriter.java b/src/main/java/com/sk89q/worldguard/blacklist/loggers/FileLoggerWriter.java index 6d835903..b2b1af4d 100644 --- a/src/main/java/com/sk89q/worldguard/blacklist/loggers/FileLoggerWriter.java +++ b/src/main/java/com/sk89q/worldguard/blacklist/loggers/FileLoggerWriter.java @@ -41,8 +41,8 @@ public class FileLoggerWriter implements Comparable { /** * Construct the object. - * - * @param path + * + * @param path * @param writer */ public FileLoggerWriter(String path, BufferedWriter writer) { @@ -53,7 +53,7 @@ public FileLoggerWriter(String path, BufferedWriter writer) { /** * File path. - * + * * @return */ public String getPath() { @@ -73,7 +73,7 @@ public BufferedWriter getWriter() { public long getLastUse() { return lastUse; } - + /** * Update last use time. */ @@ -83,7 +83,7 @@ public void updateLastUse() { /** * Comparison function. - * + * * @param other * @return */ diff --git a/src/main/java/com/sk89q/worldguard/bukkit/ConfigurationManager.java b/src/main/java/com/sk89q/worldguard/bukkit/ConfigurationManager.java index d8927746..68f9a86b 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/ConfigurationManager.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/ConfigurationManager.java @@ -34,12 +34,12 @@ /** * Represents the global configuration and also delegates configuration * for individual worlds. - * + * * @author sk89q * @author Michael */ public class ConfigurationManager { - + private static final String CONFIG_HEADER = "#\r\n" + "# WorldGuard's main configuration file\r\n" + "#\r\n" + @@ -65,22 +65,22 @@ public class ConfigurationManager { * Reference to the plugin. */ private WorldGuardPlugin plugin; - + /** * Holds configurations for different worlds. */ private Map worlds; - + /** * List of people with god mode. */ private Set hasGodMode = new HashSet(); - + /** * List of people who can breathe underwater. */ private Set hasAmphibious = new HashSet(); - + public boolean suppressTickSyncWarnings; public boolean useRegionsScheduler; public boolean activityHaltToggle = false; @@ -89,7 +89,7 @@ public class ConfigurationManager { /** * Construct the object. - * + * * @param plugin */ public ConfigurationManager(WorldGuardPlugin plugin) { @@ -104,7 +104,7 @@ public void load() { // Create the default configuration file WorldGuardPlugin.createDefaultConfiguration( new File(plugin.getDataFolder(), "config.yml"), "config.yml"); - + Configuration config = plugin.getConfiguration(); config.load(); @@ -139,14 +139,14 @@ public void unload() { /** * Get the configuration for a world. - * + * * @param world * @return */ public WorldConfiguration get(World world) { String worldName = world.getName(); WorldConfiguration config = worlds.get(worldName); - + if (config == null) { config = new WorldConfiguration(plugin, worldName); worlds.put(worldName, config); @@ -157,75 +157,75 @@ public WorldConfiguration get(World world) { /** * Forget a player. - * + * * @param player */ public void forgetPlayer(LocalPlayer player) { for (Map.Entry entry : worlds.entrySet()) { - + // The blacklist needs to forget players Blacklist bl = entry.getValue().getBlacklist(); if (bl != null) { bl.forgetPlayer(player); } } - + hasGodMode.remove(player.getName()); hasAmphibious.remove(player.getName()); } - + /** * Enable god mode for a player. - * + * * @param player */ public void enableGodMode(Player player) { hasGodMode.add(player.getName()); } - + /** * Disable god mode for a player. - * + * * @param player */ public void disableGodMode(Player player) { hasGodMode.remove(player.getName()); } - + /** * Check to see if god mode is enabled for a player. - * + * * @param player - * @return + * @return */ public boolean hasGodMode(Player player) { return hasGodMode.contains(player.getName()); } - + /** * Enable amphibious mode for a player. - * + * * @param player */ public void enableAmphibiousMode(Player player) { hasAmphibious.add(player.getName()); } - + /** * Disable amphibious mode for a player. - * + * * @param player */ public void disableAmphibiousMode(Player player) { hasAmphibious.remove(player.getName()); } - + /** * Check to see if amphibious mode is enabled for a player. - * + * * @param player - * @return + * @return */ public boolean hasAmphibiousMode(Player player) { return hasAmphibious.contains(player.getName()); diff --git a/src/main/java/com/sk89q/worldguard/bukkit/LegacyConsoleSender.java b/src/main/java/com/sk89q/worldguard/bukkit/LegacyConsoleSender.java index 94f1ddd4..be8cad1e 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/LegacyConsoleSender.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/LegacyConsoleSender.java @@ -16,11 +16,11 @@ */ class LegacyConsoleSender implements CommandSender { private Server server; - + public LegacyConsoleSender(Server server) { this.server = server; } - + public void sendMessage(String message) { WorldGuardPlugin.logger.info(message); } @@ -28,7 +28,7 @@ public void sendMessage(String message) { public Server getServer() { return server; } - + public String getName() { return "CONSOLE"; } diff --git a/src/main/java/com/sk89q/worldguard/bukkit/LoggerToChatHandler.java b/src/main/java/com/sk89q/worldguard/bukkit/LoggerToChatHandler.java index 0e29638c..9c276a0e 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/LoggerToChatHandler.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/LoggerToChatHandler.java @@ -38,7 +38,7 @@ public class LoggerToChatHandler extends Handler { /** * Construct the object. - * + * * @param player */ public LoggerToChatHandler(CommandSender player) { diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java index 387e3366..4ce743c0 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java @@ -457,7 +457,7 @@ public Blacklist getBlacklist() { public String getWorldName() { return this.worldName; } - + public boolean isChestProtected(Block block, Player player) { if (!signChestProtection) { return false; @@ -468,14 +468,14 @@ public boolean isChestProtected(Block block, Player player) { } return chestProtection.isProtected(block, player); } - + public boolean isChestProtected(Block block) { if (!signChestProtection) { return false; } return chestProtection.isProtected(block, null); } - + public boolean isChestProtectedPlacement(Block block, Player player) { if (!signChestProtection) { return false; diff --git a/src/main/java/com/sk89q/worldguard/protection/GlobalRegionManager.java b/src/main/java/com/sk89q/worldguard/protection/GlobalRegionManager.java index 18d34f3c..4b0b5e5d 100644 --- a/src/main/java/com/sk89q/worldguard/protection/GlobalRegionManager.java +++ b/src/main/java/com/sk89q/worldguard/protection/GlobalRegionManager.java @@ -44,29 +44,29 @@ /** * This class keeps track of region information for every world. It loads * world region information as needed. - * + * * @author sk89q * @author Redecouverte */ public class GlobalRegionManager { private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard"); - + /** * Reference to the plugin. */ private WorldGuardPlugin plugin; - + /** * Reference to the global configuration. */ private ConfigurationManager config; - + /** * Map of managers per-world. */ private HashMap managers; - + /** * Stores the list of modification dates for the world files. This allows * WorldGuard to reload files as needed. @@ -75,8 +75,8 @@ public class GlobalRegionManager { /** * Construct the object. - * - * @param plugin + * + * @param plugin */ public GlobalRegionManager(WorldGuardPlugin plugin) { this.plugin = plugin; @@ -92,10 +92,10 @@ public void unload() { managers.clear(); lastModified.clear(); } - + /** * Get the path for a world's regions file. - * + * * @param name * @return */ @@ -106,7 +106,7 @@ protected File getPath(String name) { /** * Unload region information for a world. - * + * * @param name */ public void unload(String name) { @@ -128,14 +128,14 @@ public void unloadAll() { /** * Load region information for a world. - * + * * @param world - * @return + * @return */ public RegionManager load(World world) { String name = world.getName(); File file = getPath(name); - + try { // Create a manager RegionManager manager = new FlatRegionManager(new YAMLDatabase(file)); @@ -147,7 +147,7 @@ public RegionManager load(World world) { // Store the last modification date so we can track changes lastModified.put(name, file.lastModified()); - + return manager; } catch (FileNotFoundException e) { logger.warning("WorldGuard: Region file for world \"" @@ -159,11 +159,11 @@ public RegionManager load(World world) { logger.warning("WorldGuard: Error loading regions for world \"" + name + "\":" + e.getMessage()); } - + // @TODO: THIS CREATES PROBLEMS!! return null; } - + /** * Preloads region managers for all worlds. */ @@ -183,7 +183,7 @@ public void reloadChanged() { File file = getPath(name); Long oldDate = lastModified.get(name); - + if (oldDate == null) { oldDate = 0L; } @@ -191,7 +191,7 @@ public void reloadChanged() { try { if (file.lastModified() > oldDate) { World world = plugin.getServer().getWorld(name); - + if (world != null) { load(world); } @@ -203,7 +203,7 @@ public void reloadChanged() { /** * Get the region manager for a particular world. - * + * * @param world * @return */ @@ -228,10 +228,10 @@ public boolean hasBypass(LocalPlayer player, World world) { return player.hasPermission("worldguard.region.bypass." + world.getName()); } - + /** * Returns whether the player can bypass. - * + * * @param player * @param world * @return @@ -240,33 +240,33 @@ public boolean hasBypass(Player player, World world) { return plugin.hasPermission(player, "worldguard.region.bypass." + world.getName()); } - + /** * Check if a player has permission to build at a block. - * + * * @param player - * @param block + * @param block * @return */ public boolean canBuild(Player player, Block block) { return canBuild(player, block.getLocation()); } - + /** * Check if a player has permission to build at a location. - * + * * @param player - * @param loc + * @param loc * @return */ public boolean canBuild(Player player, Location loc) { World world = loc.getWorld(); WorldConfiguration worldConfig = config.get(world); - + if (!worldConfig.useRegions) { return true; } - + LocalPlayer localPlayer = plugin.wrapPlayer(player); if (!hasBypass(player, world)) { @@ -280,10 +280,10 @@ public boolean canBuild(Player player, Location loc) { return true; } - + /** * Checks to see whether a flag is allowed. - * + * * @param flag * @param loc * @return @@ -291,11 +291,11 @@ public boolean canBuild(Player player, Location loc) { public boolean allows(StateFlag flag, Location loc) { World world = loc.getWorld(); WorldConfiguration worldConfig = config.get(world); - + if (!worldConfig.useRegions) { return true; } - + RegionManager mgr = plugin.getGlobalRegionManager().get(world); return mgr.getApplicableRegions(toVector(loc)).allows(flag); } diff --git a/src/main/java/com/sk89q/worldguard/protection/databases/CSVDatabase.java b/src/main/java/com/sk89q/worldguard/protection/databases/CSVDatabase.java index 35bbdccf..085010dd 100644 --- a/src/main/java/com/sk89q/worldguard/protection/databases/CSVDatabase.java +++ b/src/main/java/com/sk89q/worldguard/protection/databases/CSVDatabase.java @@ -44,12 +44,12 @@ /** * Represents a protected area database that uses CSV files. - * + * * @author sk89q */ public class CSVDatabase extends AbstractProtectionDatabase { private static Logger logger = Logger.getLogger("Minecraft.WorldGuard"); - + /** * References the CSV file. */ @@ -58,11 +58,11 @@ public class CSVDatabase extends AbstractProtectionDatabase { * Holds the list of regions. */ private Map regions; - + /** * Construct the database with a path to a file. No file is read or * written at this time. - * + * * @param file */ public CSVDatabase(File file) { @@ -84,28 +84,28 @@ public void load() throws IOException { new HashMap(); Map parentSets = new LinkedHashMap(); - + CSVReader reader = new CSVReader(new FileReader(file)); - + try { String[] line; - + while ((line = reader.readNext()) != null) { if (line.length < 2) { logger.warning("Invalid region definition: " + line); continue; } - + String id = line[0].toLowerCase().replace(".", ""); String type = line[1]; ArrayReader entries = new ArrayReader(line); - + if (type.equalsIgnoreCase("cuboid")) { if (line.length < 8) { logger.warning("Invalid region definition: " + line); continue; } - + Vector pt1 = new Vector( Integer.parseInt(line[2]), Integer.parseInt(line[3]), @@ -117,12 +117,12 @@ public void load() throws IOException { BlockVector min = Vector.getMinimum(pt1, pt2).toBlockVector(); BlockVector max = Vector.getMaximum(pt1, pt2).toBlockVector(); - + int priority = entries.get(8) == null ? 0 : Integer.parseInt(entries.get(8)); String ownersData = entries.get(9); String flagsData = entries.get(10); //String enterMessage = nullEmptyString(entries.get(11)); - + ProtectedRegion region = new ProtectedCuboidRegion(id, min, max); region.setPriority(priority); parseFlags(region, flagsData); @@ -140,7 +140,7 @@ public void load() throws IOException { BlockVector min = Vector.getMinimum(pt1, pt2).toBlockVector(); BlockVector max = Vector.getMaximum(pt1, pt2).toBlockVector(); - + int priority = entries.get(8) == null ? 0 : Integer.parseInt(entries.get(8)); String parentId = entries.get(9); String ownersData = entries.get(10); @@ -148,14 +148,14 @@ public void load() throws IOException { String flagsData = entries.get(12); //String enterMessage = nullEmptyString(entries.get(13)); //String leaveMessage = nullEmptyString(entries.get(14)); - + ProtectedRegion region = new ProtectedCuboidRegion(id, min, max); region.setPriority(priority); parseFlags(region, flagsData); region.setOwners(this.parseDomains(ownersData)); region.setMembers(this.parseDomains(membersData)); regions.put(id, region); - + // Link children to parents later if (parentId.length() > 0) { parentSets.put(region, parentId); @@ -168,7 +168,7 @@ public void load() throws IOException { } catch (IOException e) { } } - + for (Map.Entry entry : parentSets.entrySet()) { ProtectedRegion parent = regions.get(entry.getValue()); if (parent != null) { @@ -182,13 +182,13 @@ public void load() throws IOException { logger.warning("Unknown region parent: " + entry.getValue()); } } - + this.regions = regions; } - + /** * Used to parse the specified domain in the CSV file. - * + * * @param data * @return */ @@ -196,19 +196,19 @@ private DefaultDomain parseDomains(String data) { if (data == null) { return new DefaultDomain(); } - + DefaultDomain domain = new DefaultDomain(); Pattern pattern = Pattern.compile("^([A-Za-z]):(.*)$"); - + String[] parts = data.split(","); - + for (String part : parts) { if (part.trim().length() == 0) { continue; } - + Matcher matcher = pattern.matcher(part); - + if (!matcher.matches()) { logger.warning("Invalid owner specification: " + part); continue; @@ -225,22 +225,22 @@ private DefaultDomain parseDomains(String data) { logger.warning("Unknown owner specification: " + type); } } - + return domain; } - + /** * Used to parse the list of flags. - * + * * @param data */ private void parseFlags(ProtectedRegion region, String data) { if (data == null) { return; } - + State curState = State.ALLOW; - + for (int i = 0; i < data.length(); i++) { char k = data.charAt(i); if (k == '+') { @@ -262,7 +262,7 @@ private void parseFlags(ProtectedRegion region, String data) { } else { flagStr = String.valueOf(k); } - + StateFlag flag = DefaultFlag.getLegacyFlag(flagStr); if (flag != null) { region.setFlag(flag, curState); @@ -275,29 +275,29 @@ private void parseFlags(ProtectedRegion region, String data) { /** * Used to write the list of domains. - * + * * @param domain * @return */ /* private String writeDomains(DefaultDomain domain) { StringBuilder str = new StringBuilder(); - + for (String player : domain.getPlayers()) { str.append("u:" + player + ","); } - + for (String group : domain.getGroups()) { str.append("g:" + group + ","); } - + return str.length() > 0 ? str.toString().substring(0, str.length() - 1) : ""; }*/ - + /** * Helper method to prepend '+' or '-' in front of a flag according * to the flag's state. - * + * * @param state * @param flag * @return @@ -309,14 +309,14 @@ private String writeFlag(State state, String flag) { } else if (state == State.DENY) { return "-" + flag; } - + return ""; } */ /** * Returns a null if a string is null or empty. - * + * * @param str * @return */ diff --git a/src/main/java/com/sk89q/worldguard/protection/databases/ProtectionDatabase.java b/src/main/java/com/sk89q/worldguard/protection/databases/ProtectionDatabase.java index a026891c..50f368d6 100644 --- a/src/main/java/com/sk89q/worldguard/protection/databases/ProtectionDatabase.java +++ b/src/main/java/com/sk89q/worldguard/protection/databases/ProtectionDatabase.java @@ -27,46 +27,46 @@ /** * Represents a database to read and write lists of regions from and to. - * + * * @author sk89q */ public interface ProtectionDatabase { /** * Load the list of regions. The method should not modify the list returned * by getRegions() unless the load finishes successfully. - * + * * @throws IOException */ public void load() throws IOException; /** * Save the list of regions. - * + * * @throws IOException */ public void save() throws IOException; /** * Load the list of regions into a region manager. - * - * @param manager + * + * @param manager * @throws IOException */ public void load(RegionManager manager) throws IOException; /** * Save the list of regions from a region manager. - * - * @param manager + * + * @param manager * @throws IOException */ public void save(RegionManager manager) throws IOException; /** * Get a list of regions. - * + * * @return */ public Map getRegions(); /** * Set the list of regions. - * + * * @param regions */ public void setRegions(Map regions); diff --git a/src/main/java/com/sk89q/worldguard/protection/flags/DefaultFlag.java b/src/main/java/com/sk89q/worldguard/protection/flags/DefaultFlag.java index 97fc51e0..779eab8d 100644 --- a/src/main/java/com/sk89q/worldguard/protection/flags/DefaultFlag.java +++ b/src/main/java/com/sk89q/worldguard/protection/flags/DefaultFlag.java @@ -26,7 +26,7 @@ * @author sk89q */ public final class DefaultFlag { - + public static final StateFlag PASSTHROUGH = new StateFlag("passthrough", 'z', false); public static final StateFlag BUILD = new StateFlag("build", 'b', true); public static final StateFlag PVP = new StateFlag("pvp", 'p', true); @@ -101,17 +101,17 @@ public final class DefaultFlag { ENTRY.setGroupFlag(ENTRY_PERM); EXIT.setGroupFlag(EXIT_PERM); } - + private DefaultFlag() { } - + public static Flag[] getFlags() { return flagsList; } - + /** * Get the legacy flag. - * + * * @param flagString * @return null if not found */ @@ -121,7 +121,7 @@ public static StateFlag getLegacyFlag(String flagString) { return (StateFlag) flag; } } - + return null; } } diff --git a/src/main/java/com/sk89q/worldguard/protection/flags/DoubleFlag.java b/src/main/java/com/sk89q/worldguard/protection/flags/DoubleFlag.java index ae392991..5e3b535c 100644 --- a/src/main/java/com/sk89q/worldguard/protection/flags/DoubleFlag.java +++ b/src/main/java/com/sk89q/worldguard/protection/flags/DoubleFlag.java @@ -27,7 +27,7 @@ * @author sk89q */ public class DoubleFlag extends Flag { - + public DoubleFlag(String name, char legacyCode) { super(name, legacyCode); } @@ -40,7 +40,7 @@ public DoubleFlag(String name) { public Double parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat { input = input.trim(); - + try { return Double.parseDouble(input); } catch (NumberFormatException e) { diff --git a/src/main/java/com/sk89q/worldguard/protection/flags/Flag.java b/src/main/java/com/sk89q/worldguard/protection/flags/Flag.java index 748bf76a..835ea355 100644 --- a/src/main/java/com/sk89q/worldguard/protection/flags/Flag.java +++ b/src/main/java/com/sk89q/worldguard/protection/flags/Flag.java @@ -25,35 +25,35 @@ /** * * @author sk89q - * @param + * @param */ public abstract class Flag { - + private String name; private Character legacyCode; - + public Flag(String name, char legacyCode) { this.name = name; this.legacyCode = legacyCode; } - + public Flag(String name) { this.name = name; this.legacyCode = null; } - + public String getName() { return name; } - + public Character getLegacyCode() { return legacyCode; } - + public abstract T parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat; - + public abstract T unmarshal(Object o); - + public abstract Object marshal(T o); } diff --git a/src/main/java/com/sk89q/worldguard/protection/flags/IntegerFlag.java b/src/main/java/com/sk89q/worldguard/protection/flags/IntegerFlag.java index d18c4a78..b1ee4145 100644 --- a/src/main/java/com/sk89q/worldguard/protection/flags/IntegerFlag.java +++ b/src/main/java/com/sk89q/worldguard/protection/flags/IntegerFlag.java @@ -27,7 +27,7 @@ * @author sk89q */ public class IntegerFlag extends Flag { - + public IntegerFlag(String name, char legacyCode) { super(name, legacyCode); } @@ -40,7 +40,7 @@ public IntegerFlag(String name) { public Integer parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat { input = input.trim(); - + try { return Integer.parseInt(input); } catch (NumberFormatException e) { diff --git a/src/main/java/com/sk89q/worldguard/protection/flags/RegionGroupFlag.java b/src/main/java/com/sk89q/worldguard/protection/flags/RegionGroupFlag.java index 651cca3d..dd1226d4 100644 --- a/src/main/java/com/sk89q/worldguard/protection/flags/RegionGroupFlag.java +++ b/src/main/java/com/sk89q/worldguard/protection/flags/RegionGroupFlag.java @@ -39,7 +39,7 @@ public static enum RegionGroup { } private RegionGroup def; - + public RegionGroupFlag(String name, char legacyCode, RegionGroup def) { super(name, legacyCode); this.def = def; @@ -58,7 +58,7 @@ public RegionGroup getDefault() { public RegionGroup parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat { input = input.trim(); - + if (input.equalsIgnoreCase("members") || input.equalsIgnoreCase("member")) { return RegionGroup.MEMBERS; } else if (input.equalsIgnoreCase("owners") || input.equalsIgnoreCase("owner")) { @@ -149,5 +149,5 @@ public static boolean isMember(ApplicableRegionSet set, return false; } - + } diff --git a/src/main/java/com/sk89q/worldguard/protection/flags/StateFlag.java b/src/main/java/com/sk89q/worldguard/protection/flags/StateFlag.java index d3ea1f9f..d58c402f 100644 --- a/src/main/java/com/sk89q/worldguard/protection/flags/StateFlag.java +++ b/src/main/java/com/sk89q/worldguard/protection/flags/StateFlag.java @@ -27,15 +27,15 @@ * @author sk89q */ public class StateFlag extends Flag { - + public enum State { ALLOW, DENY } - + private boolean def; private RegionGroupFlag groupFlag; - + public StateFlag(String name, char legacyCode, boolean def) { super(name, legacyCode); this.def = def; @@ -62,7 +62,7 @@ public void setGroupFlag(RegionGroupFlag groupFlag) { public State parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat { input = input.trim(); - + if (input.equalsIgnoreCase("allow")) { return State.ALLOW; } else if (input.equalsIgnoreCase("deny")) { @@ -96,5 +96,5 @@ public Object marshal(State o) { return null; } } - + } diff --git a/src/main/java/com/sk89q/worldguard/protection/flags/StringFlag.java b/src/main/java/com/sk89q/worldguard/protection/flags/StringFlag.java index 065f2d98..1375c2e3 100644 --- a/src/main/java/com/sk89q/worldguard/protection/flags/StringFlag.java +++ b/src/main/java/com/sk89q/worldguard/protection/flags/StringFlag.java @@ -27,7 +27,7 @@ * @author sk89q */ public class StringFlag extends Flag { - + public StringFlag(String name, char legacyCode) { super(name, legacyCode); } @@ -55,5 +55,5 @@ public String unmarshal(Object o) { public Object marshal(String o) { return o; } - + } diff --git a/src/main/java/com/sk89q/worldguard/protection/flags/VectorFlag.java b/src/main/java/com/sk89q/worldguard/protection/flags/VectorFlag.java index 0ebe24bb..5d3d1202 100644 --- a/src/main/java/com/sk89q/worldguard/protection/flags/VectorFlag.java +++ b/src/main/java/com/sk89q/worldguard/protection/flags/VectorFlag.java @@ -33,7 +33,7 @@ * @author sk89q */ public class VectorFlag extends Flag { - + public VectorFlag(String name, char legacyCode) { super(name, legacyCode); } @@ -46,7 +46,7 @@ public VectorFlag(String name) { public Vector parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat { input = input.trim(); - + try { return BukkitUtil.toVector(plugin.checkPlayer(sender).getLocation()); } catch (CommandException e) { @@ -62,14 +62,14 @@ public Vector unmarshal(Object o) { Object rawX = map.get("x"); Object rawY = map.get("y"); Object rawZ = map.get("z"); - + if (rawX == null || rawY == null || rawZ == null) { return null; } - + return new Vector(toNumber(rawX), toNumber(rawY), toNumber(rawZ)); } - + return null; } @@ -81,7 +81,7 @@ public Object marshal(Vector o) { vec.put("z", o.getZ()); return vec; } - + private double toNumber(Object o) { if (o instanceof Integer) { return (Integer) o; diff --git a/src/main/java/com/sk89q/worldguard/protection/managers/FlatRegionManager.java b/src/main/java/com/sk89q/worldguard/protection/managers/FlatRegionManager.java index c979116e..6f2f884d 100644 --- a/src/main/java/com/sk89q/worldguard/protection/managers/FlatRegionManager.java +++ b/src/main/java/com/sk89q/worldguard/protection/managers/FlatRegionManager.java @@ -36,7 +36,7 @@ * A very simple implementation of the region manager that uses a flat list * and iterates through the list to identify applicable regions. This method * is not very efficient. - * + * * @author sk89q */ public class FlatRegionManager extends RegionManager { @@ -48,8 +48,8 @@ public class FlatRegionManager extends RegionManager { /** * Construct the manager. - * - * @param regionloader + * + * @param regionloader */ public FlatRegionManager(ProtectionDatabase regionloader) { super(regionloader); @@ -76,7 +76,7 @@ public void setRegions(Map regions) { /** * Adds a region. - * + * * @param region */ @Override @@ -86,7 +86,7 @@ public void addRegion(ProtectedRegion region) { /** * Removes a region and its children. - * + * * @param id */ @Override @@ -112,7 +112,7 @@ public void removeRegion(String id) { /** * Return whether a region exists by an ID. - * + * * @param id * @return */ @@ -123,7 +123,7 @@ public boolean hasRegion(String id) { /** * Get a region by its ID. - * + * * @param id */ @Override @@ -133,7 +133,7 @@ public ProtectedRegion getRegion(String id) { /** * Get an object for a point for rules to be applied with. - * + * * @param pt * @return */ @@ -145,16 +145,16 @@ public ApplicableRegionSet getApplicableRegions(Vector pt) { for (ProtectedRegion region : regions.values()) { if (region.contains(pt)) { appRegions.add(region); - + ProtectedRegion parent = region.getParent(); - + while (parent != null) { if (!appRegions.contains(parent)) { appRegions.add(region); } - + parent = parent.getParent(); - } + } } } @@ -184,7 +184,7 @@ public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) { /** * Get a list of region IDs that contain a point. - * + * * @param pt * @return */ @@ -203,7 +203,7 @@ public List getApplicableRegionsIDs(Vector pt) { /** * Get an object for a region for rules to be applied with. - * + * * @return */ @Override @@ -213,7 +213,7 @@ public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) { appRegions.addAll(regions.values()); List intersectRegions; - + try { intersectRegions = checkRegion.getIntersectingRegions(appRegions); } catch (Exception e) { @@ -226,7 +226,7 @@ public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) { /** * Returns true if the provided region overlaps with any other region that * is not owned by the player. - * + * * @param player * @return */ @@ -254,7 +254,7 @@ public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer pl /** * Get the number of regions. - * + * * @return */ @Override diff --git a/src/main/java/com/sk89q/worldguard/protection/managers/PRTreeRegionManager.java b/src/main/java/com/sk89q/worldguard/protection/managers/PRTreeRegionManager.java index af89dbbe..aa0a78f1 100644 --- a/src/main/java/com/sk89q/worldguard/protection/managers/PRTreeRegionManager.java +++ b/src/main/java/com/sk89q/worldguard/protection/managers/PRTreeRegionManager.java @@ -54,9 +54,9 @@ public class PRTreeRegionManager extends RegionManager { /** * Construct the manager. - * - * @param regionloader - * @throws IOException + * + * @param regionloader + * @throws IOException */ public PRTreeRegionManager(ProtectionDatabase regionloader) throws IOException { super(regionloader); @@ -87,7 +87,7 @@ public void setRegions(Map regions) { /** * Adds a region. - * + * * @param region */ @Override @@ -99,7 +99,7 @@ public void addRegion(ProtectedRegion region) { /** * Return whether a region exists by an ID. - * + * * @param id * @return */ @@ -110,7 +110,7 @@ public boolean hasRegion(String id) { /** * Get a region by its ID. - * + * * @param id */ @Override @@ -120,7 +120,7 @@ public ProtectedRegion getRegion(String id) { /** * Removes a region and its children. - * + * * @param id */ @Override @@ -150,7 +150,7 @@ public void removeRegion(String id) { /** * Get an object for a point for rules to be applied with. - * + * * @param pt * @return */ @@ -167,7 +167,7 @@ public ApplicableRegionSet getApplicableRegions(Vector pt) { appRegions.add(region); } } - + Collections.sort(appRegions); return new ApplicableRegionSet(appRegions, regions.get("__global__")); @@ -190,7 +190,7 @@ public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) { /** * Get a list of region IDs that contain a point. - * + * * @param pt * @return */ @@ -213,7 +213,7 @@ public List getApplicableRegionsIDs(Vector pt) { /** * Returns true if the provided region overlaps with any other region that * is not owned by the player. - * + * * @param player * @return */ @@ -241,7 +241,7 @@ public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer pl /** * Get the number of regions. - * + * * @return */ @Override diff --git a/src/main/java/com/sk89q/worldguard/protection/managers/RegionManager.java b/src/main/java/com/sk89q/worldguard/protection/managers/RegionManager.java index 168b0baf..0ba95651 100644 --- a/src/main/java/com/sk89q/worldguard/protection/managers/RegionManager.java +++ b/src/main/java/com/sk89q/worldguard/protection/managers/RegionManager.java @@ -34,16 +34,16 @@ * simple implementation uses a flat list and iterates through the entire list * to look for applicable regions, but a more complicated (and more efficient) * implementation may use space partitioning techniques. - * + * * @author sk89q */ public abstract class RegionManager { - + protected ProtectionDatabase loader; /** * Construct the object. - * + * * @param loader */ public RegionManager(ProtectionDatabase loader) { @@ -72,7 +72,7 @@ public void save() throws IOException { /** * Get a map of protected regions. Use one of the region manager methods * if possible if working with regions. - * + * * @return map of regions, with keys being region IDs (lowercase) */ public abstract Map getRegions(); @@ -80,7 +80,7 @@ public void save() throws IOException { /** * Set a list of protected regions. Keys should be lowercase in the given * map fo regions. - * + * * @param regions map of regions */ public abstract void setRegions(Map regions); @@ -88,14 +88,14 @@ public void save() throws IOException { /** * Adds a region. If a region by the given name already exists, then * the existing region will be replaced. - * + * * @param region region to add */ public abstract void addRegion(ProtectedRegion region); /** * Return whether a region exists by an ID. - * + * * @param id id of the region, can be mixed-case * @return whether the region exists */ @@ -103,7 +103,7 @@ public void save() throws IOException { /** * Get a region by its ID. - * + * * @param id id of the region, can be mixed-case * @return region or null if it doesn't exist */ @@ -111,7 +111,7 @@ public void save() throws IOException { /** * Removes a region, including inheriting children. - * + * * @param id id of the region, can be mixed-case */ public abstract void removeRegion(String id); @@ -119,7 +119,7 @@ public void save() throws IOException { /** * Get an object for a point for rules to be applied with. Use this in order * to query for flag data or membership data for a given point. - * + * * @param loc Bukkit location * @return applicable region set */ @@ -130,7 +130,7 @@ public ApplicableRegionSet getApplicableRegions(org.bukkit.Location loc) { /** * Get an object for a point for rules to be applied with. Use this in order * to query for flag data or membership data for a given point. - * + * * @param pt point * @return applicable region set */ @@ -150,7 +150,7 @@ public abstract ApplicableRegionSet getApplicableRegions( /** * Get a list of region IDs that contain a point. - * + * * @param pt point * @return list of region Ids */ @@ -159,7 +159,7 @@ public abstract ApplicableRegionSet getApplicableRegions( /** * Returns true if the provided region overlaps with any other region that * is not owned by the player. - * + * * @param region region to check * @param player player to check against * @return whether there is an overlap diff --git a/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedCuboidRegion.java b/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedCuboidRegion.java index d2cca379..68e21a53 100644 --- a/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedCuboidRegion.java +++ b/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedCuboidRegion.java @@ -46,8 +46,8 @@ public class ProtectedCuboidRegion extends ProtectedRegion { * Construct a new instance of this cuboid region. * * @param id - * @param min - * @param max + * @param min + * @param max */ public ProtectedCuboidRegion(String id, BlockVector min, BlockVector max) { super(id); @@ -109,7 +109,7 @@ public boolean contains(Vector pt) { /* public boolean intersectsWith(ProtectedRegion region) throws UnsupportedIntersectionException { - + if (region instanceof ProtectedCuboidRegion) { ProtectedCuboidRegion r1 = (ProtectedCuboidRegion) this; ProtectedCuboidRegion r2 = (ProtectedCuboidRegion) region; @@ -144,7 +144,7 @@ public List getIntersectingRegions(List region BlockVector rMaxPoint = region.getMaximumPoint(); // Check whether the region is outside the min and max vector - if ((rMinPoint.getBlockX() < min.getBlockX() && rMaxPoint.getBlockX() < min.getBlockX()) + if ((rMinPoint.getBlockX() < min.getBlockX() && rMaxPoint.getBlockX() < min.getBlockX()) || (rMinPoint.getBlockX() > max.getBlockX() && rMaxPoint.getBlockX() > max.getBlockX()) && ((rMinPoint.getBlockY() < min.getBlockY() && rMaxPoint.getBlockY() < min.getBlockY()) || (rMinPoint.getBlockY() > max.getBlockY() && rMaxPoint.getBlockY() > max.getBlockY())) @@ -182,7 +182,7 @@ public List getIntersectingRegions(List region } } } else if (region instanceof ProtectedCuboidRegion) { - BlockVector ptcMin = region.getMinimumPoint(); + BlockVector ptcMin = region.getMinimumPoint(); BlockVector ptcMax = region.getMaximumPoint(); if (this.contains(new Vector(ptcMin.getBlockX(), ptcMin.getBlockY(), ptcMin.getBlockZ())) @@ -197,7 +197,7 @@ public List getIntersectingRegions(List region continue; } } else { - throw new UnsupportedOperationException("Not supported yet."); + throw new UnsupportedOperationException("Not supported yet."); } // Check whether the current regions edges collide with the regions edges @@ -258,7 +258,7 @@ public List getIntersectingRegions(List region /** * Return the type of region as a user-friendly name. - * + * * @return type of region */ @Override @@ -268,7 +268,7 @@ public String getTypeName() { /** * Get the number of Blocks in this region - * + * * @return */ @Override diff --git a/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedPolygonalRegion.java b/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedPolygonalRegion.java index c05b96e8..9c4816a2 100644 --- a/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedPolygonalRegion.java +++ b/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedPolygonalRegion.java @@ -155,7 +155,7 @@ public List getIntersectingRegions(List region BlockVector rMaxPoint = region.getMaximumPoint(); // Check whether the region is outside the min and max vector - if ((rMinPoint.getBlockX() < min.getBlockX() && rMaxPoint.getBlockX() < min.getBlockX()) + if ((rMinPoint.getBlockX() < min.getBlockX() && rMaxPoint.getBlockX() < min.getBlockX()) || (rMinPoint.getBlockX() > max.getBlockX() && rMaxPoint.getBlockX() > max.getBlockX()) && ((rMinPoint.getBlockY() < min.getBlockY() && rMaxPoint.getBlockY() < min.getBlockY()) || (rMinPoint.getBlockY() > max.getBlockY() && rMaxPoint.getBlockY() > max.getBlockY())) @@ -190,7 +190,7 @@ public List getIntersectingRegions(List region } } } else if (region instanceof ProtectedCuboidRegion) { - BlockVector ptcMin = region.getMinimumPoint(); + BlockVector ptcMin = region.getMinimumPoint(); BlockVector ptcMax = region.getMaximumPoint(); if (this.contains(new Vector(ptcMin.getBlockX(), ptcMin.getBlockY(), ptcMin.getBlockZ())) @@ -205,7 +205,7 @@ public List getIntersectingRegions(List region continue; } } else { - throw new UnsupportedOperationException("Not supported yet."); + throw new UnsupportedOperationException("Not supported yet."); } // Check whether the current regions edges collide with the regions edges @@ -261,7 +261,7 @@ public List getIntersectingRegions(List region /** * Return the type of region as a user-friendly name. - * + * * @return type of region */ @Override @@ -271,7 +271,7 @@ public String getTypeName() { /** * Get the number of Blocks in this region - * + * * @return */ @Override diff --git a/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedRegion.java b/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedRegion.java index 16631806..d4c1d67d 100644 --- a/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedRegion.java +++ b/src/main/java/com/sk89q/worldguard/protection/regions/ProtectedRegion.java @@ -33,38 +33,38 @@ /** * Represents a region of any shape and size that can be protected. - * + * * @author sk89q */ public abstract class ProtectedRegion implements Comparable { - + private static final Pattern idPattern = Pattern.compile("^[A-Za-z0-9_,'\\-\\+/]{1,}$"); - + /** * Holds the region's ID. */ private String id; - + /** * Priority. */ private int priority = 0; - + /** * Holds the curParent. */ private ProtectedRegion parent; - + /** * List of owners. */ private DefaultDomain owners = new DefaultDomain(); - + /** * List of members. */ private DefaultDomain members = new DefaultDomain(); - + /** * List of flags. */ @@ -113,7 +113,7 @@ public int getPriority() { public void setPriority(int priority) { this.priority = priority; } - + /** * @return the curParent */ @@ -124,20 +124,20 @@ public ProtectedRegion getParent() { /** * Set the curParent. This checks to make sure that it will not result * in circular inheritance. - * + * * @param parent the curParent to setFlag - * @throws CircularInheritanceException + * @throws CircularInheritanceException */ public void setParent(ProtectedRegion parent) throws CircularInheritanceException { if (parent == null) { this.parent = null; return; } - + if (parent == this) { throw new CircularInheritanceException(); } - + ProtectedRegion p = parent.getParent(); while (p != null) { if (p == this) { @@ -145,7 +145,7 @@ public void setParent(ProtectedRegion parent) throws CircularInheritanceExceptio } p = p.getParent(); } - + this.parent = parent; } @@ -181,16 +181,16 @@ public void setMembers(DefaultDomain members) { /** * Checks whether a region has members or owners. - * + * * @return whether there are members or owners */ public boolean hasMembersOrOwners() { return owners.size() > 0 || members.size() > 0; } - + /** * Checks whether a player is an owner of region or any of its parents. - * + * * @param player player to check * @return whether an owner */ @@ -198,23 +198,23 @@ public boolean isOwner(LocalPlayer player) { if (owners.contains(player)) { return true; } - + ProtectedRegion curParent = getParent(); while (curParent != null) { if (curParent.getOwners().contains(player)) { return true; } - + curParent = curParent.getParent(); } - + return false; } /** * Checks whether a player is a member OR OWNER of the region * or any of its parents. - * + * * @param player player to check * @return whether an owner or member */ @@ -222,17 +222,17 @@ public boolean isMember(LocalPlayer player) { if (owners.contains(player) || members.contains(player)) { return true; } - + ProtectedRegion curParent = getParent(); while (curParent != null) { if (curParent.getOwners().contains(player) || curParent.getMembers().contains(player)) { return true; } - + curParent = curParent.getParent(); } - + return false; } @@ -259,10 +259,10 @@ public boolean isMemberOnly(LocalPlayer player) { return false; } - + /** * Get a flag's value. - * + * * @param * @param * @param flag @@ -279,10 +279,10 @@ public , V> V getFlag(T flag) { } return val; } - + /** * Set a flag's value. - * + * * @param * @param * @param flag @@ -295,20 +295,20 @@ public , V> void setFlag(T flag, V val) { flags.put(flag, val); } } - + /** * Get the map of flags. - * + * * @return */ public Map, Object> getFlags() { return flags; } - + /** * Get the map of flags. - * - * @param flags + * + * @param flags */ public void setFlags(Map, Object> flags) { this.flags = flags; @@ -316,22 +316,22 @@ public void setFlags(Map, Object> flags) { /** * Get the number of blocks in this region - * + * * @return */ public abstract int volume(); - + /** * Check to see if a point is inside this region. - * + * * @param pt * @return */ public abstract boolean contains(Vector pt); - + /** * Compares to another region. - * + * * @param other * @return */ @@ -349,14 +349,14 @@ public int compareTo(ProtectedRegion other) { /** * Return the type of region as a user-friendly, lowercase name. - * + * * @return type of region */ public abstract String getTypeName(); /** * Get a list of intersecting regions. - * + * * @param regions * @return * @throws UnsupportedIntersectionException @@ -364,17 +364,17 @@ public int compareTo(ProtectedRegion other) { public abstract List getIntersectingRegions( List regions) throws UnsupportedIntersectionException; - + /** * Checks to see if the given ID is accurate. - * + * * @param id * @return */ public static boolean isValidId(String id) { return idPattern.matcher(id).matches(); } - + /** * Returns the hash code. */ @@ -382,7 +382,7 @@ public static boolean isValidId(String id) { public int hashCode(){ return id.hashCode(); } - + /** * Returns whether this region has the same ID as another region. */ @@ -391,15 +391,15 @@ public boolean equals(Object obj) { if (!(obj instanceof ProtectedRegion)) { return false; } - + ProtectedRegion other = (ProtectedRegion) obj; return other.getId().equals(getId()); } - + /** * Thrown when setting a curParent would create a circular inheritance * situation. - * + * */ public static class CircularInheritanceException extends Exception { private static final long serialVersionUID = 7479613488496776022L; diff --git a/src/main/java/com/sk89q/worldguard/util/yaml/Configuration.java b/src/main/java/com/sk89q/worldguard/util/yaml/Configuration.java index ed4b8b80..6c8ffc8e 100644 --- a/src/main/java/com/sk89q/worldguard/util/yaml/Configuration.java +++ b/src/main/java/com/sk89q/worldguard/util/yaml/Configuration.java @@ -38,10 +38,10 @@ * a file and call its load() method. For specifying node paths in the * various get*() methods, they support SK's path notation, allowing you to * select child nodes by delimiting node names with periods. - * + * *

* For example, given the following configuration file:

- * + * *
members:
  *     - Hollie
  *     - Jason
@@ -56,41 +56,41 @@
  *     cool: false
  *     eats:
  *         babies: true
- * + * *

Calling code could access sturmeh's baby eating state by using * getBoolean("sturmeh.eats.babies", false). For lists, there are * methods such as getStringList that will return a type safe list. - * + * *

This class is currently incomplete. It is not yet possible to get a node. *

- * + * * @author sk89q */ public class Configuration extends ConfigurationNode { private Yaml yaml; private File file; private String header = null; - + public Configuration(File file) { super(new HashMap()); - + DumperOptions options = new DumperOptions(); options.setIndent(2); options.setDefaultFlowStyle(DumperOptions.FlowStyle.AUTO); yaml = new Yaml(new SafeConstructor(), new Representer(), options); - + this.file = file; } - + /** * Loads the configuration file. - * - * @throws IOException + * + * @throws IOException */ - public void load() throws IOException { + public void load() throws IOException { FileInputStream stream = null; - + try { stream = new FileInputStream(file); read(yaml.load(new UnicodeReader(stream))); @@ -179,7 +179,7 @@ public boolean save() { return false; } - + @SuppressWarnings("unchecked") private void read(Object input) throws ConfigurationException { try { @@ -192,9 +192,9 @@ private void read(Object input) throws ConfigurationException { throw new ConfigurationException("Root document must be an key-value structure"); } } - + /** - * This method returns an empty ConfigurationNode for using as a + * This method returns an empty ConfigurationNode for using as a * default in methods that select a node from a node list. * @return */ diff --git a/src/main/java/com/sk89q/worldguard/util/yaml/ConfigurationNode.java b/src/main/java/com/sk89q/worldguard/util/yaml/ConfigurationNode.java index e72f1534..bfa22106 100644 --- a/src/main/java/com/sk89q/worldguard/util/yaml/ConfigurationNode.java +++ b/src/main/java/com/sk89q/worldguard/util/yaml/ConfigurationNode.java @@ -30,30 +30,30 @@ /** * Represents a configuration node. - * + * * @author sk89q */ public class ConfigurationNode { protected Map root; - + protected ConfigurationNode(Map root) { this.root = root; } - + /** * Clear all nodes. */ public void clear() { root.clear(); } - + /** * Gets a property at a location. This will either return an Object * or null, with null meaning that no configuration value exists at * that location. This could potentially return a default value (not yet * implemented) as defined by a plugin, if this is a plugin-tied * configuration. - * + * * @param path path to node (dot notation) * @return object or null */ @@ -66,35 +66,35 @@ public Object getProperty(String path) { } return val; } - + String[] parts = path.split("\\."); Map node = root; - + for (int i = 0; i < parts.length; i++) { Object o = node.get(parts[i]); - + if (o == null) { return null; } - + if (i == parts.length - 1) { return o; } - + try { node = (Map)o; } catch (ClassCastException e) { return null; } } - + return null; } - + /** * Prepare a value for serialization, in case it's not a native type * (and we don't want to serialize objects as YAML objects). - * + * * @param value * @return */ @@ -107,53 +107,53 @@ private Object prepareSerialization(Object value) { out.put("z", vec.getZ()); return out; } - + return value; } - + /** * Set the property at a location. This will override existing * configuration data to have it conform to key/value mappings. - * + * * @param path * @param value */ @SuppressWarnings("unchecked") public void setProperty(String path, Object value) { value = prepareSerialization(value); - + if (!path.contains(".")) { root.put(path, value); return; } - + String[] parts = path.split("\\."); Map node = root; - + for (int i = 0; i < parts.length; i++) { Object o = node.get(parts[i]); - + // Found our target! if (i == parts.length - 1) { node.put(parts[i], value); return; } - + if (o == null || !(o instanceof Map)) { // This will override existing configuration data! o = new HashMap(); node.put(parts[i], o); } - + node = (Map)o; } } - + /** * Adds a new node to the given path. The returned object is a reference * to the new node. This method will replace an existing node at * the same path. See setProperty. - * + * * @param path * @return */ @@ -169,7 +169,7 @@ public ConfigurationNode addNode(String path) { * or null, with null meaning that no configuration value exists at * that location. If the object at the particular location is not actually * a string, it will be converted to its string representation. - * + * * @param path path to node (dot notation) * @return string or null */ @@ -185,7 +185,7 @@ public String getString(String path) { * Gets a vector at a location. This will either return an Vector * or a null. If the object at the particular location is not * actually a string, it will be converted to its string representation. - * + * * @param path path to node (dot notation) * @return string or default */ @@ -194,15 +194,15 @@ public Vector getVector(String path) { if (o == null) { return null; } - + Double x = o.getDouble("x"); Double y = o.getDouble("y"); Double z = o.getDouble("z"); - + if (x == null || y == null || z == null) { return null; } - + return new Vector(x, y, z); } @@ -210,7 +210,7 @@ public Vector getVector(String path) { * Gets a 2D vector at a location. This will either return an Vector * or a null. If the object at the particular location is not * actually a string, it will be converted to its string representation. - * + * * @param path path to node (dot notation) * @return string or default */ @@ -219,14 +219,14 @@ public Vector2D getVector2d(String path) { if (o == null) { return null; } - + Double x = o.getDouble("x"); Double z = o.getDouble("z"); - + if (x == null || z == null) { return null; } - + return new Vector2D(x, z); } @@ -234,7 +234,7 @@ public Vector2D getVector2d(String path) { * Gets a string at a location. This will either return an Vector * or the default value. If the object at the particular location is not * actually a string, it will be converted to its string representation. - * + * * @param path path to node (dot notation) * @param def default value * @return string or default @@ -252,7 +252,7 @@ public Vector getVector(String path, Vector def) { * Gets a string at a location. This will either return an String * or the default value. If the object at the particular location is not * actually a string, it will be converted to its string representation. - * + * * @param path path to node (dot notation) * @param def default value * @return string or default @@ -271,7 +271,7 @@ public String getString(String path, String def) { * or null. If the object at the particular location is not * actually a integer, the default value will be returned. However, other * number types will be casted to an integer. - * + * * @param path path to node (dot notation) * @return integer or null */ @@ -289,7 +289,7 @@ public Integer getInt(String path) { * or the default value. If the object at the particular location is not * actually a integer, the default value will be returned. However, other * number types will be casted to an integer. - * + * * @param path path to node (dot notation) * @param def default value * @return int or default @@ -309,7 +309,7 @@ public int getInt(String path, int def) { * or null. If the object at the particular location is not * actually a double, the default value will be returned. However, other * number types will be casted to an double. - * + * * @param path path to node (dot notation) * @return double or null */ @@ -327,7 +327,7 @@ public Double getDouble(String path) { * or the default value. If the object at the particular location is not * actually a double, the default value will be returned. However, other * number types will be casted to an double. - * + * * @param path path to node (dot notation) * @param def default value * @return double or default @@ -346,7 +346,7 @@ public double getDouble(String path, double def) { * Gets a boolean at a location. This will either return an boolean * or null. If the object at the particular location is not * actually a boolean, the default value will be returned. - * + * * @param path path to node (dot notation) * @return boolean or null */ @@ -363,7 +363,7 @@ public Boolean getBoolean(String path) { * Gets a boolean at a location. This will either return an boolean * or the default value. If the object at the particular location is not * actually a boolean, the default value will be returned. - * + * * @param path path to node (dot notation) * @param def default value * @return boolean or default @@ -377,11 +377,11 @@ public boolean getBoolean(String path, boolean def) { return o; } } - + /** * Get a list of keys at a location. If the map at the particular location * does not exist or it is not a map, null will be returned. - * + * * @param path path to node (dot notation) * @return list of keys */ @@ -401,7 +401,7 @@ public List getKeys(String path) { /** * Gets a list of objects at a location. If the list is not defined, * null will be returned. The node must be an actual list. - * + * * @param path path to node (dot notation) * @return boolean or default */ @@ -416,7 +416,7 @@ public List getList(String path) { return null; } } - + /** * Gets a list of strings. Non-valid entries will not be in the list. * There will be no null slots. If the list is not defined, the @@ -424,7 +424,7 @@ public List getList(String path) { * and an empty list will be returned instead. If an item in the list * is not a string, it will be converted to a string. The node must be * an actual list and not just a string. - * + * * @param path path to node (dot notation) * @param def default value or null for an empty list as default * @return list of strings @@ -440,20 +440,20 @@ public List getStringList(String path, List def) { if (o == null) { continue; } - + list.add(o.toString()); } - + return list; } - + /** * Gets a list of integers. Non-valid entries will not be in the list. * There will be no null slots. If the list is not defined, the * default will be returned. 'null' can be passed for the default * and an empty list will be returned instead. The node must be * an actual list and not just an integer. - * + * * @param path path to node (dot notation) * @param def default value or null for an empty list as default * @return list of integers @@ -471,17 +471,17 @@ public List getIntList(String path, List def) { list.add(i); } } - + return list; } - + /** * Gets a list of doubles. Non-valid entries will not be in the list. * There will be no null slots. If the list is not defined, the * default will be returned. 'null' can be passed for the default * and an empty list will be returned instead. The node must be * an actual list and cannot be just a double. - * + * * @param path path to node (dot notation) * @param def default value or null for an empty list as default * @return list of integers @@ -499,17 +499,17 @@ public List getDoubleList(String path, List def) { list.add(i); } } - + return list; } - + /** * Gets a list of booleans. Non-valid entries will not be in the list. * There will be no null slots. If the list is not defined, the * default will be returned. 'null' can be passed for the default * and an empty list will be returned instead. The node must be * an actual list and cannot be just a boolean, - * + * * @param path path to node (dot notation) * @param def default value or null for an empty list as default * @return list of integers @@ -527,111 +527,111 @@ public List getBooleanList(String path, List def) { list.add(tetsu); } } - + return list; } - + /** * Gets a list of vectors. Non-valid entries will not be in the list. * There will be no null slots. If the list is not defined, the * default will be returned. 'null' can be passed for the default * and an empty list will be returned instead. The node must be * an actual node and cannot be just a vector, - * + * * @param path path to node (dot notation) * @param def default value or null for an empty list as default * @return list of integers */ public List getVectorList( String path, List def) { - + List raw = getNodeList(path, null); List list = new ArrayList(); - + for (ConfigurationNode o : raw) { Double x = o.getDouble("x"); Double y = o.getDouble("y"); Double z = o.getDouble("z"); - + if (x == null || y == null || z == null) { continue; } - + list.add(new Vector(x, y, z)); } - + return list; } - + /** * Gets a list of 2D vectors. Non-valid entries will not be in the list. * There will be no null slots. If the list is not defined, the * default will be returned. 'null' can be passed for the default * and an empty list will be returned instead. The node must be * an actual node and cannot be just a vector, - * + * * @param path path to node (dot notation) * @param def default value or null for an empty list as default * @return list of integers */ public List getVector2dList( String path, List def) { - + List raw = getNodeList(path, null); List list = new ArrayList(); - + for (ConfigurationNode o : raw) { Double x = o.getDouble("x"); Double z = o.getDouble("z"); - + if (x == null || z == null) { continue; } - + list.add(new Vector2D(x, z)); } - + return list; } - + /** * Gets a list of 2D vectors. Non-valid entries will not be in the list. * There will be no null slots. If the list is not defined, the * default will be returned. 'null' can be passed for the default * and an empty list will be returned instead. The node must be * an actual node and cannot be just a vector, - * + * * @param path path to node (dot notation) * @param def default value or null for an empty list as default * @return list of integers */ public List getBlockVector2dList( String path, List def) { - + List raw = getNodeList(path, null); List list = new ArrayList(); - + for (ConfigurationNode o : raw) { Double x = o.getDouble("x"); Double z = o.getDouble("z"); - + if (x == null || z == null) { continue; } - + list.add(new BlockVector2D(x, z)); } - + return list; } - + /** * Gets a list of nodes. Non-valid entries will not be in the list. * There will be no null slots. If the list is not defined, the * default will be returned. 'null' can be passed for the default * and an empty list will be returned instead. The node must be * an actual node and cannot be just a boolean, - * + * * @param path path to node (dot notation) * @param def default value or null for an empty list as default * @return list of integers @@ -649,15 +649,15 @@ public List getNodeList(String path, List list.add(new ConfigurationNode((Map)o)); } } - + return list; } - + /** * Get a configuration node at a path. If the node doesn't exist or the * path does not lead to a node, null will be returned. A node has * key/value mappings. - * + * * @param path * @return node or null */ @@ -667,14 +667,14 @@ public ConfigurationNode getNode(String path) { if (raw instanceof Map) { return new ConfigurationNode((Map)raw); } - + return null; } - + /** * Get a list of nodes at a location. If the map at the particular location * does not exist or it is not a map, null will be returned. - * + * * @param path path to node (dot notation) * @return map of nodes */ @@ -686,23 +686,23 @@ public Map getNodes(String path) { } else if (o instanceof Map) { Map nodes = new HashMap(); - + for (Map.Entry entry : ((Map)o).entrySet()) { if (entry.getValue() instanceof Map) { nodes.put(entry.getKey(), new ConfigurationNode((Map) entry.getValue())); } } - + return nodes; } else { return null; } } - + /** * Casts a value to an integer. May return null. - * + * * @param o * @return */ @@ -723,10 +723,10 @@ private static Integer castInt(Object o) { return null; } } - + /** * Casts a value to a double. May return null. - * + * * @param o * @return */ @@ -747,10 +747,10 @@ private static Double castDouble(Object o) { return null; } } - + /** * Casts a value to a boolean. May return null. - * + * * @param o * @return */ @@ -763,11 +763,11 @@ private static Boolean castBoolean(Object o) { return null; } } - + /** * Remove the property at a location. This will override existing * configuration data to have it conform to key/value mappings. - * + * * @param path */ @SuppressWarnings("unchecked") @@ -776,19 +776,19 @@ public void removeProperty(String path) { root.remove(path); return; } - + String[] parts = path.split("\\."); Map node = root; - + for (int i = 0; i < parts.length; i++) { Object o = node.get(parts[i]); - + // Found our target! if (i == parts.length - 1) { node.remove(parts[i]); return; } - + node = (Map)o; } }