Reformat.

This commit is contained in:
drtshock
2014-12-17 20:15:11 -06:00
parent 59be72aefe
commit 73e92b8341
167 changed files with 3705 additions and 5553 deletions

View File

@@ -21,16 +21,6 @@
package com.intellectualcrafters.plot.api;
import java.util.ArrayList;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.commands.SubCommand;
@@ -41,31 +31,33 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.PlotSquaredException;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.*;
import com.sun.istack.internal.NotNull;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
import java.util.Set;
/**
* PlotSquared API
*
* @author Citymonstret
* @author Empire92
*
* @version API 2.0
*/
@SuppressWarnings("unused")
public class PlotAPI {
@SuppressWarnings("unused") public class PlotAPI {
/**
* Permission that allows for admin access,
* this permission node will allow the player
* to use any part of the plugin, without limitations.
* Permission that allows for admin access, this permission node will allow the player to use any part of the
* plugin, without limitations.
*/
public static final String ADMIN_PERMISSION = "plots.admin";
public static final String ADMIN_PERMISSION = "plots.admin";
/**
* Plot Helper Class
@@ -74,29 +66,29 @@ public class PlotAPI {
*
* @see com.intellectualcrafters.plot.util.PlotHelper
*/
private static PlotHelper plotHelper;
private static PlotHelper plotHelper;
/**
* Player Functions
*
* <p/>
* General functions involving players, and plot worlds
*
* @see com.intellectualcrafters.plot.util.PlayerFunctions
*/
private static PlayerFunctions playerFunctions;
private static PlayerFunctions playerFunctions;
/**
* Flag Manager
*
* <p/>
* The manager which handles all flags
*
* @see com.intellectualcrafters.plot.flag.FlagManager
*/
private static FlagManager flagManager;
private static FlagManager flagManager;
/**
* Schematic Handler
*
* <p/>
* The handler which is used to create, and paste, schematics
*
* @see com.intellectualcrafters.plot.util.SchematicHandler
@@ -108,25 +100,24 @@ public class PlotAPI {
*
* @see com.intellectualcrafters.plot.config.C
*/
private static C c;
private static C c;
/**
* PlotMain instance
*
* <p/>
* This is the instance that allows for most methods to be used.
*
* @see com.intellectualcrafters.plot.PlotMain
*/
private final PlotMain plotMain;
private final PlotMain plotMain;
/**
* Constructor. Insert any Plugin.
* (Optimally the plugin that is accessing the method)
* Constructor. Insert any Plugin. (Optimally the plugin that is accessing the method)
*
* @param plugin
* Plugin used to access this method
* @throws com.intellectualcrafters.plot.util.PlotSquaredException
* if the program fails to fetch the PlotMain instance
* @param plugin Plugin used to access this method
*
* @throws com.intellectualcrafters.plot.util.PlotSquaredException if the program fails to fetch the PlotMain
* instance
* @see com.intellectualcrafters.plot.PlotMain
*/
public PlotAPI(@NotNull final JavaPlugin plugin) {
@@ -140,6 +131,7 @@ public class PlotAPI {
* Get all plots
*
* @return all plots
*
* @see com.intellectualcrafters.plot.PlotMain#getPlots()
*/
public Set<Plot> getAllPlots() {
@@ -149,8 +141,8 @@ public class PlotAPI {
/**
* Return all plots for a player
*
* @param player
* Player, whose plots to search for
* @param player Player, whose plots to search for
*
* @return all plots that a player owns
*/
public Set<Plot> getPlayerPlots(@NotNull final Player player) {
@@ -160,15 +152,12 @@ public class PlotAPI {
/**
* Add a plot world
*
* @param world
* World Name
* @param plotWorld
* Plot World Object
* @param manager
* World Manager
* @see com.intellectualcrafters.plot.PlotMain#addPlotWorld(String,
* com.intellectualcrafters.plot.object.PlotWorld,
* com.intellectualcrafters.plot.object.PlotManager)
* @param world World Name
* @param plotWorld Plot World Object
* @param manager World Manager
*
* @see com.intellectualcrafters.plot.PlotMain#addPlotWorld(String, com.intellectualcrafters.plot.object.PlotWorld,
* com.intellectualcrafters.plot.object.PlotManager)
*/
public void addPlotWorld(@NotNull final String world, @NotNull final PlotWorld plotWorld, @NotNull final PlotManager manager) {
PlotMain.addPlotWorld(world, plotWorld, manager);
@@ -176,6 +165,7 @@ public class PlotAPI {
/**
* @return main configuration
*
* @see com.intellectualcrafters.plot.PlotMain#config
*/
public YamlConfiguration getConfig() {
@@ -184,6 +174,7 @@ public class PlotAPI {
/**
* @return storage configuration
*
* @see com.intellectualcrafters.plot.PlotMain#storage
*/
public YamlConfiguration getStorage() {
@@ -191,11 +182,11 @@ public class PlotAPI {
}
/**
* Get the main class for this plugin <br>
* - Contains a lot of fields and methods - not very well organized <br>
* Get the main class for this plugin <br> - Contains a lot of fields and methods - not very well organized <br>
* Only use this if you really need it
*
* @return PlotMain PlotSquared Main Class
*
* @see com.intellectualcrafters.plot.PlotMain
*/
public PlotMain getMain() {
@@ -206,6 +197,7 @@ public class PlotAPI {
* PlotHelper class contains useful methods relating to plots.
*
* @return PlotHelper
*
* @see com.intellectualcrafters.plot.util.PlotHelper
*/
public PlotHelper getPlotHelper() {
@@ -213,10 +205,10 @@ public class PlotAPI {
}
/**
* PlayerFunctions class contains useful methods relating to players - Some
* player/plot methods are here as well
* PlayerFunctions class contains useful methods relating to players - Some player/plot methods are here as well
*
* @return PlayerFunctions
*
* @see com.intellectualcrafters.plot.util.PlayerFunctions
*/
public PlayerFunctions getPlayerFunctions() {
@@ -227,6 +219,7 @@ public class PlotAPI {
* FlagManager class contains methods relating to plot flags
*
* @return FlagManager
*
* @see com.intellectualcrafters.plot.flag.FlagManager
*/
public FlagManager getFlagManager() {
@@ -237,6 +230,7 @@ public class PlotAPI {
* SchematicHandler class contains methods related to pasting schematics
*
* @return SchematicHandler
*
* @see com.intellectualcrafters.plot.util.SchematicHandler
*/
public SchematicHandler getSchematicHandler() {
@@ -247,6 +241,7 @@ public class PlotAPI {
* C class contains all the captions from the translations.yml file.
*
* @return C
*
* @see com.intellectualcrafters.plot.config.C
*/
public C getCaptions() {
@@ -254,12 +249,12 @@ public class PlotAPI {
}
/**
* Get the plot manager for a world. - Most of these methods can be accessed
* through the PlotHelper
* Get the plot manager for a world. - Most of these methods can be accessed through the PlotHelper
*
* @param world Which manager to get
*
* @param world
* Which manager to get
* @return PlotManager
*
* @see com.intellectualcrafters.plot.object.PlotManager
* @see PlotMain#getPlotManager(org.bukkit.World)
*/
@@ -268,12 +263,13 @@ public class PlotAPI {
}
/**
* Get the plot manager for a world. - Contains useful low level methods for
* plot merging, clearing, and tessellation
* Get the plot manager for a world. - Contains useful low level methods for plot merging, clearing, and
* tessellation
*
* @param world Plot World
*
* @param world
* Plot World
* @return PlotManager
*
* @see PlotMain#getPlotManager(String)
* @see com.intellectualcrafters.plot.object.PlotManager
*/
@@ -282,14 +278,13 @@ public class PlotAPI {
}
/**
* Get the settings for a world (settings bundled in PlotWorld class) - You
* will need to downcast for the specific settings a Generator has. e.g.
* DefaultPlotWorld class implements PlotWorld
* Get the settings for a world (settings bundled in PlotWorld class) - You will need to downcast for the specific
* settings a Generator has. e.g. DefaultPlotWorld class implements PlotWorld
*
* @param world (to get settings of)
*
* @return PlotWorld class for that world ! will return null if not a plot world world
*
* @param world
* (to get settings of)
* @return PlotWorld class for that world ! will return null if not a plot
* world world
* @see PlotMain#getWorldSettings(org.bukkit.World)
* @see com.intellectualcrafters.plot.object.PlotWorld
*/
@@ -300,10 +295,10 @@ public class PlotAPI {
/**
* Get the settings for a world (settings bundled in PlotWorld class)
*
* @param world
* (to get settings of)
* @return PlotWorld class for that world ! will return null if not a plot
* world world
* @param world (to get settings of)
*
* @return PlotWorld class for that world ! will return null if not a plot world world
*
* @see PlotMain#getWorldSettings(String)
* @see com.intellectualcrafters.plot.object.PlotWorld
*/
@@ -314,12 +309,11 @@ public class PlotAPI {
/**
* Send a message to a player.
*
* @param player
* Player that will receive the message
* @param c
* (Caption)
* @param player Player that will receive the message
* @param c (Caption)
*
* @see com.intellectualcrafters.plot.util.PlayerFunctions#sendMessage(org.bukkit.entity.Player,
* com.intellectualcrafters.plot.config.C, String...)
* com.intellectualcrafters.plot.config.C, String...)
*/
public void sendMessage(@NotNull final Player player, @NotNull final C c) {
PlayerFunctions.sendMessage(player, c);
@@ -328,12 +322,10 @@ public class PlotAPI {
/**
* Send a message to a player. - Supports color codes
*
* @param player
* Player that will receive the message
* @param string
* The message
* @see com.intellectualcrafters.plot.util.PlayerFunctions#sendMessage(org.bukkit.entity.Player,
* String)
* @param player Player that will receive the message
* @param string The message
*
* @see com.intellectualcrafters.plot.util.PlayerFunctions#sendMessage(org.bukkit.entity.Player, String)
*/
public void sendMessage(@NotNull final Player player, @NotNull final String string) {
PlayerFunctions.sendMessage(player, string);
@@ -342,8 +334,8 @@ public class PlotAPI {
/**
* Send a message to the console. - Supports color codes
*
* @param msg
* Message that should be sent to the console
* @param msg Message that should be sent to the console
*
* @see PlotMain#sendConsoleSenderMessage(String)
*/
public void sendConsoleMessage(@NotNull final String msg) {
@@ -353,8 +345,8 @@ public class PlotAPI {
/**
* Send a message to the console
*
* @param c
* (Caption)
* @param c (Caption)
*
* @see #sendConsoleMessage(String)
* @see com.intellectualcrafters.plot.config.C
*/
@@ -365,8 +357,8 @@ public class PlotAPI {
/**
* Register a flag for use in plots
*
* @param flag
* Flag that should be registered
* @param flag Flag that should be registered
*
* @see com.intellectualcrafters.plot.flag.FlagManager#addFlag(com.intellectualcrafters.plot.flag.AbstractFlag)
* @see com.intellectualcrafters.plot.flag.AbstractFlag
*/
@@ -378,6 +370,7 @@ public class PlotAPI {
* get all the currently registered flags
*
* @return array of Flag[]
*
* @see com.intellectualcrafters.plot.flag.FlagManager#getFlags()
* @see com.intellectualcrafters.plot.flag.AbstractFlag
*/
@@ -388,15 +381,13 @@ public class PlotAPI {
/**
* Get a plot based on the ID
*
* @param world
* World in which the plot is located
* @param x
* Plot Location X Co-ord
* @param z
* Plot Location Z Co-ord
* @param world World in which the plot is located
* @param x Plot Location X Co-ord
* @param z Plot Location Z Co-ord
*
* @return plot, null if ID is wrong
* @see PlotHelper#getPlot(org.bukkit.World,
* com.intellectualcrafters.plot.object.PlotId)
*
* @see PlotHelper#getPlot(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId)
* @see com.intellectualcrafters.plot.object.Plot
*/
public Plot getPlot(@NotNull final World world, final int x, final int z) {
@@ -406,9 +397,10 @@ public class PlotAPI {
/**
* Get a plot based on the location
*
* @param l
* The location that you want to to retrieve the plot from
* @param l The location that you want to to retrieve the plot from
*
* @return plot if found, otherwise it creates a temporary plot-
*
* @see PlotHelper#getCurrentPlot(org.bukkit.Location)
* @see com.intellectualcrafters.plot.object.Plot
*/
@@ -419,9 +411,10 @@ public class PlotAPI {
/**
* Get a plot based on the player location
*
* @param player
* Get the current plot for the player location
* @param player Get the current plot for the player location
*
* @return plot if found, otherwise it creates a temporary plot
*
* @see #getPlot(org.bukkit.Location)
* @see com.intellectualcrafters.plot.object.Plot
*/
@@ -432,9 +425,10 @@ public class PlotAPI {
/**
* Check whether or not a player has a plot
*
* @param player
* Player that you want to check for
* @param player Player that you want to check for
*
* @return true if player has a plot, false if not.
*
* @see #getPlots(org.bukkit.World, org.bukkit.entity.Player, boolean)
*/
public boolean hasPlot(@NotNull final World world, @NotNull final Player player) {
@@ -444,10 +438,9 @@ public class PlotAPI {
/**
* Get all plots for the player
*
* @param plr
* to search for
* @param just_owner
* should we just search for owner? Or with rights?
* @param plr to search for
* @param just_owner should we just search for owner? Or with rights?
*
* @see com.intellectualcrafters.plot.object.Plot
*/
public Plot[] getPlots(@NotNull final World world, @NotNull final Player plr, final boolean just_owner) {
@@ -457,8 +450,7 @@ public class PlotAPI {
if ((plot.owner != null) && (plot.owner == UUIDHandler.getUUID(plr))) {
pPlots.add(plot);
}
}
else {
} else {
if (plot.hasRights(plr)) {
pPlots.add(plot);
}
@@ -470,9 +462,10 @@ public class PlotAPI {
/**
* Get all plots for the world
*
* @param world
* to get plots of
* @param world to get plots of
*
* @return Plot[] - array of plot objects in world
*
* @see PlotMain#getWorldPlots(org.bukkit.World)
* @see com.intellectualcrafters.plot.object.Plot
*/
@@ -484,6 +477,7 @@ public class PlotAPI {
* Get all plot worlds
*
* @return World[] - array of plot worlds
*
* @see com.intellectualcrafters.plot.PlotMain#getPlotWorlds()
*/
public String[] getPlotWorlds() {
@@ -493,9 +487,10 @@ public class PlotAPI {
/**
* Get if plot world
*
* @param world
* (to check if plot world)
* @param world (to check if plot world)
*
* @return boolean (if plot world or not)
*
* @see com.intellectualcrafters.plot.PlotMain#isPlotWorld(org.bukkit.World)
*/
public boolean isPlotWorld(@NotNull final World world) {
@@ -505,31 +500,33 @@ public class PlotAPI {
/**
* Get plot locations
*
* @param p
* Plot that you want to get the locations for
* @param p Plot that you want to get the locations for
*
* @return [0] = bottomLc, [1] = topLoc, [2] = home
*
* @see com.intellectualcrafters.plot.util.PlotHelper#getPlotBottomLoc(org.bukkit.World,
* com.intellectualcrafters.plot.object.PlotId)
* com.intellectualcrafters.plot.object.PlotId)
* @see com.intellectualcrafters.plot.util.PlotHelper#getPlotTopLoc(org.bukkit.World,
* com.intellectualcrafters.plot.object.PlotId)
* com.intellectualcrafters.plot.object.PlotId)
* @see com.intellectualcrafters.plot.util.PlotHelper#getPlotHome(org.bukkit.World,
* com.intellectualcrafters.plot.object.Plot)
* com.intellectualcrafters.plot.object.Plot)
* @see com.intellectualcrafters.plot.object.PlotHomePosition
* @see com.intellectualcrafters.plot.object.Plot
*/
public Location[] getLocations(@NotNull final Plot p) {
final World world = Bukkit.getWorld(p.world);
return new Location[] { PlotHelper.getPlotBottomLoc(world, p.id), PlotHelper.getPlotTopLoc(world, p.id), PlotHelper.getPlotHome(world, p.id) };
return new Location[]{PlotHelper.getPlotBottomLoc(world, p.id), PlotHelper.getPlotTopLoc(world, p.id), PlotHelper.getPlotHome(world, p.id)};
}
/**
* Get home location
*
* @param p
* Plot that you want to get the location for
* @param p Plot that you want to get the location for
*
* @return plot bottom location
*
* @see com.intellectualcrafters.plot.util.PlotHelper#getPlotHome(org.bukkit.World,
* com.intellectualcrafters.plot.object.Plot)
* com.intellectualcrafters.plot.object.Plot)
* @see com.intellectualcrafters.plot.object.PlotHomePosition
* @see com.intellectualcrafters.plot.object.Plot
*/
@@ -540,11 +537,12 @@ public class PlotAPI {
/**
* Get Bottom Location (min, min, min)
*
* @param p
* Plot that you want to get the location for
* @param p Plot that you want to get the location for
*
* @return plot bottom location
*
* @see com.intellectualcrafters.plot.util.PlotHelper#getPlotBottomLoc(org.bukkit.World,
* com.intellectualcrafters.plot.object.PlotId)
* com.intellectualcrafters.plot.object.PlotId)
* @see com.intellectualcrafters.plot.object.Plot
*/
public Location getBottomLocation(@NotNull final Plot p) {
@@ -555,11 +553,11 @@ public class PlotAPI {
/**
* Get Top Location (max, max, max)
*
* @param p
* Plot that you want to get the location for
* @param p Plot that you want to get the location for
*
* @return plot top location
* @see PlotHelper#getPlotTopLoc(org.bukkit.World,
* com.intellectualcrafters.plot.object.PlotId)
*
* @see PlotHelper#getPlotTopLoc(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId)
* @see com.intellectualcrafters.plot.object.Plot
*/
public Location getTopLocation(@NotNull final Plot p) {
@@ -570,9 +568,10 @@ public class PlotAPI {
/**
* Check whether or not a player is in a plot
*
* @param player
* who we're checking for
* @param player who we're checking for
*
* @return true if the player is in a plot, false if not-
*
* @see com.intellectualcrafters.plot.util.PlayerFunctions#isInPlot(org.bukkit.entity.Player)
*/
public boolean isInPlot(@NotNull final Player player) {
@@ -582,8 +581,8 @@ public class PlotAPI {
/**
* Register a subcommand
*
* @param c
* SubCommand, that we want to register
* @param c SubCommand, that we want to register
*
* @see com.intellectualcrafters.plot.commands.MainCommand#subCommands
* @see com.intellectualcrafters.plot.commands.SubCommand
*/
@@ -595,6 +594,7 @@ public class PlotAPI {
* Get the plotMain class
*
* @return PlotMain Class
*
* @see com.intellectualcrafters.plot.PlotMain
*/
public PlotMain getPlotMain() {
@@ -604,13 +604,13 @@ public class PlotAPI {
/**
* Get the player plot count
*
* @param world
* Specify the world we want to select the plots from
* @param player
* Player, for whom we're getting the plot count
* @param world Specify the world we want to select the plots from
* @param player Player, for whom we're getting the plot count
*
* @return the number of plots the player has
*
* @see com.intellectualcrafters.plot.util.PlayerFunctions#getPlayerPlotCount(org.bukkit.World,
* org.bukkit.entity.Player)
* org.bukkit.entity.Player)
*/
public int getPlayerPlotCount(@NotNull final World world, @NotNull final Player player) {
return PlayerFunctions.getPlayerPlotCount(world, player);
@@ -619,13 +619,13 @@ public class PlotAPI {
/**
* Get a collection containing the players plots
*
* @param world
* Specify the world we want to select the plots from
* @param player
* Player, for whom we're getting the plots
* @param world Specify the world we want to select the plots from
* @param player Player, for whom we're getting the plots
*
* @return a set containing the players plots
*
* @see com.intellectualcrafters.plot.util.PlayerFunctions#getPlayerPlots(org.bukkit.World,
* org.bukkit.entity.Player)
* org.bukkit.entity.Player)
* @see com.intellectualcrafters.plot.object.Plot
*/
public Set<Plot> getPlayerPlots(@NotNull final World world, @NotNull final Player player) {
@@ -635,10 +635,10 @@ public class PlotAPI {
/**
* Get the numbers of plots, which the player is able to build in
*
* @param player
* Player, for whom we're getting the plots (trusted, helper and
* owner)
* @param player Player, for whom we're getting the plots (trusted, helper and owner)
*
* @return the number of allowed plots
*
* @see com.intellectualcrafters.plot.util.PlayerFunctions#getAllowedPlots(org.bukkit.entity.Player)
*/
public int getAllowedPlots(@NotNull final Player player) {