Reformat code

This commit is contained in:
sauilitired
2018-08-10 17:01:10 +02:00
parent 02ee1e8fa1
commit 1646cd0f5a
437 changed files with 12795 additions and 14203 deletions

View File

@ -7,16 +7,8 @@ import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.flag.Flags;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.util.BukkitUtil;
@ -26,44 +18,41 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.*;
/**
* PlotSquared API.
*
* <p>
* <p>Useful classes:
* <ul>
* <li>{@link BukkitUtil}</li>
* <li>{@link PlotPlayer}</li>
* <li>{@link Plot}</li>
* <li>{@link com.intellectualcrafters.plot.object.Location}</li>
* <li>{@link PlotArea}</li>
* <li>{@link PS}</li>
* <li>{@link BukkitUtil}</li>
* <li>{@link PlotPlayer}</li>
* <li>{@link Plot}</li>
* <li>{@link com.intellectualcrafters.plot.object.Location}</li>
* <li>{@link PlotArea}</li>
* <li>{@link PS}</li>
* </ul>
*
* @version 3.3.3
*/
public class PlotAPI {
/**
* Deprecated, does nothing.
*
* @param plugin not needed
* @deprecated Not needed
*/
@Deprecated
public PlotAPI(JavaPlugin plugin) {}
@Deprecated public PlotAPI(JavaPlugin plugin) {
}
public PlotAPI(){}
public PlotAPI() {
}
/**
* Get all plots.
*
* @return all plots
*
* @see PS#getPlots()
*/
public Set<Plot> getAllPlots() {
@ -74,7 +63,6 @@ public class PlotAPI {
* Return all plots for a player.
*
* @param player Player, whose plots to search for
*
* @return all plots that a player owns
*/
public Set<Plot> getPlayerPlots(Player player) {
@ -93,8 +81,8 @@ public class PlotAPI {
/**
* Returns the PlotSquared configurations file.
* @return main configuration
*
* @return main configuration
* @see PS#config
*/
public YamlConfiguration getConfig() {
@ -103,8 +91,8 @@ public class PlotAPI {
/**
* Get the PlotSquared storage file.
* @return storage configuration
*
* @return storage configuration
* @see PS#storage
*/
public YamlConfiguration getStorage() {
@ -115,7 +103,6 @@ public class PlotAPI {
* Get the main class for this plugin. Only use this if you really need it.
*
* @return PlotSquared PlotSquared Main Class
*
* @see PS
*/
public PS getMain() {
@ -125,15 +112,14 @@ public class PlotAPI {
/**
* ChunkManager class contains several useful methods.
* <ul>
* <li>Chunk deletion</li>
* <li>Moving or copying regions</li>
* <li>Plot swapping</li>
* <li>Entity Tracking</li>
* <li>Region Regeneration</li>
* <li>Chunk deletion</li>
* <li>Moving or copying regions</li>
* <li>Plot swapping</li>
* <li>Entity Tracking</li>
* <li>Region Regeneration</li>
* </ul>
*
* @return ChunkManager
*
* @see ChunkManager
*/
public ChunkManager getChunkManager() {
@ -142,6 +128,7 @@ public class PlotAPI {
/**
* Get the block/biome set queue
*
* @return GlobalBlockQueue.IMP
*/
public GlobalBlockQueue getBlockQueue() {
@ -153,7 +140,6 @@ public class PlotAPI {
* to use the UUIDHandler class instead.
*
* @return UUIDWrapper
*
* @see UUIDWrapper
*/
public UUIDWrapper getUUIDWrapper() {
@ -162,14 +148,12 @@ public class PlotAPI {
/**
* Do not use this. Instead use FlagManager.[method] in your code.
* - Flag related stuff
* - Flag related stuff
*
* @return FlagManager
*
* @deprecated Use {@link FlagManager} directly
*/
@Deprecated
public FlagManager getFlagManager() {
@Deprecated public FlagManager getFlagManager() {
return new FlagManager();
}
@ -179,8 +163,7 @@ public class PlotAPI {
* @return MainUtil
* @deprecated Use {@link MainUtil} directly
*/
@Deprecated
public MainUtil getMainUtil() {
@Deprecated public MainUtil getMainUtil() {
return new MainUtil();
}
@ -188,12 +171,10 @@ public class PlotAPI {
* Do not use this. Instead use C.PERMISSION_[method] in your code.
*
* @return Array of strings
*
* @see Permissions
* @deprecated Use {@link C} to list all the permissions
*/
@Deprecated
public String[] getPermissions() {
@Deprecated public String[] getPermissions() {
ArrayList<String> perms = new ArrayList<>();
for (C caption : C.values()) {
if ("static.permissions".equals(caption.getCategory())) {
@ -208,7 +189,6 @@ public class PlotAPI {
* and writing schematics.
*
* @return SchematicHandler
*
* @see SchematicHandler
*/
public SchematicHandler getSchematicHandler() {
@ -221,8 +201,7 @@ public class PlotAPI {
* @return C
* @deprecated Use {@link C}
*/
@Deprecated
public C[] getCaptions() {
@Deprecated public C[] getCaptions() {
return C.values();
}
@ -231,15 +210,11 @@ public class PlotAPI {
* through the MainUtil.
*
* @param world the world to retrieve the manager from
*
* @return PlotManager
*
* @see PlotManager
* @see PS#getPlotManager(Plot)
*/
@SuppressWarnings("deprecation")
@Deprecated
public PlotManager getPlotManager(World world) {
@SuppressWarnings("deprecation") @Deprecated public PlotManager getPlotManager(World world) {
if (world == null) {
return null;
}
@ -248,6 +223,7 @@ public class PlotAPI {
/**
* Get a list of PlotAreas in the world.
*
* @param world The world to check for plot areas
* @return A set of PlotAreas
*/
@ -263,14 +239,11 @@ public class PlotAPI {
* plot merging, clearing, and tessellation.
*
* @param world The world
*
* @return PlotManager
*
* @see PS#getPlotManager(Plot)
* @see PlotManager
*/
@Deprecated
public PlotManager getPlotManager(String world) {
@Deprecated public PlotManager getPlotManager(String world) {
Set<PlotArea> areas = PS.get().getPlotAreas(world);
switch (areas.size()) {
case 0:
@ -278,7 +251,8 @@ public class PlotAPI {
case 1:
return areas.iterator().next().manager;
default:
PS.debug("PlotAPI#getPlotManager(org.bukkit.World) is deprecated and doesn't support multi plot area worlds.");
PS.debug(
"PlotAPI#getPlotManager(org.bukkit.World) is deprecated and doesn't support multi plot area worlds.");
return null;
}
}
@ -289,15 +263,11 @@ public class PlotAPI {
* DefaultPlotWorld class implements PlotArea
*
* @param world The World
*
* @return The {@link PlotArea} for the world or null if not in plotworld
*
* @see #getPlotAreas(World)
* @see PlotArea
*/
@SuppressWarnings("deprecation")
@Deprecated
public PlotArea getWorldSettings(World world) {
@SuppressWarnings("deprecation") @Deprecated public PlotArea getWorldSettings(World world) {
if (world == null) {
return null;
}
@ -308,14 +278,11 @@ public class PlotAPI {
* Get the settings for a world.
*
* @param world the world to retrieve settings from
*
* @return The {@link PlotArea} for the world or null if not in plotworld
*
* @see PS#getPlotArea(String, String)
* @see PlotArea
*/
@Deprecated
public PlotArea getWorldSettings(String world) {
@Deprecated public PlotArea getWorldSettings(String world) {
if (world == null) {
return null;
}
@ -326,7 +293,8 @@ public class PlotAPI {
case 1:
return areas.iterator().next();
default:
PS.debug("PlotAPI#getWorldSettings(org.bukkit.World) is deprecated and doesn't support multi plot area worlds.");
PS.debug(
"PlotAPI#getWorldSettings(org.bukkit.World) is deprecated and doesn't support multi plot area worlds.");
return null;
}
}
@ -334,9 +302,8 @@ public class PlotAPI {
/**
* Send a message to a player.
*
* @param player the recipient of the message
* @param player the recipient of the message
* @param caption the message
*
* @see MainUtil#sendMessage(PlotPlayer, C, String...)
*/
public void sendMessage(Player player, C caption) {
@ -348,7 +315,6 @@ public class PlotAPI {
*
* @param player the recipient of the message
* @param string the message
*
* @see MainUtil#sendMessage(PlotPlayer, String)
*/
public void sendMessage(Player player, String string) {
@ -359,7 +325,6 @@ public class PlotAPI {
* Send a message to the console. The message supports color codes.
*
* @param message the message
*
* @see MainUtil#sendConsoleMessage(C, String...)
*/
public void sendConsoleMessage(String message) {
@ -370,7 +335,6 @@ public class PlotAPI {
* Send a message to the console.
*
* @param caption the message
*
* @see #sendConsoleMessage(String)
* @see C
*/
@ -382,7 +346,6 @@ public class PlotAPI {
* Registers a flag for use in plots.
*
* @param flag the flag to register
*
*/
public void addFlag(Flag<?> flag) {
Flags.registerFlag(flag);
@ -392,16 +355,12 @@ public class PlotAPI {
* Gets a plot based on the ID.
*
* @param world the world the plot is located in
* @param x The PlotID x coordinate
* @param z The PlotID y coordinate
*
* @param x The PlotID x coordinate
* @param z The PlotID y coordinate
* @return plot, null if ID is wrong
*
* @see PlotArea#getPlot(PlotId)
*/
@SuppressWarnings("deprecation")
@Deprecated
public Plot getPlot(World world, int x, int z) {
@SuppressWarnings("deprecation") @Deprecated public Plot getPlot(World world, int x, int z) {
if (world == null) {
return null;
}
@ -416,9 +375,7 @@ public class PlotAPI {
* Get a plot based on the location.
*
* @param location the location to check
*
* @return plot if found, otherwise it creates a temporary plot
*
* @see Plot
*/
public Plot getPlot(Location location) {
@ -432,9 +389,7 @@ public class PlotAPI {
* Get a plot based on the player location.
*
* @param player the player to check
*
* @return plot if found, otherwise it creates a temporary plot
*
* @see #getPlot(Location)
* @see Plot
*/
@ -446,27 +401,24 @@ public class PlotAPI {
* Check whether or not a player has a plot.
*
* @param player Player that you want to check for
* @param world The world to check
* @param world The world to check
* @return true if player has a plot, false if not.
*
* @see #getPlots(World, Player, boolean)
*/
@SuppressWarnings("deprecation")
@Deprecated
public boolean hasPlot(World world, Player player) {
@SuppressWarnings("deprecation") @Deprecated public boolean hasPlot(World world,
Player player) {
return getPlots(world, player, true).length > 0;
}
/**
* Get all plots for the player.
*
* @param world The world to retrieve plots from
* @param player The player to search for
* @param world The world to retrieve plots from
* @param player The player to search for
* @param justOwner should we just search for owner? Or with rights?
* @return An array of plots for the player
*/
@Deprecated
public Plot[] getPlots(World world, Player player, boolean justOwner) {
@Deprecated public Plot[] getPlots(World world, Player player, boolean justOwner) {
ArrayList<Plot> pPlots = new ArrayList<>();
UUID uuid = BukkitUtil.getPlayer(player).getUUID();
for (Plot plot : PS.get().getPlots(world.getName())) {
@ -485,14 +437,11 @@ public class PlotAPI {
* Get all plots for the world.
*
* @param world to get plots of
*
* @return Plot[] - array of plot objects in world
*
* @see PS#getPlots(String)
* @see Plot
*/
@Deprecated
public Plot[] getPlots(World world) {
@Deprecated public Plot[] getPlots(World world) {
if (world == null) {
return new Plot[0];
}
@ -504,11 +453,8 @@ public class PlotAPI {
* Get all plot worlds.
*
* @return World[] - array of plot worlds
*
*/
@SuppressWarnings("deprecation")
@Deprecated
public String[] getPlotWorlds() {
@SuppressWarnings("deprecation") @Deprecated public String[] getPlotWorlds() {
Set<String> plotWorldStrings = PS.get().getPlotWorldStrings();
return plotWorldStrings.toArray(new String[plotWorldStrings.size()]);
}
@ -517,13 +463,10 @@ public class PlotAPI {
* Get if plotworld.
*
* @param world The world to check
*
* @return boolean (if plot world or not)
*
* @see PS#hasPlotArea(String)
*/
@Deprecated
public boolean isPlotWorld(World world) {
@Deprecated public boolean isPlotWorld(World world) {
return PS.get().hasPlotArea(world.getName());
}
@ -531,29 +474,22 @@ public class PlotAPI {
* Get plot locations.
*
* @param plot Plot to get the locations for
*
* @return [0] = bottomLc, [1] = topLoc, [2] = home
*
* @deprecated As merged plots may not have a rectangular shape
*
* @see Plot
* @deprecated As merged plots may not have a rectangular shape
*/
@SuppressWarnings("deprecation")
@Deprecated
public Location[] getLocations(Plot plot) {
@SuppressWarnings("deprecation") @Deprecated public Location[] getLocations(Plot plot) {
Location bukkitBottom = BukkitUtil.getLocation(plot.getCorners()[0]);
Location bukkitTop = BukkitUtil.getLocation(plot.getCorners()[1]);
Location bukkitHome = BukkitUtil.getLocation(plot.getHome());
return new Location[]{bukkitBottom, bukkitTop, bukkitHome};
return new Location[] {bukkitBottom, bukkitTop, bukkitHome};
}
/**
* Get home location.
*
* @param plot Plot that you want to get the location for
*
* @return plot bottom location
*
* @see Plot
*/
public Location getHomeLocation(Plot plot) {
@ -564,16 +500,11 @@ public class PlotAPI {
* Get Bottom Location (min, min, min).
*
* @param plot Plot that you want to get the location for
*
* @return plot bottom location
*
* @deprecated As merged plots may not have a rectangular shape
*
* @see Plot
* @deprecated As merged plots may not have a rectangular shape
*/
@SuppressWarnings("deprecation")
@Deprecated
public Location getBottomLocation(Plot plot) {
@SuppressWarnings("deprecation") @Deprecated public Location getBottomLocation(Plot plot) {
return BukkitUtil.getLocation(plot.getCorners()[0]);
}
@ -581,16 +512,11 @@ public class PlotAPI {
* Get Top Location (max, max, max).
*
* @param plot Plot that you want to get the location for
*
* @return plot top location
*
* @deprecated As merged plots may not have a rectangular shape
*
* @see Plot
* @deprecated As merged plots may not have a rectangular shape
*/
@SuppressWarnings("deprecation")
@Deprecated
public Location getTopLocation(Plot plot) {
@SuppressWarnings("deprecation") @Deprecated public Location getTopLocation(Plot plot) {
return BukkitUtil.getLocation(plot.getCorners()[1]);
}
@ -598,9 +524,7 @@ public class PlotAPI {
* Check whether or not a player is in a plot.
*
* @param player who we're checking for
*
* @return true if the player is in a plot, false if not-
*
*/
public boolean isInPlot(Player player) {
return getPlot(player) != null;
@ -608,12 +532,12 @@ public class PlotAPI {
/**
* Register a subcommand.
* @deprecated Command registration is done on object creation
*
* @param c SubCommand, that we want to register
* @see SubCommand
* @deprecated Command registration is done on object creation
*/
@Deprecated
public void registerCommand(SubCommand c) {
@Deprecated public void registerCommand(SubCommand c) {
PS.debug("SubCommands are now registered on creation");
}
@ -621,7 +545,6 @@ public class PlotAPI {
* Gets the PlotSquared class.
*
* @return PlotSquared Class
*
* @see PS
*/
public PS getPlotSquared() {
@ -633,9 +556,7 @@ public class PlotAPI {
*
* @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
*
*/
public int getPlayerPlotCount(World world, Player player) {
if (world == null) {
@ -649,11 +570,8 @@ public class PlotAPI {
*
* @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 PS#getPlots(String, PlotPlayer)
*
* @see Plot
*/
public Set<Plot> getPlayerPlots(World world, Player player) {
@ -667,9 +585,7 @@ public class PlotAPI {
* Gets the number of plots, which the player is able to build in.
*
* @param player player, for whom we're getting the plots
*
* @return the number of allowed plots
*
*/
public int getAllowedPlots(Player player) {
PlotPlayer plotPlayer = PlotPlayer.wrap(player);
@ -680,10 +596,9 @@ public class PlotAPI {
* Gets the PlotPlayer for a player. The PlotPlayer is usually cached and
* will provide useful functions relating to players.
*
* @see PlotPlayer#wrap(Object)
*
* @param player the player to wrap
* @return a {@code PlotPlayer}
* @see PlotPlayer#wrap(Object)
*/
public PlotPlayer wrapPlayer(Player player) {
return PlotPlayer.wrap(player);
@ -691,14 +606,13 @@ public class PlotAPI {
/**
* Get the PlotPlayer for a UUID.
*
* <p>
* <p><i>Please note that PlotSquared can be configured to provide
* different UUIDs than bukkit</i>
*
* @see PlotPlayer#wrap(Object)
*
* @param uuid the uuid of the player to wrap
* @return a {@code PlotPlayer}
* @see PlotPlayer#wrap(Object)
*/
public PlotPlayer wrapPlayer(UUID uuid) {
return PlotPlayer.wrap(uuid);
@ -707,10 +621,9 @@ public class PlotAPI {
/**
* Get the PlotPlayer for a username.
*
* @see PlotPlayer#wrap(Object)
*
* @param player the player to wrap
* @return a {@code PlotPlayer}
* @see PlotPlayer#wrap(Object)
*/
public PlotPlayer wrapPlayer(String player) {
return PlotPlayer.wrap(player);
@ -718,14 +631,13 @@ public class PlotAPI {
/**
* Get the PlotPlayer for an offline player.
*
* <p>
* <p>Note that this will work if the player is offline, however not all
* functionality will work.
*
* @see PlotPlayer#wrap(Object)
*
* @param player the player to wrap
* @return a {@code PlotPlayer}
* @see PlotPlayer#wrap(Object)
*/
public PlotPlayer wrapPlayer(OfflinePlayer player) {
return PlotPlayer.wrap(player);