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.
*
* @author Citymonstret
* @author Empire92
*/
public enum Command {
@ -37,6 +38,9 @@ public enum Command {
// - /plot rate <number out of 10>
// - /plot list <some parameter to list the most popular, and highest rated
// plots>
/**
*
*/
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;

View File

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

View File

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

View File

@ -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
* <p/>
* Such as: /plot claim
*/
CLAIMING("Claiming"),
/**
* Teleportation Commands
* <p/>
* Such as: /plot visit
*/
TELEPORT("Teleportation"),
/**
* Action Commands
* <p/>
* Such as: /plot clear
*/
ACTIONS("Actions"),
/**
* Information Commands
* <p/>
* Such as: /plot info
*/
INFO("Information"),
/**
* Debug Commands
* <p/>
* 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;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -30,6 +30,8 @@ import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
/**
* SetBlockFast class<br>
* 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++) {

View File

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

View File

@ -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<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>());
@ -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<StringWrapper, UUID> 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);

View File

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

View File

@ -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<StringWrapper, UUID> 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;
}

View File

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