More documentation :_:

This commit is contained in:
Sauilitired 2014-11-20 00:00:38 +01:00
parent 6f73193cfb
commit 7b83ea2413
16 changed files with 291 additions and 51 deletions

View File

@ -25,6 +25,7 @@ package com.intellectualcrafters.plot.commands;
* Created by Citymonstret on 2014-08-03. * Created by Citymonstret on 2014-08-03.
* *
* @author Citymonstret * @author Citymonstret
* @author Empire92
*/ */
public enum Command { public enum Command {
@ -37,6 +38,9 @@ public enum Command {
// - /plot rate <number out of 10> // - /plot rate <number out of 10>
// - /plot list <some parameter to list the most popular, and highest rated // - /plot list <some parameter to list the most popular, and highest rated
// plots> // plots>
/**
*
*/
SWAP("swap"), SWAP("swap"),
/** /**
* *
@ -58,7 +62,13 @@ public enum Command {
* *
*/ */
PASTE("paste"), PASTE("paste"),
/**
*
*/
CLIPBOARD("clipboard", "cboard"), CLIPBOARD("clipboard", "cboard"),
/**
*
*/
COPY("copy"), COPY("copy"),
/** /**
* *
@ -128,26 +138,44 @@ public enum Command {
* *
*/ */
OP("op", "admin"), OP("op", "admin"),
/**
*
*/
DEOP("deop", "deadmin"), DEOP("deop", "deadmin"),
/**
*
*/
BAN("ban", "block"), BAN("ban", "block"),
/**
*
*/
UNBAN("unban", "unblock"), UNBAN("unban", "unblock"),
/**
*
*/
DATABASE("database", "convert"), DATABASE("database", "convert"),
/**
*
*/
TP("tp", "tp"); 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) { Command(final String command) {
this.command = command; this.command = command;
@ -156,8 +184,8 @@ public enum Command {
} }
/** /**
* @param command * @param command Command "name" (/plot [cmd])
* @param permission * @param permission Command Permission Node
*/ */
Command(final String command, final CommandPermission permission) { Command(final String command, final CommandPermission permission) {
this.command = command; this.command = command;
@ -166,8 +194,8 @@ public enum Command {
} }
/** /**
* @param command * @param command Command "name" (/plot [cmd])
* @param alias * @param alias Command Alias
*/ */
Command(final String command, final String alias) { Command(final String command, final String alias) {
this.command = command; this.command = command;
@ -176,9 +204,9 @@ public enum Command {
} }
/** /**
* @param Command * @param command Command "name" (/plot [cmd])
* @param alias * @param alias Command Alias
* @param permission * @param permission Required Permission Node
*/ */
Command(final String command, final String alias, final CommandPermission permission) { Command(final String command, final String alias, final CommandPermission permission) {
this.command = command; this.command = command;
@ -187,21 +215,22 @@ public enum Command {
} }
/** /**
* @return * @return command
*/ */
public String getCommand() { public String getCommand() {
return this.command; return this.command;
} }
/** /**
* @return * @return alias
*/ */
public String getAlias() { public String getAlias() {
return this.alias; return this.alias;
} }
/** /**
* @return * @return permission object
* @see com.intellectualcrafters.plot.commands.CommandPermission
*/ */
public CommandPermission getPermission() { public CommandPermission getPermission() {
return this.permission; return this.permission;

View File

@ -32,9 +32,9 @@ import org.bukkit.entity.Player;
public class CommandPermission { public class CommandPermission {
/** /**
* * Permission Node
*/ */
public String permission; public final String permission;
/** /**
* @param permission Command Permission * @param permission Command Permission

View File

@ -43,6 +43,9 @@ import java.util.List;
*/ */
public class MainCommand implements CommandExecutor, TabCompleter { public class MainCommand implements CommandExecutor, TabCompleter {
/**
* Main Permission Node
*/
public static final String public static final String
MAIN_PERMISSION = "plots.use"; MAIN_PERMISSION = "plots.use";

View File

@ -30,32 +30,37 @@ import org.bukkit.entity.Player;
* *
* @author Citymonstret * @author Citymonstret
*/ */
@SuppressWarnings({"deprecation", "unused", "javadoc"}) @SuppressWarnings({"deprecation", "unused"})
public abstract class SubCommand { public abstract class SubCommand {
public boolean isPlayer;
/** /**
* Command * Command
*/ */
public String cmd; public final String cmd;
/** /**
* Permission node * Permission node
*/ */
public CommandPermission permission; public final CommandPermission permission;
/** /**
* Simple description * Simple description
*/ */
public String description; public final String description;
/** /**
* Alias * Alias
*/ */
public String alias; public final String alias;
/** /**
* Command usage * Command usage
*/ */
public String usage; public final String usage;
/**
public CommandCategory category; * The category
*/
public final CommandCategory category;
/**
* Is this a player-online command?
*/
public boolean isPlayer;
/** /**
* @param cmd Command /plot {cmd} <-- That! * @param cmd Command /plot {cmd} <-- That!
@ -100,6 +105,11 @@ public abstract class SubCommand {
*/ */
public abstract boolean execute(final Player plr, final String... args); public abstract boolean execute(final Player plr, final String... args);
/**
* Execute the command as console
*
* @param args Arguments
*/
public void executeConsole(final String... args) { public void executeConsole(final String... args) {
this.execute(null, args); this.execute(null, args);
} }
@ -107,23 +117,64 @@ public abstract class SubCommand {
/** /**
* Send a message * Send a message
* *
* @param plr * @param plr Player who will receive the mssage
* @param c * @param c Caption
* @param args * @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) { public boolean sendMessage(final Player plr, final C c, final String... args) {
PlayerFunctions.sendMessage(plr, c, args); PlayerFunctions.sendMessage(plr, c, args);
return true; return true;
} }
/**
* CommandCategory
*
* @author Citymonstret
* @author Empire92
*/
public enum CommandCategory { public enum CommandCategory {
/**
* Claiming Commands
* <p/>
* Such as: /plot claim
*/
CLAIMING("Claiming"), CLAIMING("Claiming"),
/**
* Teleportation Commands
* <p/>
* Such as: /plot visit
*/
TELEPORT("Teleportation"), TELEPORT("Teleportation"),
/**
* Action Commands
* <p/>
* Such as: /plot clear
*/
ACTIONS("Actions"), ACTIONS("Actions"),
/**
* Information Commands
* <p/>
* Such as: /plot info
*/
INFO("Information"), INFO("Information"),
/**
* Debug Commands
* <p/>
* Such as: /plot debug
*/
DEBUG("Debug"); DEBUG("Debug");
private String name;
/**
* The category name (Readable)
*/
private final String name;
/**
* Constructor
*
* @param name readable name
*/
CommandCategory(final String name) { CommandCategory(final String name) {
this.name = name; this.name = name;
} }

View File

@ -367,13 +367,6 @@ public enum C {
HELP_INFO("&6You have to specify a category"), HELP_INFO("&6You have to specify a category"),
HELP_INFO_ITEM("&6/plots help %category% &c- &6%category_desc%"), HELP_INFO_ITEM("&6/plots help %category% &c- &6%category_desc%"),
HELP_ITEM("&6%usage% [%alias%]\n &c%desc%\n"), 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 * Direction
*/ */
@ -382,13 +375,33 @@ public enum C {
* Custom * Custom
*/ */
CUSTOM_STRING("-"); 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; private static TranslationManager manager;
/**
* The default file
*
* @see com.intellectualsites.translation.TranslationFile
*/
private static TranslationFile defaultFile; private static TranslationFile defaultFile;
/** /**
* Default * Default
*/ */
private String d; private String d;
/** /**
* Translated * Translated
*/ */
@ -472,6 +485,7 @@ public enum C {
/** /**
* @return translated and color decoded * @return translated and color decoded
* @see org.bukkit.ChatColor#translateAlternateColorCodes(char, String)
*/ */
public String translated() { public String translated() {
return ChatColor.translateAlternateColorCodes('&', this.s()); return ChatColor.translateAlternateColorCodes('&', this.s());

View File

@ -26,6 +26,11 @@ import org.apache.commons.lang.StringUtils;
import java.util.Arrays; import java.util.Arrays;
/**
* Configuration Node
*
* @author Empire92
*/
public class ConfigurationNode { public class ConfigurationNode {
private final String constant; private final String constant;
private final Object default_value; private final Object default_value;

View File

@ -29,66 +29,91 @@ package com.intellectualcrafters.plot.config;
*/ */
public class Settings { public class Settings {
/**
* Mob Cap Enabled
*/
public static boolean MOB_CAP_ENABLED = false; public static boolean MOB_CAP_ENABLED = false;
/**
* The Mob Cap
*/
public static int MOB_CAP = 20; public static int MOB_CAP = 20;
/**
* Display titles
*/
public static boolean TITLES = true; public static boolean TITLES = true;
/** /**
* Schematic Save Path * Schematic Save Path
*/ */
public static String SCHEMATIC_SAVE_PATH = "/var/www/schematics"; public static String SCHEMATIC_SAVE_PATH = "/var/www/schematics";
/** /**
* Max allowed plots * Max allowed plots
*/ */
public static int MAX_PLOTS = 20; public static int MAX_PLOTS = 20;
/** /**
* WorldGuard region on claimed plots * WorldGuard region on claimed plots
*/ */
public static boolean WORLDGUARD = false; public static boolean WORLDGUARD = false;
/** /**
* metrics * metrics
*/ */
public static boolean METRICS = true; public static boolean METRICS = true;
/** /**
* plot specific resource pack * plot specific resource pack
*/ */
public static String PLOT_SPECIFIC_RESOURCE_PACK = ""; public static String PLOT_SPECIFIC_RESOURCE_PACK = "";
/** /**
* Kill road mobs? * Kill road mobs?
*/ */
public static boolean KILL_ROAD_MOBS; public static boolean KILL_ROAD_MOBS;
/** /**
* Default kill road mobs: true * Default kill road mobs: true
*/ */
public static boolean KILL_ROAD_MOBS_DEFAULT = true; public static boolean KILL_ROAD_MOBS_DEFAULT = true;
/** /**
* mob pathfinding? * mob pathfinding?
*/ */
public static boolean MOB_PATHFINDING; public static boolean MOB_PATHFINDING;
/** /**
* Default mob pathfinding: true * Default mob pathfinding: true
*/ */
public static boolean MOB_PATHFINDING_DEFAULT = true; public static boolean MOB_PATHFINDING_DEFAULT = true;
/** /**
* Delete plots on ban? * Delete plots on ban?
*/ */
public static boolean DELETE_PLOTS_ON_BAN = false; public static boolean DELETE_PLOTS_ON_BAN = false;
/** /**
* Verbose? * Verbose?
*/ */
public static boolean DEBUG = true; public static boolean DEBUG = true;
/** /**
* Auto clear enabled * Auto clear enabled
*/ */
public static boolean AUTO_CLEAR = false; public static boolean AUTO_CLEAR = false;
/** /**
* Days until a plot gets cleared * Days until a plot gets cleared
*/ */
public static int AUTO_CLEAR_DAYS = 365; public static int AUTO_CLEAR_DAYS = 365;
/** /**
* API Location * API Location
*/ */
public static String API_URL = "http://www.intellectualsites.com/minecraft.php"; public static String API_URL = "http://www.intellectualsites.com/minecraft.php";
/** /**
* Use the custom API * Use the custom API
*/ */

View File

@ -39,10 +39,11 @@ import org.bukkit.entity.Player;
/** /**
* @author Citymonstret * @author Citymonstret
* @author Empire92
*/ */
@SuppressWarnings("ALL")
public class PWE { public class PWE {
@SuppressWarnings("deprecation")
public static void setMask(final Player p, final Location l) { public static void setMask(final Player p, final Location l) {
try { try {
LocalSession s; LocalSession s;

View File

@ -830,6 +830,13 @@ public class PlotHelper {
return 64; 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) { public static Location getPlotHome(final World w, final PlotId plotid) {
if (getPlot(w, plotid).settings.getPosition() == PlotHomePosition.DEFAULT) { 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) { public static Location getPlotHome(final World w, final Plot plot) {
return getPlotHome(w, plot.id); 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) { public static void refreshPlotChunks(final World world, final Plot plot) {
final int bottomX = getPlotBottomLoc(world, plot.id).getBlockX(); final int bottomX = getPlotBottomLoc(world, plot.id).getBlockX();
final int topX = getPlotTopLoc(world, plot.id).getBlockX(); final int topX = getPlotTopLoc(world, plot.id).getBlockX();

View File

@ -45,7 +45,6 @@ import java.util.zip.GZIPOutputStream;
* @author Citymonstret * @author Citymonstret
* @author Empire92 * @author Empire92
*/ */
@SuppressWarnings({"all"})
public class SchematicHandler { public class SchematicHandler {
/** /**
* Paste a schematic * Paste a schematic
@ -125,7 +124,9 @@ public class SchematicHandler {
{ {
final File parent = new File(JavaPlugin.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics"); final File parent = new File(JavaPlugin.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics");
if (!parent.exists()) { 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"); 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 * @param id plot
* @return tag * @return tag
*/ */
@SuppressWarnings("deprecation")
public static CompoundTag getCompoundTag(final World world, final PlotId id) { public static CompoundTag getCompoundTag(final World world, final PlotId id) {
if (!PlotMain.getPlots(world).containsKey(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)); final Block block = world.getBlockAt(new Location(world, pos1.getBlockX() + x, y, pos1.getBlockZ() + z));
@SuppressWarnings("deprecation")
final int id2 = block.getTypeId(); final int id2 = block.getTypeId();
if (id2 > 255) { if (id2 > 255) {

View File

@ -30,6 +30,8 @@ import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
/** /**
* SetBlockFast class<br> * SetBlockFast class<br>
* Used to do fast world editing * Used to do fast world editing
*
* @author Empire92
*/ */
public class SetBlockFast { public class SetBlockFast {
@ -43,6 +45,11 @@ public class SetBlockFast {
private static RefMethod methodA; private static RefMethod methodA;
private static RefMethod methodGetById; private static RefMethod methodGetById;
/**
* Constructor
*
* @throws NoSuchMethodException
*/
public SetBlockFast() throws NoSuchMethodException { public SetBlockFast() throws NoSuchMethodException {
methodGetHandle = classCraftWorld.getMethod("getHandle"); methodGetHandle = classCraftWorld.getMethod("getHandle");
methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, int.class); methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, int.class);
@ -50,6 +57,17 @@ public class SetBlockFast {
methodGetById = classBlock.getMethod("getById", int.class); 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 { 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(); final Object w = methodGetHandle.of(world).call();
@ -59,6 +77,10 @@ public class SetBlockFast {
return true; return true;
} }
/**
* Update chunks
* @param player Player whose chunks we're updating
*/
public static void update(final org.bukkit.entity.Player player) { public static void update(final org.bukkit.entity.Player player) {
final int distance = Bukkit.getViewDistance() + 1; final int distance = Bukkit.getViewDistance() + 1;
for (int cx = -distance; cx < distance; cx++) { for (int cx = -distance; cx < distance; cx++) {

View File

@ -36,12 +36,14 @@ public class StringComparison {
* Best Match * Best Match
*/ */
private String bestMatch; private String bestMatch;
/** /**
* Match Value * Match Value
* <p/> * <p/>
* Can be checked for low match (< .25 or something) * Can be checked for low match (< .25 or something)
*/ */
private double match = 0; private double match = 0;
/** /**
* The actual object * The actual object
*/ */

View File

@ -71,7 +71,8 @@ public class UUIDHandler {
private static boolean online = Bukkit.getServer().getOnlineMode(); 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<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>()); private static BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>());
@ -79,6 +80,7 @@ public class UUIDHandler {
* Get the map containing all names/uuids * Get the map containing all names/uuids
* *
* @return map with names + uuids * @return map with names + uuids
* @see com.google.common.collect.BiMap
*/ */
public static BiMap<StringWrapper, UUID> getUuidMap() { public static BiMap<StringWrapper, UUID> getUuidMap() {
return uuidMap; return uuidMap;
@ -89,6 +91,7 @@ public class UUIDHandler {
* *
* @param uuid to check * @param uuid to check
* @return true of the uuid is cached * @return true of the uuid is cached
* @see com.google.common.collect.BiMap#containsValue(Object)
*/ */
public static boolean uuidExists(final UUID uuid) { public static boolean uuidExists(final UUID uuid) {
return uuidMap.containsValue(uuid); return uuidMap.containsValue(uuid);
@ -99,6 +102,7 @@ public class UUIDHandler {
* *
* @param name to check * @param name to check
* @return true of the name is cached * @return true of the name is cached
* @see com.google.common.collect.BiMap#containsKey(Object)
*/ */
public static boolean nameExists(final StringWrapper name) { public static boolean nameExists(final StringWrapper name) {
return uuidMap.containsKey(name); return uuidMap.containsKey(name);

View File

@ -38,6 +38,9 @@ import java.util.UUID;
/** /**
* Plot UUID Saver/Fetcher * Plot UUID Saver/Fetcher
*
* @author Citymonstret
* @author Empire92
*/ */
public class PlotUUIDSaver implements UUIDSaver { public class PlotUUIDSaver implements UUIDSaver {

View File

@ -30,17 +30,57 @@ import java.util.UUID;
* @author Citymonstret * @author Citymonstret
*/ */
public interface UUIDSaver { public interface UUIDSaver {
/**
* Populate the default list
*/
public void globalPopulate(); public void globalPopulate();
/**
* Save the UUIDs
*
* @param biMap Map containing names and UUIDs
*/
public void globalSave(final BiMap<StringWrapper, UUID> biMap); public void globalSave(final BiMap<StringWrapper, UUID> biMap);
/**
* Save a single UUIDSet
*
* @param set Set to save
*/
public void save(final UUIDSet set); public void save(final UUIDSet set);
/**
* Get a single UUIDSet
*
* @param name Username
* @return UUID Set
*/
public UUIDSet get(final String name); public UUIDSet get(final String name);
/**
* Get a single UUIDSet
*
* @param uuid UUID
* @return UUID Set
*/
public UUIDSet get(final UUID uuid); 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; 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; public String mojangName(final UUID uuid) throws Exception;
} }

View File

@ -27,9 +27,23 @@ import java.util.UUID;
* @author Citymonstret * @author Citymonstret
*/ */
public class UUIDSet { public class UUIDSet {
/**
* Player Name
*/
private final String name; private final String name;
/**
* Player UUID
*/
private final UUID uuid; private final UUID uuid;
/**
* Constructor
*
* @param name Username
* @param uuid UUID
*/
public UUIDSet(final String name, final UUID uuid) { public UUIDSet(final String name, final UUID uuid) {
this.name = name; this.name = name;
this.uuid = uuid; this.uuid = uuid;
@ -40,6 +54,11 @@ public class UUIDSet {
return getName(); return getName();
} }
/**
* Return the name
*
* @return Name
*/
public String getName() { public String getName() {
return this.name; return this.name;
} }