Class PlayerCacheUtil

java.lang.Object
com.palmergames.bukkit.towny.utils.PlayerCacheUtil

public class PlayerCacheUtil extends Object
Groups all the cache status and permissions in one place.
Author:
ElgarL/Shade
  • Constructor Details

    • PlayerCacheUtil

      public PlayerCacheUtil()
  • Method Details

    • initialize

      public static void initialize(Towny plugin)
    • getCache

      public static PlayerCache getCache(org.bukkit.entity.Player player)
      Returns the PlayerCache of a Player.
      Parameters:
      player - The Player for which to fetch the PlayerCache.
      Returns:
      PlayerCache
    • getCachePermission

      public static boolean getCachePermission(org.bukkit.entity.Player player, org.bukkit.Location location, org.bukkit.Material material, TownyPermission.ActionType action)
      Returns player cached permission for BUILD, DESTROY, SWITCH or ITEM_USE at this location for the specified item id. Generates the cache if it doesn't exist.
      Parameters:
      player - - Player to check
      location - - Location
      material - - Material
      action - - ActionType
      Returns:
      true if the player has permission.
    • cacheStatus

      public static PlayerCache.TownBlockStatus cacheStatus(org.bukkit.entity.Player player, WorldCoord worldCoord, PlayerCache.TownBlockStatus townBlockStatus)
      Update and return back the townBlockStatus for the player at this worldCoord.
      Parameters:
      player - - Player
      worldCoord - - WorldCoord
      townBlockStatus - - TownBlockStatus
      Returns:
      TownBlockStatus type.
    • cacheBlockErrMsg

      public static void cacheBlockErrMsg(org.bukkit.entity.Player player, String msg)
      Update the cached BlockErrMsg for this player.
      Parameters:
      player - - Player
      msg - - String
    • fetchTownBlockStatus

      public static PlayerCache.TownBlockStatus fetchTownBlockStatus(org.bukkit.entity.Player player, WorldCoord worldCoord)
      Wrapper for getTownBlockStatus(Player, WorldCoord) which allows another plugin to alter the pre-determined TownBlockStatus.
      Parameters:
      player - Player who is getting a new TownBlockStatus for their PlayerCache.
      worldCoord - WorldCoord where the TownBlockStatus is being fetched for.
      Returns:
      PlayerCache.TownBlockStatus which will be used by Towny.
    • getTownBlockStatus

      public static PlayerCache.TownBlockStatus getTownBlockStatus(org.bukkit.entity.Player player, WorldCoord worldCoord)
      Fetch the TownBlockStatus type for this player at this WorldCoord.
      Parameters:
      player - - Player
      worldCoord - - WorldCoord
      Returns:
      TownBlockStatus type.
    • isOwnerCache

      public static boolean isOwnerCache(@NotNull @NotNull PlayerCache cache)
      Does the given cache have a TownBlockStatus which is admin, plot_owner or town_owner. These TownBlockStatus values will always allow for all interactions.
      Parameters:
      cache - PlayerCache to check for, do not pass a null cache.
      Returns:
      true if the cache's TownBlockStatus is a admin, plot or town owner.