Package dev.espi.protectionstones
Class ProtectionStones
java.lang.Object
org.bukkit.plugin.PluginBase
org.bukkit.plugin.java.JavaPlugin
dev.espi.protectionstones.ProtectionStones
- All Implemented Interfaces:
org.bukkit.command.CommandExecutor,org.bukkit.command.TabCompleter,org.bukkit.command.TabExecutor,org.bukkit.plugin.Plugin
public class ProtectionStones
extends org.bukkit.plugin.java.JavaPlugin
The base class for the plugin. Some utilities are static, and others are instance methods, so they need to
be accessed through getInstance().
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommandArgument(PSCommandArg psca)Add a command argument to /ps.static org.bukkit.inventory.ItemStackGet a protection block item from a protect block config object.voidPrint a debug message (only prints if the plugin is in debug mode).static PSProtectBlockgetBlockOptions(String blockType)Gets the config options for the protection block type specified.static PSProtectBlockgetBlockOptions(org.bukkit.block.Block block)Get the protection block config options for the block specified.static PSProtectBlockgetBlockOptions(org.bukkit.inventory.ItemStack item)Get the protection block config options for the item specified.Returns the list of PSProtectBlocks configured through the config.static PSEconomystatic ProtectionStonesnet.luckperms.api.LuckPermsstatic Loggerstatic PSProtectBlockgetProtectBlockFromAlias(String name)Get the config options for a protect block based on its aliasgetPSRegions(org.bukkit.World w, String identifier)Get protection stone regions using an ID or alias.net.milkbowl.vault.economy.EconomybooleanisDebug()booleanbooleanstatic booleanisProtectBlock(org.bukkit.block.Block b)Check whether or not a given block is a protection block, and actually protects a region.static booleanisProtectBlockItem(org.bukkit.inventory.ItemStack item)Check if an item is a valid protection block, and if the block type has restrict-obtaining on, check if it was created by ProtectionStones (custom NBT tag).static booleanisProtectBlockItem(org.bukkit.inventory.ItemStack item, boolean checkNBT)Check if an item is a valid protection block, and if checkNBT is true, check if it was created by ProtectionStones.static booleanisProtectBlockType(String material)Get whether or not a material is used as a protection block.static booleanisProtectBlockType(org.bukkit.block.Block b)static booleanisPSNameAlreadyUsed(String name)Check if a ProtectionStones name is already used by a region globally (from /ps name)static booleanisPSRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion r)Check if a WorldGuardProtectedRegionis a ProtectionStones region, and is configured in the config.static booleanisPSRegionFormat(com.sk89q.worldguard.protection.regions.ProtectedRegion r)Check if a WorldGuardProtectedRegionhas the format of a ProtectionStones region, but is not necessarily configured in the config.booleanstatic voidloadConfig(boolean isReload)voidonEnable()voidonLoad()static booleanremovePSRegion(org.bukkit.World w, String psID)Removes a protection stone region given its ID, and the region manager it is stored in Note: Does not remove the PS block.static booleanremovePSRegion(org.bukkit.World w, String psID, org.bukkit.entity.Player cause)Removes a protection stone region given its ID, and the region manager it is stored in, with a player as its cause Note: Does not remove the PS block, and does not check if the player (cause) has permission to do this.voidsetConfigOptions(PSConfig conf)voidsetDebug(boolean debug)Methods inherited from class org.bukkit.plugin.java.JavaPlugin
getClassLoader, getCommand, getConfig, getDataFolder, getDefaultBiomeProvider, getDefaultWorldGenerator, getDescription, getFile, getLogger, getPlugin, getPluginLoader, getProvidingPlugin, getResource, getServer, getTextResource, isEnabled, isNaggable, onCommand, onDisable, onTabComplete, reloadConfig, saveConfig, saveDefaultConfig, saveResource, setEnabled, setNaggable, toStringMethods inherited from class org.bukkit.plugin.PluginBase
equals, getName, hashCode
-
Field Details
-
CONFIG_VERSION
public static final int CONFIG_VERSION- See Also:
- Constant Field Values
-
configLocation
-
blockDataFolder
-
config
public static com.electronwill.nightconfig.core.file.CommentedFileConfig config -
toggleList
-
-
Constructor Details
-
ProtectionStones
public ProtectionStones()
-
-
Method Details
-
addCommandArgument
Add a command argument to /ps.- Parameters:
psca- PSCommandArg object to be added
-
getCommandArguments
- Returns:
- the list of command arguments for /ps
-
isPlaceholderAPISupportEnabled
public boolean isPlaceholderAPISupportEnabled()- Returns:
- whether PlaceholderAPI support is enabled
-
isVaultSupportEnabled
public boolean isVaultSupportEnabled()- Returns:
- whether vault support is enabled
-
getVaultEconomy
public net.milkbowl.vault.economy.Economy getVaultEconomy()- Returns:
- returns this instance's vault economy hook
-
getPSEconomy
- Returns:
- the instance's
PSEconomyinstance
-
isLuckPermsSupportEnabled
public boolean isLuckPermsSupportEnabled() -
getLuckPerms
public net.luckperms.api.LuckPerms getLuckPerms() -
setDebug
public void setDebug(boolean debug)- Parameters:
debug- whether the plugin should be in debug mode
-
isDebug
public boolean isDebug()- Returns:
- whether the plugin is in debug mode
-
debug
Print a debug message (only prints if the plugin is in debug mode).- Parameters:
msg- the message to print
-
getConfigOptions
- Returns:
- returns the config options of this instance of ProtectionStones
-
setConfigOptions
- Parameters:
conf- config object to replace current config
-
getConfiguredBlocks
Returns the list of PSProtectBlocks configured through the config.- Returns:
- the list of PSProtectBlocks configured
-
getInstance
- Returns:
- the plugin instance that is currently being used
-
getPluginLogger
- Returns:
- the plugin's logger
-
getEconomy
- Returns:
- the PSEconomy object adapter
-
getBlockOptions
Get the protection block config options for the block specified.- Parameters:
block- the block to get the block options of- Returns:
- the config options for the protect block specified (null if not found)
-
getBlockOptions
Get the protection block config options for the item specified. If the options has restrict-obtaining enabled, and the item does not contain the required NBT tag, null will be returned.- Parameters:
item- the item to get the block options of- Returns:
- the config options for the protect item specified (null if not found)
-
getBlockOptions
Gets the config options for the protection block type specified. It is recommended to use the block parameter overloaded method instead if possible, since it deals better with heads.- Parameters:
blockType- the material type name (Bukkit) of the protect block to get the options for, or "PLAYER_HEAD name" for heads- Returns:
- the config options for the protect block specified (null if not found)
-
isProtectBlockType
public static boolean isProtectBlockType(org.bukkit.block.Block b) -
isProtectBlockType
Get whether or not a material is used as a protection block. It is recommended to use the block parameter overloaded method if possible since player heads have a different format.- Parameters:
material- material type to check (Bukkit material name), or "PLAYER_HEAD name" for heads- Returns:
- whether or not that material is being used for a protection block
-
isProtectBlock
public static boolean isProtectBlock(org.bukkit.block.Block b)Check whether or not a given block is a protection block, and actually protects a region.- Parameters:
b- the block to look at- Returns:
- whether or not the block is a protection block responsible for a region.
-
isPSRegion
public static boolean isPSRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion r)Check if a WorldGuardProtectedRegionis a ProtectionStones region, and is configured in the config.- Parameters:
r- the region to check- Returns:
- true if the WorldGuard region is a ProtectionStones region, and false if it isn't
-
isPSRegionFormat
public static boolean isPSRegionFormat(com.sk89q.worldguard.protection.regions.ProtectedRegion r)Check if a WorldGuardProtectedRegionhas the format of a ProtectionStones region, but is not necessarily configured in the config.- Parameters:
r- the region to check- Returns:
- true if the WorldGuard region is a ProtectionStones region, and false if it isn't
-
isPSNameAlreadyUsed
Check if a ProtectionStones name is already used by a region globally (from /ps name)- Parameters:
name- the name to search for- Returns:
- whether or not there is a region with this name
-
getPSRegions
Get protection stone regions using an ID or alias.- Parameters:
w- the world to search in (only if it is an id; aliases/names are global)identifier- id or alias of the region- Returns:
- a list of psregions that match the id or alias; will be empty if no regions were found
-
removePSRegion
Removes a protection stone region given its ID, and the region manager it is stored in Note: Does not remove the PS block.- Parameters:
w- the world that the region is inpsID- the worldguard region ID of the region- Returns:
- whether or not the event was cancelled
-
removePSRegion
public static boolean removePSRegion(org.bukkit.World w, String psID, org.bukkit.entity.Player cause)Removes a protection stone region given its ID, and the region manager it is stored in, with a player as its cause Note: Does not remove the PS block, and does not check if the player (cause) has permission to do this.- Parameters:
w- the world that the region is inpsID- the worldguard region ID of the regioncause- the player that caused the removal- Returns:
- whether or not the event was cancelled
-
getProtectBlockFromAlias
Get the config options for a protect block based on its alias- Parameters:
name- the alias of the protection block- Returns:
- the protect block options, or null if it wasn't found
-
isProtectBlockItem
public static boolean isProtectBlockItem(org.bukkit.inventory.ItemStack item, boolean checkNBT)Check if an item is a valid protection block, and if checkNBT is true, check if it was created by ProtectionStones. Be aware that blocks may have restrict-obtaining off, meaning that it is ignored whether or not the item is created by ProtectionStones (in this case have checkNBT false).- Parameters:
item- the item to checkcheckNBT- whether or not to check if the plugin signed off on the item (restrict-obtaining)- Returns:
- whether or not the item is a valid protection block item, and was created by protection stones
-
isProtectBlockItem
public static boolean isProtectBlockItem(org.bukkit.inventory.ItemStack item)Check if an item is a valid protection block, and if the block type has restrict-obtaining on, check if it was created by ProtectionStones (custom NBT tag). Be aware that blocks may have restrict-obtaining off, meaning that it ignores whether or not the item is created by ProtectionStones.- Parameters:
item- the item to check- Returns:
- whether or not the item is a valid protection block item, and was created by protection stones
-
createProtectBlockItem
Get a protection block item from a protect block config object.- Parameters:
b- the config options for the protection block- Returns:
- the item with NBT and other metadata to signify that it was created by protection stones
-
loadConfig
public static void loadConfig(boolean isReload) -
onLoad
public void onLoad()- Specified by:
onLoadin interfaceorg.bukkit.plugin.Plugin- Overrides:
onLoadin classorg.bukkit.plugin.java.JavaPlugin
-
onEnable
public void onEnable()- Specified by:
onEnablein interfaceorg.bukkit.plugin.Plugin- Overrides:
onEnablein classorg.bukkit.plugin.java.JavaPlugin
-