Class PlayerCacheUtil
java.lang.Object
com.palmergames.bukkit.towny.utils.PlayerCacheUtil
Groups all the cache status and permissions in one place.
- Author:
- ElgarL/Shade
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcacheBlockErrMsg(org.bukkit.entity.Player player, String msg) Update the cached BlockErrMsg for this player.static PlayerCache.TownBlockStatuscacheStatus(org.bukkit.entity.Player player, WorldCoord worldCoord, PlayerCache.TownBlockStatus townBlockStatus) Update and return back the townBlockStatus for the player at this worldCoord.static PlayerCache.TownBlockStatusfetchTownBlockStatus(org.bukkit.entity.Player player, WorldCoord worldCoord) Wrapper forgetTownBlockStatus(Player, WorldCoord)which allows another plugin to alter the pre-determined TownBlockStatus.static PlayerCachegetCache(org.bukkit.entity.Player player) Returns the PlayerCache of a Player.static booleangetCachePermission(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.static PlayerCache.TownBlockStatusgetTownBlockStatus(org.bukkit.entity.Player player, WorldCoord worldCoord) Fetch the TownBlockStatus type for this player at this WorldCoord.static voidinitialize(Towny plugin) static booleanisOwnerCache(@NotNull PlayerCache cache) Does the given cache have a TownBlockStatus which is admin, plot_owner or town_owner.
-
Constructor Details
-
PlayerCacheUtil
public PlayerCacheUtil()
-
-
Method Details
-
initialize
-
getCache
Returns the PlayerCache of a Player.- Parameters:
player- ThePlayerfor which to fetch thePlayerCache.- 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 checklocation- - Locationmaterial- - Materialaction- - 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- - PlayerworldCoord- - WorldCoordtownBlockStatus- - TownBlockStatus- Returns:
- TownBlockStatus type.
-
cacheBlockErrMsg
Update the cached BlockErrMsg for this player.- Parameters:
player- - Playermsg- - String
-
fetchTownBlockStatus
public static PlayerCache.TownBlockStatus fetchTownBlockStatus(org.bukkit.entity.Player player, WorldCoord worldCoord) Wrapper forgetTownBlockStatus(Player, WorldCoord)which allows another plugin to alter the pre-determined TownBlockStatus.- Parameters:
player-Playerwho is getting a new TownBlockStatus for their PlayerCache.worldCoord-WorldCoordwhere the TownBlockStatus is being fetched for.- Returns:
PlayerCache.TownBlockStatuswhich 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- - PlayerworldCoord- - WorldCoord- Returns:
- TownBlockStatus type.
-
isOwnerCache
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.
-