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
    Modifier and Type
    Field
    Description
    static File
     
    static com.electronwill.nightconfig.core.file.CommentedFileConfig
     
    static int
     
    static File
     
    static Set<UUID>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Add a command argument to /ps.
    static org.bukkit.inventory.ItemStack
    Get a protection block item from a protect block config object.
    void
    debug​(String msg)
    Print a debug message (only prints if the plugin is in debug mode).
    getBlockOptions​(String blockType)
    Gets the config options for the protection block type specified.
    getBlockOptions​(org.bukkit.block.Block block)
    Get the protection block config options for the block specified.
    getBlockOptions​(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 PSEconomy
     
     
    net.luckperms.api.LuckPerms
     
    static Logger
     
    Get the config options for a protect block based on its alias
     
    static List<PSRegion>
    getPSRegions​(org.bukkit.World w, String identifier)
    Get protection stone regions using an ID or alias.
    net.milkbowl.vault.economy.Economy
     
    boolean
     
    boolean
     
    boolean
     
    static boolean
    isProtectBlock​(org.bukkit.block.Block b)
    Check whether or not a given block is a protection block, and actually protects a region.
    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).
    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.
    static boolean
    Get whether or not a material is used as a protection block.
    static boolean
    isProtectBlockType​(org.bukkit.block.Block b)
     
    static boolean
    Check if a ProtectionStones name is already used by a region globally (from /ps name)
    static boolean
    isPSRegion​(com.sk89q.worldguard.protection.regions.ProtectedRegion r)
    Check if a WorldGuard ProtectedRegion is a ProtectionStones region, and is configured in the config.
    static boolean
    isPSRegionFormat​(com.sk89q.worldguard.protection.regions.ProtectedRegion r)
    Check if a WorldGuard ProtectedRegion has the format of a ProtectionStones region, but is not necessarily configured in the config.
    boolean
     
    static void
    loadConfig​(boolean isReload)
     
    void
     
    void
     
    static boolean
    removePSRegion​(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 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.
    void
     
    void
    setDebug​(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, toString

    Methods inherited from class org.bukkit.plugin.PluginBase

    equals, getName, hashCode

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • CONFIG_VERSION

      public static final int CONFIG_VERSION
      See Also:
      Constant Field Values
    • configLocation

      public static File configLocation
    • blockDataFolder

      public static File blockDataFolder
    • config

      public static com.electronwill.nightconfig.core.file.CommentedFileConfig config
    • toggleList

      public static Set<UUID> toggleList
  • Constructor Details

    • ProtectionStones

      public ProtectionStones()
  • Method Details

    • addCommandArgument

      public void addCommandArgument(PSCommandArg psca)
      Add a command argument to /ps.
      Parameters:
      psca - PSCommandArg object to be added
    • getCommandArguments

      public List<PSCommandArg> 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

      public PSEconomy getPSEconomy()
      Returns:
      the instance's PSEconomy instance
    • 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

      public void debug(String msg)
      Print a debug message (only prints if the plugin is in debug mode).
      Parameters:
      msg - the message to print
    • getConfigOptions

      public PSConfig getConfigOptions()
      Returns:
      returns the config options of this instance of ProtectionStones
    • setConfigOptions

      public void setConfigOptions(PSConfig conf)
      Parameters:
      conf - config object to replace current config
    • getConfiguredBlocks

      public List<PSProtectBlock> getConfiguredBlocks()
      Returns the list of PSProtectBlocks configured through the config.
      Returns:
      the list of PSProtectBlocks configured
    • getInstance

      public static ProtectionStones getInstance()
      Returns:
      the plugin instance that is currently being used
    • getPluginLogger

      public static Logger getPluginLogger()
      Returns:
      the plugin's logger
    • getEconomy

      public static PSEconomy getEconomy()
      Returns:
      the PSEconomy object adapter
    • getBlockOptions

      public static PSProtectBlock getBlockOptions(org.bukkit.block.Block block)
      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

      public static PSProtectBlock getBlockOptions(org.bukkit.inventory.ItemStack item)
      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

      public static PSProtectBlock getBlockOptions(String blockType)
      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

      public static boolean isProtectBlockType(String material)
      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 WorldGuard ProtectedRegion is 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 WorldGuard ProtectedRegion has 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

      public static boolean isPSNameAlreadyUsed(String name)
      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

      public static List<PSRegion> getPSRegions(org.bukkit.World w, String identifier)
      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

      public static boolean removePSRegion(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.
      Parameters:
      w - the world that the region is in
      psID - 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 in
      psID - the worldguard region ID of the region
      cause - the player that caused the removal
      Returns:
      whether or not the event was cancelled
    • getProtectBlockFromAlias

      public static PSProtectBlock getProtectBlockFromAlias(String name)
      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 check
      checkNBT - 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

      public static org.bukkit.inventory.ItemStack createProtectBlockItem(PSProtectBlock b)
      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:
      onLoad in interface org.bukkit.plugin.Plugin
      Overrides:
      onLoad in class org.bukkit.plugin.java.JavaPlugin
    • onEnable

      public void onEnable()
      Specified by:
      onEnable in interface org.bukkit.plugin.Plugin
      Overrides:
      onEnable in class org.bukkit.plugin.java.JavaPlugin