From 7b83ea241310f3710894b01cad49d1da82ab8489 Mon Sep 17 00:00:00 2001 From: Sauilitired Date: Thu, 20 Nov 2014 00:00:38 +0100 Subject: [PATCH] More documentation :_: --- .../plot/commands/Command.java | 75 ++++++++++++------ .../plot/commands/CommandPermission.java | 4 +- .../plot/commands/MainCommand.java | 3 + .../plot/commands/SubCommand.java | 79 +++++++++++++++---- .../intellectualcrafters/plot/config/C.java | 30 +++++-- .../plot/config/ConfigurationNode.java | 5 ++ .../plot/config/Settings.java | 25 ++++++ .../intellectualcrafters/plot/util/PWE.java | 3 +- .../plot/util/PlotHelper.java | 19 +++++ .../plot/util/SchematicHandler.java | 7 +- .../plot/util/SetBlockFast.java | 22 ++++++ .../plot/util/StringComparison.java | 2 + .../plot/util/UUIDHandler.java | 6 +- .../plot/uuid/PlotUUIDSaver.java | 3 + .../plot/uuid/UUIDSaver.java | 40 ++++++++++ .../plot/uuid/UUIDSet.java | 19 +++++ 16 files changed, 291 insertions(+), 51 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java index 214d721b6..dae1897d7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java @@ -25,6 +25,7 @@ package com.intellectualcrafters.plot.commands; * Created by Citymonstret on 2014-08-03. * * @author Citymonstret + * @author Empire92 */ public enum Command { @@ -37,6 +38,9 @@ public enum Command { // - /plot rate // - /plot list + /** + * + */ SWAP("swap"), /** * @@ -58,7 +62,13 @@ public enum Command { * */ PASTE("paste"), + /** + * + */ CLIPBOARD("clipboard", "cboard"), + /** + * + */ COPY("copy"), /** * @@ -128,26 +138,44 @@ public enum Command { * */ OP("op", "admin"), + /** + * + */ DEOP("deop", "deadmin"), + /** + * + */ BAN("ban", "block"), + /** + * + */ UNBAN("unban", "unblock"), + /** + * + */ DATABASE("database", "convert"), + /** + * + */ TP("tp", "tp"); - /** - * - */ - private String command; - /** - * - */ - private String alias; - /** - * - */ - private CommandPermission permission; /** - * @param command + * Command + */ + private final String command; + + /** + * Alias + */ + private final String alias; + + /** + * Permission Node + */ + private final CommandPermission permission; + + /** + * @param command Command "name" (/plot [cmd]) */ Command(final String command) { this.command = command; @@ -156,8 +184,8 @@ public enum Command { } /** - * @param command - * @param permission + * @param command Command "name" (/plot [cmd]) + * @param permission Command Permission Node */ Command(final String command, final CommandPermission permission) { this.command = command; @@ -166,8 +194,8 @@ public enum Command { } /** - * @param command - * @param alias + * @param command Command "name" (/plot [cmd]) + * @param alias Command Alias */ Command(final String command, final String alias) { this.command = command; @@ -176,9 +204,9 @@ public enum Command { } /** - * @param Command - * @param alias - * @param permission + * @param command Command "name" (/plot [cmd]) + * @param alias Command Alias + * @param permission Required Permission Node */ Command(final String command, final String alias, final CommandPermission permission) { this.command = command; @@ -187,21 +215,22 @@ public enum Command { } /** - * @return + * @return command */ public String getCommand() { return this.command; } /** - * @return + * @return alias */ public String getAlias() { return this.alias; } /** - * @return + * @return permission object + * @see com.intellectualcrafters.plot.commands.CommandPermission */ public CommandPermission getPermission() { return this.permission; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java index aae7d4608..df4aa3a41 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java @@ -32,9 +32,9 @@ import org.bukkit.entity.Player; public class CommandPermission { /** - * + * Permission Node */ - public String permission; + public final String permission; /** * @param permission Command Permission diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index b87394576..39dd43acd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -43,6 +43,9 @@ import java.util.List; */ public class MainCommand implements CommandExecutor, TabCompleter { + /** + * Main Permission Node + */ public static final String MAIN_PERMISSION = "plots.use"; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java index 9658f4ba7..11616b1d6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java @@ -30,32 +30,37 @@ import org.bukkit.entity.Player; * * @author Citymonstret */ -@SuppressWarnings({"deprecation", "unused", "javadoc"}) +@SuppressWarnings({"deprecation", "unused"}) public abstract class SubCommand { - public boolean isPlayer; + /** * Command */ - public String cmd; + public final String cmd; /** * Permission node */ - public CommandPermission permission; + public final CommandPermission permission; /** * Simple description */ - public String description; + public final String description; /** * Alias */ - public String alias; - + public final String alias; /** * Command usage */ - public String usage; - - public CommandCategory category; + public final String usage; + /** + * The category + */ + public final CommandCategory category; + /** + * Is this a player-online command? + */ + public boolean isPlayer; /** * @param cmd Command /plot {cmd} <-- That! @@ -100,6 +105,11 @@ public abstract class SubCommand { */ public abstract boolean execute(final Player plr, final String... args); + /** + * Execute the command as console + * + * @param args Arguments + */ public void executeConsole(final String... args) { this.execute(null, args); } @@ -107,23 +117,64 @@ public abstract class SubCommand { /** * Send a message * - * @param plr - * @param c - * @param args + * @param plr Player who will receive the mssage + * @param c Caption + * @param args Arguments (%s's) + * @see com.intellectualcrafters.plot.util.PlayerFunctions#sendMessage(org.bukkit.entity.Player, com.intellectualcrafters.plot.config.C, String...) */ public boolean sendMessage(final Player plr, final C c, final String... args) { PlayerFunctions.sendMessage(plr, c, args); return true; } + /** + * CommandCategory + * + * @author Citymonstret + * @author Empire92 + */ public enum CommandCategory { + /** + * Claiming Commands + *

+ * Such as: /plot claim + */ CLAIMING("Claiming"), + /** + * Teleportation Commands + *

+ * Such as: /plot visit + */ TELEPORT("Teleportation"), + /** + * Action Commands + *

+ * Such as: /plot clear + */ ACTIONS("Actions"), + /** + * Information Commands + *

+ * Such as: /plot info + */ INFO("Information"), + /** + * Debug Commands + *

+ * Such as: /plot debug + */ DEBUG("Debug"); - private String name; + /** + * The category name (Readable) + */ + private final String name; + + /** + * Constructor + * + * @param name readable name + */ CommandCategory(final String name) { this.name = name; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 224eb31ca..16d0d6f7e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -367,13 +367,6 @@ public enum C { HELP_INFO("&6You have to specify a category"), HELP_INFO_ITEM("&6/plots help %category% &c- &6%category_desc%"), HELP_ITEM("&6%usage% [%alias%]\n &c%desc%\n"), - /* - HELP_CATEGORY("&6Current Category&c: &l%category%"), - HELP_INFO("&6You need to specify a help category"), - HELP_INFO_ITEM("&6/plots help %category% &c- &6%category_desc%"), - HELP_PAGE("&c>> &6%usage% &c[&6%alias%&c]\n" + "&c>> &6%desc%\n"), - HELP_ITEM_SEPARATOR("&c%lines"), - HELP_HEADER("&c(Page &6%cur&c/&6%max&c) &6Help for Plots"),*/ /* * Direction */ @@ -382,13 +375,33 @@ public enum C { * Custom */ CUSTOM_STRING("-"); - static TranslationLanguage lang = new TranslationLanguage("PlotSquared", "this", "use"); + + /** + * Special Language + * + * @see com.intellectualsites.translation.TranslationLanguage + */ + protected static TranslationLanguage lang = new TranslationLanguage("PlotSquared", "this", "use"); + + /** + * The TranslationManager + * + * @see com.intellectualsites.translation.TranslationManager + */ private static TranslationManager manager; + + /** + * The default file + * + * @see com.intellectualsites.translation.TranslationFile + */ private static TranslationFile defaultFile; + /** * Default */ private String d; + /** * Translated */ @@ -472,6 +485,7 @@ public enum C { /** * @return translated and color decoded + * @see org.bukkit.ChatColor#translateAlternateColorCodes(char, String) */ public String translated() { return ChatColor.translateAlternateColorCodes('&', this.s()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java index a0b45f773..11b6851ed 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java @@ -26,6 +26,11 @@ import org.apache.commons.lang.StringUtils; import java.util.Arrays; +/** + * Configuration Node + * + * @author Empire92 + */ public class ConfigurationNode { private final String constant; private final Object default_value; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java index 4544c7d48..158418483 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -29,66 +29,91 @@ package com.intellectualcrafters.plot.config; */ public class Settings { + /** + * Mob Cap Enabled + */ public static boolean MOB_CAP_ENABLED = false; + + /** + * The Mob Cap + */ public static int MOB_CAP = 20; + /** + * Display titles + */ public static boolean TITLES = true; + /** * Schematic Save Path */ public static String SCHEMATIC_SAVE_PATH = "/var/www/schematics"; + /** * Max allowed plots */ public static int MAX_PLOTS = 20; + /** * WorldGuard region on claimed plots */ public static boolean WORLDGUARD = false; + /** * metrics */ public static boolean METRICS = true; + /** * plot specific resource pack */ public static String PLOT_SPECIFIC_RESOURCE_PACK = ""; + /** * Kill road mobs? */ public static boolean KILL_ROAD_MOBS; + /** * Default kill road mobs: true */ public static boolean KILL_ROAD_MOBS_DEFAULT = true; + /** * mob pathfinding? */ public static boolean MOB_PATHFINDING; + /** * Default mob pathfinding: true */ public static boolean MOB_PATHFINDING_DEFAULT = true; + /** * Delete plots on ban? */ public static boolean DELETE_PLOTS_ON_BAN = false; + /** * Verbose? */ public static boolean DEBUG = true; + /** * Auto clear enabled */ public static boolean AUTO_CLEAR = false; + /** * Days until a plot gets cleared */ public static int AUTO_CLEAR_DAYS = 365; + /** * API Location */ public static String API_URL = "http://www.intellectualsites.com/minecraft.php"; + /** * Use the custom API */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java index b663f391f..442cb8af6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java @@ -39,10 +39,11 @@ import org.bukkit.entity.Player; /** * @author Citymonstret + * @author Empire92 */ +@SuppressWarnings("ALL") public class PWE { - @SuppressWarnings("deprecation") public static void setMask(final Player p, final Location l) { try { LocalSession s; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java index c12637607..25d921c53 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -830,6 +830,13 @@ public class PlotHelper { return 64; } + /** + * Get plot home + * + * @param w World in which the plot is located + * @param plotid Plot ID + * @return Home Location + */ public static Location getPlotHome(final World w, final PlotId plotid) { if (getPlot(w, plotid).settings.getPosition() == PlotHomePosition.DEFAULT) { @@ -849,10 +856,22 @@ public class PlotHelper { } } + /** + * Get the plot home + * @param w World + * @param plot Plot Object + * @return Plot Home Location + * @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) + */ public static Location getPlotHome(final World w, final Plot plot) { return getPlotHome(w, plot.id); } + /** + * Refresh the plot chunks + * @param world World in which the plot is located + * @param plot Plot Object + */ public static void refreshPlotChunks(final World world, final Plot plot) { final int bottomX = getPlotBottomLoc(world, plot.id).getBlockX(); final int topX = getPlotTopLoc(world, plot.id).getBlockX(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index 6e2c5c1c0..aea945977 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -45,7 +45,6 @@ import java.util.zip.GZIPOutputStream; * @author Citymonstret * @author Empire92 */ -@SuppressWarnings({"all"}) public class SchematicHandler { /** * Paste a schematic @@ -125,7 +124,9 @@ public class SchematicHandler { { final File parent = new File(JavaPlugin.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics"); if (!parent.exists()) { - parent.mkdir(); + if (!parent.mkdir()) { + throw new RuntimeException("Could not create schematic parent directory"); + } } } final File file = new File(JavaPlugin.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics" + File.separator + name + ".schematic"); @@ -252,6 +253,7 @@ public class SchematicHandler { * @param id plot * @return tag */ + @SuppressWarnings("deprecation") public static CompoundTag getCompoundTag(final World world, final PlotId id) { if (!PlotMain.getPlots(world).containsKey(id)) { @@ -307,6 +309,7 @@ public class SchematicHandler { final Block block = world.getBlockAt(new Location(world, pos1.getBlockX() + x, y, pos1.getBlockZ() + z)); + @SuppressWarnings("deprecation") final int id2 = block.getTypeId(); if (id2 > 255) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast.java index 6d080f717..fbbc82e9f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockFast.java @@ -30,6 +30,8 @@ import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; /** * SetBlockFast class
* Used to do fast world editing + * + * @author Empire92 */ public class SetBlockFast { @@ -43,6 +45,11 @@ public class SetBlockFast { private static RefMethod methodA; private static RefMethod methodGetById; + /** + * Constructor + * + * @throws NoSuchMethodException + */ public SetBlockFast() throws NoSuchMethodException { methodGetHandle = classCraftWorld.getMethod("getHandle"); methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, int.class); @@ -50,6 +57,17 @@ public class SetBlockFast { methodGetById = classBlock.getMethod("getById", int.class); } + /** + * Set the block at the location + * @param world World in which the block should be set + * @param x X Coordinate + * @param y Y Coordinate + * @param z Z Coordinate + * @param blockId Block ID + * @param data Block Data Value + * @return true + * @throws NoSuchMethodException + */ public static boolean set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data) throws NoSuchMethodException { final Object w = methodGetHandle.of(world).call(); @@ -59,6 +77,10 @@ public class SetBlockFast { return true; } + /** + * Update chunks + * @param player Player whose chunks we're updating + */ public static void update(final org.bukkit.entity.Player player) { final int distance = Bukkit.getViewDistance() + 1; for (int cx = -distance; cx < distance; cx++) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java index 58f011d70..487126a78 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java @@ -36,12 +36,14 @@ public class StringComparison { * Best Match */ private String bestMatch; + /** * Match Value *

* Can be checked for low match (< .25 or something) */ private double match = 0; + /** * The actual object */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java index cd3b23a8c..b849b8f10 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java @@ -71,7 +71,8 @@ public class UUIDHandler { private static boolean online = Bukkit.getServer().getOnlineMode(); /** - * Map containing names and UUID's + * Map containing names and UUIDs + * @see com.google.common.collect.BiMap */ private static BiMap uuidMap = HashBiMap.create(new HashMap()); @@ -79,6 +80,7 @@ public class UUIDHandler { * Get the map containing all names/uuids * * @return map with names + uuids + * @see com.google.common.collect.BiMap */ public static BiMap getUuidMap() { return uuidMap; @@ -89,6 +91,7 @@ public class UUIDHandler { * * @param uuid to check * @return true of the uuid is cached + * @see com.google.common.collect.BiMap#containsValue(Object) */ public static boolean uuidExists(final UUID uuid) { return uuidMap.containsValue(uuid); @@ -99,6 +102,7 @@ public class UUIDHandler { * * @param name to check * @return true of the name is cached + * @see com.google.common.collect.BiMap#containsKey(Object) */ public static boolean nameExists(final StringWrapper name) { return uuidMap.containsKey(name); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/PlotUUIDSaver.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/PlotUUIDSaver.java index 97ca78944..2258effb5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/PlotUUIDSaver.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/PlotUUIDSaver.java @@ -38,6 +38,9 @@ import java.util.UUID; /** * Plot UUID Saver/Fetcher + * + * @author Citymonstret + * @author Empire92 */ public class PlotUUIDSaver implements UUIDSaver { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDSaver.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDSaver.java index f84b8c64a..d0c4ee827 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDSaver.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDSaver.java @@ -30,17 +30,57 @@ import java.util.UUID; * @author Citymonstret */ public interface UUIDSaver { + + /** + * Populate the default list + */ public void globalPopulate(); + /** + * Save the UUIDs + * + * @param biMap Map containing names and UUIDs + */ public void globalSave(final BiMap biMap); + /** + * Save a single UUIDSet + * + * @param set Set to save + */ public void save(final UUIDSet set); + /** + * Get a single UUIDSet + * + * @param name Username + * @return UUID Set + */ public UUIDSet get(final String name); + /** + * Get a single UUIDSet + * + * @param uuid UUID + * @return UUID Set + */ public UUIDSet get(final UUID uuid); + /** + * Fetch uuid from mojang servers + * + * @param name Username + * @return uuid + * @throws Exception + */ public UUID mojangUUID(final String name) throws Exception; + /** + * Fetch username from mojang servers + * + * @param uuid UUID + * @return username + * @throws Exception + */ public String mojangName(final UUID uuid) throws Exception; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDSet.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDSet.java index 82e1554c2..8b8071bec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDSet.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDSet.java @@ -27,9 +27,23 @@ import java.util.UUID; * @author Citymonstret */ public class UUIDSet { + + /** + * Player Name + */ private final String name; + + /** + * Player UUID + */ private final UUID uuid; + /** + * Constructor + * + * @param name Username + * @param uuid UUID + */ public UUIDSet(final String name, final UUID uuid) { this.name = name; this.uuid = uuid; @@ -40,6 +54,11 @@ public class UUIDSet { return getName(); } + /** + * Return the name + * + * @return Name + */ public String getName() { return this.name; }