ru.tehkode.permissions
Class PermissionManager

java.lang.Object
  extended by ru.tehkode.permissions.PermissionManager

public class PermissionManager
extends Object

Author:
code

Field Summary
protected  boolean allowOps
           
protected  PermissionBackend backend
           
protected  org.bukkit.util.config.Configuration config
           
protected  boolean debugMode
           
protected  Map<String,PermissionGroup> defaultGroups
           
protected  Map<String,PermissionGroup> groups
           
protected static Logger logger
           
protected  Timer timer
           
static int TRANSIENT_PERMISSION
           
protected  Map<String,PermissionUser> users
           
 
Constructor Summary
PermissionManager(org.bukkit.util.config.Configuration config)
           
 
Method Summary
protected  void callEvent(PermissionEvent event)
           
protected  void callEvent(PermissionSystemEvent.Action action)
           
protected  void clearCache()
           
 void clearUserCache(org.bukkit.entity.Player player)
          Clear cache for specified player
 void clearUserCache(String userName)
          Clear cache for specified user
 PermissionBackend getBackend()
          Return current backend
 PermissionGroup getDefaultGroup()
           
 PermissionGroup getDefaultGroup(String worldName)
          Return default group object
 PermissionGroup getGroup(String groupname)
          Return object for specified group
 PermissionGroup[] getGroups()
          Return all groups
 PermissionGroup[] getGroups(String groupName)
           
 PermissionGroup[] getGroups(String groupName, boolean inheritance)
           
 PermissionGroup[] getGroups(String groupName, String worldName)
          Return all child groups of specified group
 PermissionGroup[] getGroups(String groupName, String worldName, boolean inheritance)
          Return all descendants or child groups for groupName
 Map<Integer,PermissionGroup> getRankLadder(String ladderName)
          Return groups of specified rank ladder
 PermissionUser getUser(org.bukkit.entity.Player player)
          Return object of specified player
 PermissionUser getUser(String username)
          Return user's object
 PermissionUser[] getUsers()
          Return all registered user objects
 PermissionUser[] getUsers(String groupName)
           
 PermissionUser[] getUsers(String groupName, boolean inheritance)
           
 PermissionUser[] getUsers(String groupName, String worldName)
          Return all users in group
 PermissionUser[] getUsers(String groupName, String worldName, boolean inheritance)
          Return all users in group and descendant groups
 String[] getWorldInheritance(String worldName)
          Return array of world names who has world inheritance
 boolean has(org.bukkit.entity.Player player, String permission)
          Check if specified player has specified permission
 boolean has(org.bukkit.entity.Player player, String permission, String world)
          Check if player has specified permission in world
 boolean has(String playerName, String permission, String world)
          Check if player with name has permission in world
 boolean isDebug()
          Return current state of debug mode
protected  void registerTask(TimerTask task, int delay)
          Register new timer task
 void reset()
          Reset all in-memory groups and users, clean up runtime stuff, reloads backend
 void resetGroup(String groupName)
          Reset in-memory object for groupName
 void resetUser(String userName)
          Reset in-memory object of specified user
 void setBackend(String backendName)
          Set backend to specified backend.
 void setDebug(boolean debug)
          Set debug mode
 void setDefaultGroup(PermissionGroup group)
           
 void setDefaultGroup(PermissionGroup group, String worldName)
          Set default group to specified group
 void setWorldInheritance(String world, String[] parentWorlds)
          Set world inheritance parents for world
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRANSIENT_PERMISSION

public static final int TRANSIENT_PERMISSION
See Also:
Constant Field Values

logger

protected static final Logger logger

users

protected Map<String,PermissionUser> users

groups

protected Map<String,PermissionGroup> groups

defaultGroups

protected Map<String,PermissionGroup> defaultGroups

backend

protected PermissionBackend backend

config

protected org.bukkit.util.config.Configuration config

timer

protected Timer timer

debugMode

protected boolean debugMode

allowOps

protected boolean allowOps
Constructor Detail

PermissionManager

public PermissionManager(org.bukkit.util.config.Configuration config)
Method Detail

has

public boolean has(org.bukkit.entity.Player player,
                   String permission)
Check if specified player has specified permission

Parameters:
player - player object
permission - permission string to check against
Returns:
true on success false otherwise

has

public boolean has(org.bukkit.entity.Player player,
                   String permission,
                   String world)
Check if player has specified permission in world

Parameters:
player - player object
permission - permission as string to check against
world - world's name as string
Returns:
true on success false otherwise

has

public boolean has(String playerName,
                   String permission,
                   String world)
Check if player with name has permission in world

Parameters:
player - player object
permission - permission as string to check against
world - world's name as string
Returns:
true on success false otherwise

getUser

public PermissionUser getUser(String username)
Return user's object

Parameters:
username - get PermissionUser with given name
Returns:
PermissionUser instance

getUser

public PermissionUser getUser(org.bukkit.entity.Player player)
Return object of specified player

Parameters:
player - player object
Returns:
PermissionUser instance

getUsers

public PermissionUser[] getUsers()
Return all registered user objects

Returns:
PermissionUser array

getUsers

public PermissionUser[] getUsers(String groupName,
                                 String worldName)
Return all users in group

Parameters:
groupName - group's name
Returns:
PermissionUser array

getUsers

public PermissionUser[] getUsers(String groupName)

getUsers

public PermissionUser[] getUsers(String groupName,
                                 String worldName,
                                 boolean inheritance)
Return all users in group and descendant groups

Parameters:
groupName - group's name
inheritance - true return members of descendant groups of specified group
Returns:
PermissionUser array for groupnName

getUsers

public PermissionUser[] getUsers(String groupName,
                                 boolean inheritance)

resetUser

public void resetUser(String userName)
Reset in-memory object of specified user

Parameters:
userName - user's name

clearUserCache

public void clearUserCache(String userName)
Clear cache for specified user

Parameters:
userName -

clearUserCache

public void clearUserCache(org.bukkit.entity.Player player)
Clear cache for specified player

Parameters:
player -

getGroup

public PermissionGroup getGroup(String groupname)
Return object for specified group

Parameters:
groupname - group's name
Returns:
PermissionGroup object

getGroups

public PermissionGroup[] getGroups()
Return all groups

Returns:
PermissionGroup array

getGroups

public PermissionGroup[] getGroups(String groupName,
                                   String worldName)
Return all child groups of specified group

Parameters:
groupName - group's name
Returns:
PermissionGroup array

getGroups

public PermissionGroup[] getGroups(String groupName)

getGroups

public PermissionGroup[] getGroups(String groupName,
                                   String worldName,
                                   boolean inheritance)
Return all descendants or child groups for groupName

Parameters:
groupName - group's name
inheritance - true: only direct child groups would be returned
Returns:
PermissionGroup array for specified groupName

getGroups

public PermissionGroup[] getGroups(String groupName,
                                   boolean inheritance)

getDefaultGroup

public PermissionGroup getDefaultGroup(String worldName)
Return default group object

Returns:
default group object. null if not specified

getDefaultGroup

public PermissionGroup getDefaultGroup()

setDefaultGroup

public void setDefaultGroup(PermissionGroup group,
                            String worldName)
Set default group to specified group

Parameters:
group - PermissionGroup group object

setDefaultGroup

public void setDefaultGroup(PermissionGroup group)

resetGroup

public void resetGroup(String groupName)
Reset in-memory object for groupName

Parameters:
groupName - group's name

setDebug

public void setDebug(boolean debug)
Set debug mode

Parameters:
debug - true enables debug mode, false disables

isDebug

public boolean isDebug()
Return current state of debug mode

Returns:
true debug is enabled, false if disabled

getRankLadder

public Map<Integer,PermissionGroup> getRankLadder(String ladderName)
Return groups of specified rank ladder

Parameters:
ladderName -
Returns:
Map of ladder, key - rank of group, value - group object. Empty map if ladder does not exist

getWorldInheritance

public String[] getWorldInheritance(String worldName)
Return array of world names who has world inheritance

Parameters:
world - World name
Returns:
Array of parent world, if world does not exist return empty array

setWorldInheritance

public void setWorldInheritance(String world,
                                String[] parentWorlds)
Set world inheritance parents for world

Parameters:
world - world name which inheritance should be set
parentWorlds - array of parent world names

getBackend

public PermissionBackend getBackend()
Return current backend

Returns:
current backend object

setBackend

public void setBackend(String backendName)
Set backend to specified backend. This would also cause backend resetting.

Parameters:
backendName - name of backend to set to

registerTask

protected void registerTask(TimerTask task,
                            int delay)
Register new timer task

Parameters:
task - TimerTask object
delay - delay in seconds

reset

public void reset()
Reset all in-memory groups and users, clean up runtime stuff, reloads backend


clearCache

protected void clearCache()

callEvent

protected void callEvent(PermissionEvent event)

callEvent

protected void callEvent(PermissionSystemEvent.Action action)


Copyright © 2011. All Rights Reserved.