io.github.alshain01.flags.api
Class FlagsAPI

java.lang.Object
  extended by io.github.alshain01.flags.api.FlagsAPI

public final class FlagsAPI
extends java.lang.Object

Primary class for hooking into the API.


Method Summary
static int bundleCount()
          Gets the total number of bundles defined on the server
static boolean checkAPI(java.lang.String version)
          Utility method that checks if the provided string represents a version number that is equal to or lower than the current Bukkit API version.
static void close(io.github.alshain01.flags.DataStore data)
          Closes the API.
static Area getAbsoluteAreaAt(org.bukkit.Location location)
          Gets an area from at a specific location, ignoring inheritance.
static Area getArea(java.lang.String id)
          Gets an area by cuboid system specific ID.
static Area getAreaAt(org.bukkit.Location location)
          Gets an area from at a specific location.
static AreaPlugin getAreaPlugin()
          Gets the currently active cuboid system.
static java.util.Collection<Flag> getBundle(java.lang.String bundle)
          Gets a bundle from the data store.
static java.util.Collection<java.lang.String> getBundleNames()
          Gets a set of bundle names created on the server.
static Area getDefaultArea(org.bukkit.World world)
          Gets the default area for the world.
static Registrar getRegistrar()
          Gets the registrar for this instance of Flags.
static SectorManager getSectorManager()
          Gets the sector manager for this instance of Flags.
static Area getWildernessArea(org.bukkit.World world)
          Gets the wilderness area for the world.
static boolean hasArea(org.bukkit.Location location)
          Gets if the configured cuboid system has an area at a specific location.
static void initialize(org.bukkit.plugin.Plugin plugin, AreaPlugin cuboidSystem, SectorManager sectors, io.github.alshain01.flags.DataStore data)
          Starts the API.
static boolean inPvpCombat(org.bukkit.entity.Player player)
          Checks if a player is in Pvp combat that is being monitored by the cuboid system
static boolean isBundle(java.lang.String bundle)
          Checks if a bundle name exists in the data store.
static void setBundle(java.lang.String name, java.util.Collection<Flag> flags)
          Sets a bundle to the data file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

initialize

public static void initialize(@Nonnull
                              org.bukkit.plugin.Plugin plugin,
                              @Nonnull
                              AreaPlugin cuboidSystem,
                              @Nullable
                              SectorManager sectors,
                              @Nonnull
                              io.github.alshain01.flags.DataStore data)
Starts the API. Cannot be used externally.

Parameters:
cuboidSystem - The cuboid system detected
data - The datastore to be used

close

public static void close(@Nonnull
                         io.github.alshain01.flags.DataStore data)
Closes the API. Cannot be used externally.

Parameters:
data - The data store to close

getAreaPlugin

public static AreaPlugin getAreaPlugin()
Gets the currently active cuboid system.

Returns:
The Cuboid System in use by Flags.

getRegistrar

public static Registrar getRegistrar()
Gets the registrar for this instance of Flags.

Returns:
The flag registrar.

getSectorManager

public static SectorManager getSectorManager()
Gets the sector manager for this instance of Flags. Null if Flags is not configured to use sectors.

Returns:
The sector manager for Flags

getDefaultArea

public static Area getDefaultArea(@Nonnull
                                  org.bukkit.World world)
Gets the default area for the world.

Parameters:
world - The world for which to request the default area.
Returns:
The area for setting default settings for areas in the world.

getWildernessArea

public static Area getWildernessArea(@Nonnull
                                     org.bukkit.World world)
Gets the wilderness area for the world.

Parameters:
world - The world for which to request the wilderness area.
Returns:
The area for setting wilderness settings in the world.

hasArea

public static boolean hasArea(@Nonnull
                              org.bukkit.Location location)
Gets if the configured cuboid system has an area at a specific location.

Parameters:
location - The location to request an area.
Returns:
True if there is an area present at the location.

getArea

public static Area getArea(@Nonnull
                           java.lang.String id)
Gets an area by cuboid system specific ID. The name is formatted based on the cuboid system. Warning, there is little data type validation in this method. Incorrect usage may result in exceptions. ID Data Format: Factiod, Flags, Grief Prevention, Residence = UUID as String GriefPrevention = ClaimID (Long) PreciousStones = WorldUUID.FieldID (Long) Regios = Region name InfinitePlots, PlotMe = WorldUUID.PlotID (X;Z) WorldGuard = WorldName.RegionName

Parameters:
id - The cuboid system specific name of the area or world name
Returns:
The Area requested, may be null in cases of invalid cuboid system selection.

getAreaAt

public static Area getAreaAt(@Nonnull
                             org.bukkit.Location location)
Gets an area from at a specific location. If an area is an inheriting subdivision, the parent is returned.

Parameters:
location - The location for which to request an area.
Returns:
An area from the configured cuboid system or the wilderness area if no area is defined.

getAbsoluteAreaAt

public static Area getAbsoluteAreaAt(@Nonnull
                                     org.bukkit.Location location)
Gets an area from at a specific location, ignoring inheritance.

Parameters:
location - The location for which to request an area.
Returns:
An area from the configured cuboid system or the wilderness area if no area is defined.

getBundleNames

public static java.util.Collection<java.lang.String> getBundleNames()
Gets a set of bundle names created on the server.

Returns:
A set of bundles names configured on the server.

bundleCount

public static int bundleCount()
Gets the total number of bundles defined on the server

Returns:
A count of the bundles on the server

isBundle

public static boolean isBundle(@Nonnull
                               java.lang.String bundle)
Checks if a bundle name exists in the data store.

Parameters:
bundle - A string bundle name.
Returns:
True if the string is a valid bundle name.

getBundle

public static java.util.Collection<Flag> getBundle(@Nonnull
                                                   java.lang.String bundle)
Gets a bundle from the data store.

Parameters:
bundle - The bundle name to retrieve
Returns:
A list containing the bundle. Null if it doesn't exist.
Throws:
java.lang.IllegalArgumentException

setBundle

public static void setBundle(@Nonnull
                             java.lang.String name,
                             @Nullable
                             java.util.Collection<Flag> flags)
Sets a bundle to the data file.

Parameters:
name - The bundle name
flags - A list of flags in the bundle. May be null to remove the bundle but if not null, may not contain null elements.
Throws:
java.lang.IllegalArgumentException

inPvpCombat

public static boolean inPvpCombat(@Nonnull
                                  org.bukkit.entity.Player player)
Checks if a player is in Pvp combat that is being monitored by the cuboid system

Parameters:
player - The player to request information for
Returns:
True if the player is in pvp combat, false is not or if cuboid system is unsupported.

checkAPI

public static boolean checkAPI(@Nonnull
                               java.lang.String version)
Utility method that checks if the provided string represents a version number that is equal to or lower than the current Bukkit API version. String should be formatted with 3 numbers: x.y.z

Returns:
true if the version provided is compatible