759 lines
22 KiB
Java
Raw Normal View History

2016-02-22 23:11:28 -05:00
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.api;
import com.intellectualcrafters.configuration.file.YamlConfiguration;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.commands.SubCommand;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.flag.AbstractFlag;
import com.intellectualcrafters.plot.flag.FlagManager;
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.SchematicHandler;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.util.BukkitUtil;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
2016-02-22 23:11:28 -05:00
2016-03-29 00:56:44 -04:00
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
2016-02-22 23:11:28 -05:00
/**
2016-03-29 00:56:44 -04:00
* PlotSquared API.
* <br>
* @version API 3.3.1
* <br>
* Useful classes:<br>
* @see BukkitUtil
* @see PlotPlayer
* @see Plot
* @see com.intellectualcrafters.plot.object.Location
* @see PlotArea
* @see PS
2016-02-22 23:11:28 -05:00
*/
public class PlotAPI {
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Permission that allows for admin access, this permission node will allow the player to use any part of the
* plugin, without limitations.
2016-03-20 23:19:37 +01:00
* @deprecated Use C.PERMISSION_ADMIN instead
2016-02-22 23:11:28 -05:00
*/
@Deprecated
public static final String ADMIN_PERMISSION = C.PERMISSION_ADMIN.s();
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* @deprecated Use new PlotAPI() instead
*/
@Deprecated
2016-03-23 13:16:05 -04:00
public PlotAPI(JavaPlugin plugin) {
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* @see PS
*
* @deprecated Use this class if you just want to do a few simple things.<br>
* - It will remain stable for future versions of the plugin
* - The PlotPlayer and Plot class should be considered relatively safe
* - For more advanced/intensive tasks you should consider using other classes
*
*
*/
@Deprecated
2016-03-23 13:16:05 -04:00
public PlotAPI() {
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
2016-03-29 00:56:44 -04:00
* Get all plots.
2016-02-22 23:11:28 -05:00
*
* @return all plots
*
* @see PS#getPlots()
*/
public Set<Plot> getAllPlots() {
return PS.get().getPlots();
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
2016-03-29 00:56:44 -04:00
* Return all plots for a player.
2016-02-22 23:11:28 -05:00
*
* @param player Player, whose plots to search for
*
* @return all plots that a player owns
*/
2016-03-23 13:16:05 -04:00
public Set<Plot> getPlayerPlots(Player player) {
2016-02-22 23:11:28 -05:00
return PS.get().getPlots(BukkitUtil.getPlayer(player));
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
2016-03-29 00:56:44 -04:00
* Add a plot world.
2016-02-22 23:11:28 -05:00
*
* @param plotArea Plot World Object
* @see PS#addPlotArea(PlotArea)
*/
2016-03-23 13:16:05 -04:00
public void addPlotArea(PlotArea plotArea) {
2016-02-22 23:11:28 -05:00
PS.get().addPlotArea(plotArea);
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* @return main configuration
*
* @see PS#config
*/
public YamlConfiguration getConfig() {
return PS.get().config;
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* @return storage configuration
*
* @see PS#storage
*/
public YamlConfiguration getStorage() {
return PS.get().storage;
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* 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 PlotSquared PlotSquared Main Class
*
* @see PS
*/
public PS getMain() {
return PS.get();
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* ChunkManager class contains several useful methods<br>
* - Chunk deletion<br>
* - Moving or copying regions<br>
* - plot swapping<br>
* - Entity tracking<br>
* - region regeneration<br>
*
* @return ChunkManager
*
* @see com.intellectualcrafters.plot.util.ChunkManager
*/
public ChunkManager getChunkManager() {
return ChunkManager.manager;
}
/**
* Get the block/biome set queue
* @return SetQueue.IMP
*/
public SetQueue getSetQueue() {
return SetQueue.IMP;
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* UUIDWrapper class has basic methods for getting UUIDS (it's recommended to use the UUIDHandler class instead)
*
* @return UUIDWrapper
*
* @see com.intellectualcrafters.plot.uuid.UUIDWrapper
*/
public UUIDWrapper getUUIDWrapper() {
return UUIDHandler.getUUIDWrapper();
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Do not use this. Instead use FlagManager.[method] in your code.
* - Flag related stuff
*
* @return FlagManager
*
* @see com.intellectualcrafters.plot.flag.FlagManager
*/
@Deprecated
public FlagManager getFlagManager() {
return new FlagManager();
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Do not use this. Instead use MainUtil.[method] in your code.
* - Basic plot management stuff
*
* @return MainUtil
*
* @see MainUtil
*/
@Deprecated
public MainUtil getMainUtil() {
return new MainUtil();
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Do not use this. Instead use C.PERMISSION_[method] in your code.
* - Basic permission management stuff
*
* @return Array of strings
*
* @see com.intellectualcrafters.plot.util.Permissions
*/
@Deprecated
public String[] getPermissions() {
2016-03-23 13:16:05 -04:00
ArrayList<String> perms = new ArrayList<>();
for (C c : C.values()) {
if ("static.permissions".equals(c.getCategory())) {
2016-02-22 23:11:28 -05:00
perms.add(c.s());
}
}
return perms.toArray(new String[perms.size()]);
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* SchematicHandler class contains methods related to pasting, reading and writing schematics
*
* @return SchematicHandler
*
* @see com.intellectualcrafters.plot.util.SchematicHandler
*/
public SchematicHandler getSchematicHandler() {
return SchematicHandler.manager;
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Use C.[caption] instead
*
* @return C
*
* @see com.intellectualcrafters.plot.config.C
*/
@Deprecated
public C[] getCaptions() {
return C.values();
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Get the plot manager for a world. - Most of these methods can be accessed through the MainUtil
*
* @param world Which manager to get
*
* @return PlotManager
*
* @see com.intellectualcrafters.plot.object.PlotManager
* @see PS#getPlotManager(Plot)
*/
@Deprecated
2016-03-23 13:16:05 -04:00
public PlotManager getPlotManager(World world) {
2016-02-22 23:11:28 -05:00
if (world == null) {
return null;
}
return getPlotManager(world.getName());
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
public Set<PlotArea> getPlotAreas(World world) {
if (world == null) {
return new HashSet<>();
}
return PS.get().getPlotAreas(world.getName());
}
/**
* Get the plot manager for a world. - Contains useful low level methods for plot merging, clearing, and
* tessellation
*
* @param world
*
* @return PlotManager
*
* @see PS#getPlotManager(Plot)
* @see com.intellectualcrafters.plot.object.PlotManager
*/
@Deprecated
2016-03-23 13:16:05 -04:00
public PlotManager getPlotManager(String world) {
2016-02-22 23:11:28 -05:00
Set<PlotArea> areas = PS.get().getPlotAreas(world);
switch (areas.size()) {
case 0:
return null;
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.");
return null;
}
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Get the settings for a world (settings bundled in PlotArea class) - You will need to downcast for the specific
* settings a Generator has. e.g. DefaultPlotWorld class implements PlotArea
*
* @param world (to get settings of)
*
* @return PlotArea class for that world ! will return null if not a plot world world
*
* @see #getPlotAreas(World)
* @see com.intellectualcrafters.plot.object.PlotArea
*/
@Deprecated
2016-03-23 13:16:05 -04:00
public PlotArea getWorldSettings(World world) {
2016-02-22 23:11:28 -05:00
if (world == null) {
return null;
}
return getWorldSettings(world.getName());
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Get the settings for a world (settings bundled in PlotArea class)
*
* @param world (to get settings of)
*
* @return PlotArea class for that world ! will return null if not a plot world world
*
* @see PS#getPlotArea(String, String)
* @see com.intellectualcrafters.plot.object.PlotArea
*/
@Deprecated
2016-03-23 13:16:05 -04:00
public PlotArea getWorldSettings(String world) {
2016-02-22 23:11:28 -05:00
if (world == null) {
return null;
}
Set<PlotArea> areas = PS.get().getPlotAreas(world);
switch (areas.size()) {
case 0:
return null;
case 1:
return areas.iterator().next();
default:
PS.debug("PlotAPI#getWorldSettings(org.bukkit.World) is deprecated and doesn't support multi plot area worlds.");
return null;
}
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Send a message to a player.
*
* @param player Player that will receive the message
* @param c (Caption)
*
* @see MainUtil#sendMessage(PlotPlayer, C, String...)
* com.intellectualcrafters.plot.config.C, String...)
*/
2016-03-23 13:16:05 -04:00
public void sendMessage(Player player, C c) {
2016-02-22 23:11:28 -05:00
MainUtil.sendMessage(BukkitUtil.getPlayer(player), c);
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Send a message to a player. - Supports color codes
*
* @param player Player that will receive the message
* @param string The message
*
* @see MainUtil#sendMessage(PlotPlayer, String)
*/
2016-03-23 13:16:05 -04:00
public void sendMessage(Player player, String string) {
2016-02-22 23:11:28 -05:00
MainUtil.sendMessage(BukkitUtil.getPlayer(player), string);
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Send a message to the console. - Supports color codes
*
* @param msg Message that should be sent to the console
*
* @see MainUtil#sendConsoleMessage(C, String...)
*/
2016-03-23 13:16:05 -04:00
public void sendConsoleMessage(String msg) {
2016-02-22 23:11:28 -05:00
PS.log(msg);
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Send a message to the console
*
* @param c (Caption)
*
* @see #sendConsoleMessage(String)
* @see com.intellectualcrafters.plot.config.C
*/
2016-03-23 13:16:05 -04:00
public void sendConsoleMessage(C c) {
sendConsoleMessage(c.s());
2016-02-22 23:11:28 -05:00
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Register a flag for use in plots
*
* @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
*/
2016-03-23 13:16:05 -04:00
public void addFlag(AbstractFlag flag) {
2016-02-22 23:11:28 -05:00
FlagManager.addFlag(flag);
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* get all the currently registered flags
*
* @return array of Flag[]
*
* @see com.intellectualcrafters.plot.flag.FlagManager#getFlags()
* @see com.intellectualcrafters.plot.flag.AbstractFlag
*/
public AbstractFlag[] getFlags() {
return FlagManager.getFlags().toArray(new AbstractFlag[FlagManager.getFlags().size()]);
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
2016-03-23 13:16:05 -04:00
* Get a plot based on the ID.
2016-02-22 23:11:28 -05:00
*
* @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 PlotArea#getPlot(PlotId)
*/
@Deprecated
2016-03-23 13:16:05 -04:00
public Plot getPlot(World world, int x, int z) {
2016-02-22 23:11:28 -05:00
if (world == null) {
return null;
}
PlotArea area = getWorldSettings(world);
if (area == null) {
return null;
}
return area.getPlot(new PlotId(x, z));
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
2016-03-23 13:16:05 -04:00
* Get a plot based on the location.
2016-02-22 23:11:28 -05:00
*
* @param l The location that you want to to retrieve the plot from
*
* @return plot if found, otherwise it creates a temporary plot-
*
* @see Plot
*/
2016-03-23 13:16:05 -04:00
public Plot getPlot(Location l) {
2016-02-22 23:11:28 -05:00
if (l == null) {
return null;
}
return BukkitUtil.getLocation(l).getPlot();
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
2016-03-23 13:16:05 -04:00
* Get a plot based on the player location.
2016-02-22 23:11:28 -05:00
*
* @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 Plot
*/
2016-03-23 13:16:05 -04:00
public Plot getPlot(Player player) {
2016-02-22 23:11:28 -05:00
return this.getPlot(player.getLocation());
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
2016-03-23 13:16:05 -04:00
* Check whether or not a player has a plot.
2016-02-22 23:11:28 -05:00
*
* @param player Player that you want to check for
*
* @return true if player has a plot, false if not.
*
* @see #getPlots(World, Player, boolean)
*/
@Deprecated
2016-03-23 13:16:05 -04:00
public boolean hasPlot(World world, Player player) {
2016-03-29 00:56:44 -04:00
return getPlots(world, player, true).length > 0;
2016-02-22 23:11:28 -05:00
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
2016-03-23 13:16:05 -04:00
* Get all plots for the player.
2016-02-22 23:11:28 -05:00
*
2016-03-23 13:16:05 -04:00
* @param world
* @param player The player to search for
* @param justOwner should we just search for owner? Or with rights?
2016-02-22 23:11:28 -05:00
*/
@Deprecated
2016-03-23 13:16:05 -04:00
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())) {
if (justOwner) {
2016-02-22 23:11:28 -05:00
if (plot.hasOwner() && plot.isOwner(uuid)) {
pPlots.add(plot);
}
2016-03-29 00:56:44 -04:00
} else if (plot.isAdded(uuid)) {
pPlots.add(plot);
2016-02-22 23:11:28 -05:00
}
}
return pPlots.toArray(new Plot[pPlots.size()]);
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
2016-03-23 13:16:05 -04:00
* Get all plots for the world.
2016-02-22 23:11:28 -05:00
*
* @param world to get plots of
*
* @return Plot[] - array of plot objects in world
*
* @see PS#getPlots(String)
* @see Plot
*/
@Deprecated
2016-03-23 13:16:05 -04:00
public Plot[] getPlots(World world) {
2016-02-22 23:11:28 -05:00
if (world == null) {
return new Plot[0];
}
Collection<Plot> plots = PS.get().getPlots(world.getName());
return plots.toArray(new Plot[plots.size()]);
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
2016-03-23 13:16:05 -04:00
* Get all plot worlds.
2016-02-22 23:11:28 -05:00
*
* @return World[] - array of plot worlds
*
*/
@Deprecated
public String[] getPlotWorlds() {
Set<String> plotWorldStrings = PS.get().getPlotWorldStrings();
return plotWorldStrings.toArray(new String[plotWorldStrings.size()]);
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Get if plot world
*
* @param world (to check if plot world)
*
* @return boolean (if plot world or not)
*
* @see PS#hasPlotArea(String)
*/
@Deprecated
2016-03-23 13:16:05 -04:00
public boolean isPlotWorld(World world) {
2016-02-22 23:11:28 -05:00
return PS.get().hasPlotArea(world.getName());
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Get plot locations
*
* @param p Plot that you want 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
2016-03-23 13:16:05 -04:00
public Location[] getLocations(Plot p) {
return new Location[]{BukkitUtil.getLocation(p.getBottom()), BukkitUtil.getLocation(p.getTop()), BukkitUtil.getLocation(p.getHome())};
2016-02-22 23:11:28 -05:00
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Get home location
*
* @param p Plot that you want to get the location for
*
* @return plot bottom location
*
* @see Plot
*/
2016-03-23 13:16:05 -04:00
public Location getHomeLocation(Plot p) {
2016-02-22 23:11:28 -05:00
return BukkitUtil.getLocation(p.getHome());
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Get Bottom Location (min, min, min)
*
* @param p 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
2016-03-23 13:16:05 -04:00
public Location getBottomLocation(Plot p) {
2016-02-22 23:11:28 -05:00
return BukkitUtil.getLocation(p.getBottom());
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Get Top Location (max, max, max)
*
* @param p Plot that you want to get the location for
*
* @return plot top location
2016-03-20 23:19:37 +01:00
*
2016-02-22 23:11:28 -05:00
* @deprecated As merged plots may not have a rectangular shape
*
* @see Plot
*/
@Deprecated
2016-03-23 13:16:05 -04:00
public Location getTopLocation(Plot p) {
2016-02-22 23:11:28 -05:00
return BukkitUtil.getLocation(p.getTop());
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* 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-
*
*/
2016-03-23 13:16:05 -04:00
public boolean isInPlot(Player player) {
2016-02-22 23:11:28 -05:00
return getPlot(player) != null;
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Register a subcommand
* @deprecated Command registration is done on object creation
2016-02-22 23:11:28 -05:00
* @param c SubCommand, that we want to register
* @see com.intellectualcrafters.plot.commands.SubCommand
*/
@Deprecated
2016-03-23 13:16:05 -04:00
public void registerCommand(SubCommand c) {
PS.debug("SubCommands are now registered on creation");
2016-02-22 23:11:28 -05:00
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Get the PlotSquared class
*
* @return PlotSquared Class
*
* @see PS
*/
public PS getPlotSquared() {
return PS.get();
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* 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
*
* @return the number of plots the player has
*
*/
2016-03-23 13:16:05 -04:00
public int getPlayerPlotCount(World world, Player player) {
2016-02-22 23:11:28 -05:00
if (world == null) {
return 0;
}
return BukkitUtil.getPlayer(player).getPlotCount(world.getName());
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* 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
*
* @return a set containing the players plots
*
* @see PS#getPlots(String, PlotPlayer)
*
* @see Plot
*/
2016-03-23 13:16:05 -04:00
public Set<Plot> getPlayerPlots(World world, Player player) {
2016-02-22 23:11:28 -05:00
if (world == null) {
return new HashSet<>();
}
return BukkitUtil.getPlayer(player).getPlots(world.getName());
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Get the numbers of plots, which the player is able to build in
*
* @param player Player, for whom we're getting the plots (trusted, member and owner)
*
* @return the number of allowed plots
*
*/
2016-03-23 13:16:05 -04:00
public int getAllowedPlots(Player player) {
PlotPlayer pp = BukkitUtil.getPlayer(player);
2016-02-22 23:11:28 -05:00
return pp.getAllowedPlots();
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Get the PlotPlayer for a player<br>
* - The PlotPlayer is usually cached and will provide useful functions relating to players
*
* @see PlotPlayer#wrap(Object)
*
* @param player
* @return
*/
2016-03-23 13:16:05 -04:00
public PlotPlayer wrapPlayer(Player player) {
2016-02-22 23:11:28 -05:00
return PlotPlayer.wrap(player);
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Get the PlotPlayer for a UUID (Please note that PlotSquared can be configured to provide different UUIDs than bukkit)
*
* @see PlotPlayer#wrap(Object)
*
* @param uuid
* @return
*/
2016-03-23 13:16:05 -04:00
public PlotPlayer wrapPlayer(UUID uuid) {
2016-02-22 23:11:28 -05:00
return PlotPlayer.wrap(uuid);
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Get the PlotPlayer for a username
*
* @see PlotPlayer#wrap(Object)
*
* @param player
* @return
*/
2016-03-23 13:16:05 -04:00
public PlotPlayer wrapPlayer(String player) {
2016-02-22 23:11:28 -05:00
return PlotPlayer.wrap(player);
}
2016-03-20 23:19:37 +01:00
2016-02-22 23:11:28 -05:00
/**
* Get the PlotPlayer for an offline player<br>
* Note that this will work if the player is offline, however not all functionality will work
*
* @see PlotPlayer#wrap(Object)
*
* @param player
* @return
*/
2016-03-23 13:16:05 -04:00
public PlotPlayer wrapPlayer(OfflinePlayer player) {
2016-02-22 23:11:28 -05:00
return PlotPlayer.wrap(player);
}
}