Package net.alpenblock.bungeeperms
Class PermissionsManager
- java.lang.Object
-
- net.alpenblock.bungeeperms.PermissionsManager
-
public class PermissionsManager extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description PermissionsManager(PlatformPlugin p, BPConfig conf, Debug d)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addGroup(Group group)
Adds a group to cache and database.void
addGroupInheritance(Group group, Group toadd)
Deprecated.void
addGroupInheritance(Group group, Group toadd, java.lang.String server, java.lang.String world)
Adds the toadd group to the group as inheritancevoid
addGroupPerm(Group group, java.lang.String perm)
Deprecated.void
addGroupPerm(Group group, java.lang.String server, java.lang.String world, java.lang.String perm)
Adds a permission to a group.void
addGroupTimedInheritance(Group group, TimedValue<Group> toadd)
Deprecated.void
addGroupTimedInheritance(Group group, TimedValue<Group> toadd, java.lang.String server, java.lang.String world)
Adds the toadd timed group to the group as inheritancevoid
addGroupTimedPerm(Group group, java.lang.String server, java.lang.String world, TimedValue perm)
Adds a timed permission to a group.void
addGroupToCache(Group g)
void
addUser(User user)
Adds a user to cache and database.void
addUserGroup(User user, Group group)
Deprecated.void
addUserGroup(User user, Group group, java.lang.String server, java.lang.String world)
Adds the given group to the user.void
addUserPerm(User user, java.lang.String perm)
Deprecated.void
addUserPerm(User user, java.lang.String server, java.lang.String world, java.lang.String perm)
Adds a permission to a user.void
addUserTimedGroup(User user, TimedValue<Group> group)
Deprecated.void
addUserTimedGroup(User user, TimedValue<Group> group, java.lang.String server, java.lang.String world)
Adds the given timed group to the user.void
addUserTimedPerm(User user, java.lang.String server, java.lang.String world, TimedValue perm)
Adds a timed permission to a user.void
addUserToCache(User u)
int
cleanup()
Cleans the permissions backEnd and wipes 0815 users.User
createTempUser(java.lang.String playername, java.util.UUID uuid)
Creates a temporary user with the given parameters and adds it to the users cache.void
deleteGroup(Group group)
Deletes a user from cache and database and validates all groups and users.void
deleteUser(User user)
Deletes a user from cache and database.void
disable()
Disables the permissions manager.void
enable()
Enables the permissions manager.void
format()
Formats the permissions backEnd.java.util.List<Group>
getDefaultGroups()
Gets a list of all groups that are marked as default and given to all users by default.java.util.List<java.lang.String>
getDefaultGroupsString()
Gets a list of all groups that are marked as default and given to all users by default.Group
getGroup(java.lang.String groupname)
Gets a group by its name.java.util.List<Group>
getGroups()
Gets an unmodifiable list of all groupsjava.util.List<java.lang.String>
getGroupUsers(Group group)
Gets a list of all user which are in the given groupjava.util.Map<java.util.UUID,java.lang.String>
getGroupUsersUUID(Group group)
Gets a list of all user and their UUIDs which are in the given groupjava.util.List<Group>
getLadderGroups(java.lang.String ladder)
Gets all groups of the given ladder.java.util.List<java.lang.String>
getLadders()
Gets a list of all existing ladders.Group
getMainGroup(User player)
Get the group of the player with the highesst rank.Group
getNextGroup(Group group)
Gets the next (higher) group in the same ladder.Group
getPreviousGroup(Group group)
Gets the previous (lower) group in the same ladder.java.util.List<java.lang.String>
getRegisteredUsers()
Gets a list of all usersjava.util.Map<java.util.UUID,java.lang.String>
getRegisteredUsersUUID()
Gets a list of all users and their uuidsUser
getUser(java.lang.String usernameoruuid)
Gets a user by its name.User
getUser(java.lang.String usernameoruuid, boolean loadfromdb)
Gets a user by its name.User
getUser(java.util.UUID uuid)
Gets a user by its UUID.User
getUser(java.util.UUID uuid, boolean loadfromdb)
Gets a user by its UUID.java.util.List<User>
getUsers()
Gets an unmodifiable list of all loaded usersvoid
ladderGroup(Group group, java.lang.String ladder)
Set the ladder for the group.void
loadConfig()
Loads the configuration of the plugin from the config.yml file.void
loadPerms()
(Re)loads the all groups and online players from file/table.void
migrateBackEnd(BackEndType bet)
Migrates the permissions to the given backnd type.void
migrateUsePlayerNames(java.util.Map<java.util.UUID,java.lang.String> playernames)
Converts the permissions database to use player names for player identification.void
migrateUseUUID(java.util.Map<java.lang.String,java.util.UUID> uuids)
Converts the permissions database to use UUIDs for player identification.void
rankGroup(Group group, int rank)
Sets the rank for the group.void
reload()
Reloads the config and permissions.void
reloadGroup(java.lang.String group)
void
reloadGroups()
void
reloadUser(java.lang.String user)
void
reloadUser(java.util.UUID uuid)
void
reloadUsers()
void
removeGroupFromCache(Group g)
void
removeGroupInheritance(Group group, Group toremove)
Deprecated.void
removeGroupInheritance(Group group, Group toremove, java.lang.String server, java.lang.String world)
Removes the toremove group from the group as inheritancevoid
removeGroupPerm(Group group, java.lang.String perm)
Deprecated.void
removeGroupPerm(Group group, java.lang.String server, java.lang.String world, java.lang.String perm)
Removes a permission from a group.void
removeGroupTimedInheritance(Group group, Group toremove)
Deprecated.void
removeGroupTimedInheritance(Group group, Group toremove, java.lang.String server, java.lang.String world)
Removes the toremove timed group from the group as inheritancevoid
removeGroupTimedPerm(Group group, java.lang.String server, java.lang.String world, java.lang.String perm)
Removes a timed permission from a group.void
removeUserFromCache(User u)
void
removeUserGroup(User user, Group group)
Deprecated.void
removeUserGroup(User user, Group group, java.lang.String server, java.lang.String world)
Removes the given group from the user.void
removeUserPerm(User user, java.lang.String perm)
Deprecated.void
removeUserPerm(User user, java.lang.String server, java.lang.String world, java.lang.String perm)
Removes a permission from a user.void
removeUserTimedGroup(User user, Group group)
Deprecated.void
removeUserTimedGroup(User user, Group group, java.lang.String server, java.lang.String world)
Removes the given timed group from the user.void
removeUserTimedPerm(User user, java.lang.String server, java.lang.String world, java.lang.String perm)
Removes a timed permission from a user.void
setGroupDefault(Group group, boolean isdefault)
Sets if the the group is a default group.void
setGroupDisplay(Group group, java.lang.String display, java.lang.String server, java.lang.String world)
Sets the displayname of the groupvoid
setGroupPrefix(Group group, java.lang.String prefix, java.lang.String server, java.lang.String world)
Sets the prefix for the group.void
setGroupSuffix(Group group, java.lang.String suffix, java.lang.String server, java.lang.String world)
Sets the suffix for the group.void
setUserDisplay(User user, java.lang.String display, java.lang.String server, java.lang.String world)
Sets the displayname of the groupvoid
setUserPrefix(User user, java.lang.String prefix, java.lang.String server, java.lang.String world)
Sets the prefix for the group.void
setUserSuffix(User user, java.lang.String suffix, java.lang.String server, java.lang.String world)
Sets the suffix for the group.void
validateUsersGroups()
Deprecated.void
weightGroup(Group group, int weight)
Sets the weight for the group.
-
-
-
Constructor Detail
-
PermissionsManager
public PermissionsManager(PlatformPlugin p, BPConfig conf, Debug d)
-
-
Method Detail
-
loadConfig
public final void loadConfig()
Loads the configuration of the plugin from the config.yml file.
-
loadPerms
public final void loadPerms()
(Re)loads the all groups and online players from file/table.
-
enable
public void enable()
Enables the permissions manager.
-
disable
public void disable()
Disables the permissions manager.
-
reload
public void reload()
Reloads the config and permissions.
-
validateUsersGroups
@Deprecated public void validateUsersGroups()
Deprecated.Validates all loaded groups and users and fixes invalid objects.
-
getMainGroup
public Group getMainGroup(User player)
Get the group of the player with the highesst rank. Do not to be confused with the rank property. The higher the rank the smaller the rank property. (1 is highest rank; 1000 is a low rank)- Parameters:
player
- the user to get the main group of- Returns:
- the main group of the user (highest rank)
- Throws:
java.lang.NullPointerException
- if player is null
-
getNextGroup
public Group getNextGroup(Group group)
Gets the next (higher) group in the same ladder.- Parameters:
group
- the group to get the next group of- Returns:
- the next group in the same ladder or null if the group has no next group
- Throws:
java.lang.IllegalArgumentException
- if the group ladder does not exist (anymore)
-
getPreviousGroup
public Group getPreviousGroup(Group group)
Gets the previous (lower) group in the same ladder.- Parameters:
group
- the group to get the previous group of- Returns:
- the previous group in the same ladder or null if the group has no previous group
- Throws:
java.lang.IllegalArgumentException
- if the group ladder does not exist (anymore)
-
getLadderGroups
public java.util.List<Group> getLadderGroups(java.lang.String ladder)
Gets all groups of the given ladder.- Parameters:
ladder
- the ladder of the groups to get- Returns:
- a sorted list of all matched groups
-
getLadders
public java.util.List<java.lang.String> getLadders()
Gets a list of all existing ladders.- Returns:
- a list of all ladders
-
getDefaultGroups
public java.util.List<Group> getDefaultGroups()
Gets a list of all groups that are marked as default and given to all users by default.- Returns:
- a list of default groups
-
getDefaultGroupsString
public java.util.List<java.lang.String> getDefaultGroupsString()
Gets a list of all groups that are marked as default and given to all users by default.- Returns:
- a list of default groups
-
getGroup
public Group getGroup(java.lang.String groupname)
Gets a group by its name.- Parameters:
groupname
- the name of the group to get- Returns:
- the found group if any or null
-
getUser
public User getUser(java.lang.String usernameoruuid)
Gets a user by its name. If the user is not loaded it will be loaded.- Parameters:
usernameoruuid
- the name or the UUID of the user to get- Returns:
- the found user or null if it does not exist
-
getUser
public User getUser(java.lang.String usernameoruuid, boolean loadfromdb)
Gets a user by its name. If the user is not loaded it will be loaded if loadfromdb is true.- Parameters:
usernameoruuid
- the name or the UUID of the user to getloadfromdb
- whether or not to load the user from the database if not already loaded- Returns:
- the found user or null if it does not exist
-
getUser
public User getUser(java.util.UUID uuid)
Gets a user by its UUID. If the user is not loaded it will be loaded.- Parameters:
uuid
- the uuid of the user to get- Returns:
- the found user or null if it does not exist
-
getUser
public User getUser(java.util.UUID uuid, boolean loadfromdb)
Gets a user by its UUID. If the user is not loaded it will be loaded if loadfromdb is true.- Parameters:
uuid
- the uuid of the user to getloadfromdb
- whether or not to load the user from the database if not already loaded- Returns:
- the found user or null if it does not exist
-
createTempUser
public User createTempUser(java.lang.String playername, java.util.UUID uuid)
Creates a temporary user with the given parameters and adds it to the users cache. The returned user object is no saved to the backend in this function.- Parameters:
playername
- the name of the temporary useruuid
- the user of the temporary user- Returns:
- the created user
-
getGroups
public java.util.List<Group> getGroups()
Gets an unmodifiable list of all groups- Returns:
- an unmodifiable list of all groups
-
getUsers
public java.util.List<User> getUsers()
Gets an unmodifiable list of all loaded users- Returns:
- an unmodifiable list of all loaded users
-
getRegisteredUsers
public java.util.List<java.lang.String> getRegisteredUsers()
Gets a list of all users- Returns:
- a list of all users
-
getRegisteredUsersUUID
public java.util.Map<java.util.UUID,java.lang.String> getRegisteredUsersUUID()
Gets a list of all users and their uuids- Returns:
- a list of all users
-
getGroupUsers
public java.util.List<java.lang.String> getGroupUsers(Group group)
Gets a list of all user which are in the given group- Parameters:
group
- the group- Returns:
- a list of all user which are in the given group
-
getGroupUsersUUID
public java.util.Map<java.util.UUID,java.lang.String> getGroupUsersUUID(Group group)
Gets a list of all user and their UUIDs which are in the given group- Parameters:
group
- the group- Returns:
- a list of all user which are in the given group
-
deleteUser
public void deleteUser(User user)
Deletes a user from cache and database.- Parameters:
user
- the user to delete
-
deleteGroup
public void deleteGroup(Group group)
Deletes a user from cache and database and validates all groups and users.- Parameters:
group
- the group the remove
-
addUser
public void addUser(User user)
Adds a user to cache and database.- Parameters:
user
- the user to add
-
addGroup
public void addGroup(Group group)
Adds a group to cache and database.- Parameters:
group
- the group to add
-
format
public void format()
Formats the permissions backEnd.
-
cleanup
public int cleanup()
Cleans the permissions backEnd and wipes 0815 users.- Returns:
- the number of deleted users
-
addUserGroup
@Deprecated public void addUserGroup(User user, Group group)
Deprecated.Adds the given group to the user.- Parameters:
user
- the user to add the group togroup
- the group to add to the user
-
addUserGroup
public void addUserGroup(User user, Group group, java.lang.String server, java.lang.String world)
Adds the given group to the user.- Parameters:
user
- the user to add the group togroup
- the group to add to the userserver
- optional: the serverworld
- optional: the world
-
addUserTimedGroup
@Deprecated public void addUserTimedGroup(User user, TimedValue<Group> group)
Deprecated.Adds the given timed group to the user.- Parameters:
user
- the user to add the group togroup
- the timed group to add to the user
-
addUserTimedGroup
public void addUserTimedGroup(User user, TimedValue<Group> group, java.lang.String server, java.lang.String world)
Adds the given timed group to the user.- Parameters:
user
- the user to add the group togroup
- the timed group to add to the userserver
- optional: the serverworld
- optional: the world
-
removeUserGroup
@Deprecated public void removeUserGroup(User user, Group group)
Deprecated.Removes the given group from the user.- Parameters:
user
- the user to remove the group fromgroup
- the group to remove from the user
-
removeUserGroup
public void removeUserGroup(User user, Group group, java.lang.String server, java.lang.String world)
Removes the given group from the user.- Parameters:
user
- the user to remove the group fromgroup
- the group to remove from the userserver
- optional: the serverworld
- optional: the world
-
removeUserTimedGroup
@Deprecated public void removeUserTimedGroup(User user, Group group)
Deprecated.Removes the given timed group from the user.- Parameters:
user
- the user to remove the group fromgroup
- the timed group to remove from the user
-
removeUserTimedGroup
public void removeUserTimedGroup(User user, Group group, java.lang.String server, java.lang.String world)
Removes the given timed group from the user.- Parameters:
user
- the user to remove the group fromgroup
- the timed group to remove from the userserver
- optional: the serverworld
- optional: the world
-
addUserPerm
@Deprecated public void addUserPerm(User user, java.lang.String perm)
Deprecated.Adds a permission to the user.- Parameters:
user
- the user to add the permission toperm
- the permission to add to the user
-
removeUserPerm
@Deprecated public void removeUserPerm(User user, java.lang.String perm)
Deprecated.Removes a permission from the user.- Parameters:
user
- the user to remove the permission fromperm
- the permission to remove from the user
-
addUserPerm
public void addUserPerm(User user, java.lang.String server, java.lang.String world, java.lang.String perm)
Adds a permission to a user.- Parameters:
user
- the userserver
- optional: the serverworld
- optional: the worldperm
- the permission to add
-
addUserTimedPerm
public void addUserTimedPerm(User user, java.lang.String server, java.lang.String world, TimedValue perm)
Adds a timed permission to a user.- Parameters:
user
- the userserver
- optional: the serverworld
- optional: the worldperm
- the timed permission to add
-
removeUserPerm
public void removeUserPerm(User user, java.lang.String server, java.lang.String world, java.lang.String perm)
Removes a permission from a user.- Parameters:
user
- the userserver
- optional: the serverworld
- optional: the worldperm
- the permission to remove
-
removeUserTimedPerm
public void removeUserTimedPerm(User user, java.lang.String server, java.lang.String world, java.lang.String perm)
Removes a timed permission from a user.- Parameters:
user
- the userserver
- optional: the serverworld
- optional: the worldperm
- timed the permission to remove
-
setUserDisplay
public void setUserDisplay(User user, java.lang.String display, java.lang.String server, java.lang.String world)
Sets the displayname of the group- Parameters:
user
- the userdisplay
- the displayserver
- the server to set the display on; may be nullworld
- the world to ser the display in; may be null
-
setUserPrefix
public void setUserPrefix(User user, java.lang.String prefix, java.lang.String server, java.lang.String world)
Sets the prefix for the group.- Parameters:
user
- the userprefix
- the prefixserver
- the server to set the prefix on; may be nullworld
- the world to ser the prefix in; may be null
-
setUserSuffix
public void setUserSuffix(User user, java.lang.String suffix, java.lang.String server, java.lang.String world)
Sets the suffix for the group.- Parameters:
user
- the usersuffix
- the suffixserver
- the server to set the suffix on; may be nullworld
- the world to ser the suffix in; may be null
-
addGroupPerm
@Deprecated public void addGroupPerm(Group group, java.lang.String perm)
Deprecated.Adds a permission to a group.- Parameters:
group
- the groupperm
- the permission to add
-
removeGroupPerm
@Deprecated public void removeGroupPerm(Group group, java.lang.String perm)
Deprecated.Removes a permission from a group.- Parameters:
group
- the groupperm
- the permission to remove
-
addGroupPerm
public void addGroupPerm(Group group, java.lang.String server, java.lang.String world, java.lang.String perm)
Adds a permission to a group.- Parameters:
group
- the groupserver
- optional: the serverworld
- optional: the worldperm
- the permission to add
-
addGroupTimedPerm
public void addGroupTimedPerm(Group group, java.lang.String server, java.lang.String world, TimedValue perm)
Adds a timed permission to a group.- Parameters:
group
- the groupserver
- optional: the serverworld
- optional: the worldperm
- the timed permission to add
-
removeGroupPerm
public void removeGroupPerm(Group group, java.lang.String server, java.lang.String world, java.lang.String perm)
Removes a permission from a group.- Parameters:
group
- the groupserver
- optional: the serverworld
- optional: the worldperm
- the permission to remove
-
removeGroupTimedPerm
public void removeGroupTimedPerm(Group group, java.lang.String server, java.lang.String world, java.lang.String perm)
Removes a timed permission from a group.- Parameters:
group
- the groupserver
- optional: the serverworld
- optional: the worldperm
- the timed permission to remove
-
addGroupInheritance
@Deprecated public void addGroupInheritance(Group group, Group toadd)
Deprecated.Adds the toadd group to the group as inheritance- Parameters:
group
- the group which should inherittoadd
- the group which should be inherited
-
addGroupInheritance
public void addGroupInheritance(Group group, Group toadd, java.lang.String server, java.lang.String world)
Adds the toadd group to the group as inheritance- Parameters:
group
- the group which should inherittoadd
- the group which should be inheritedserver
- optional: the serverworld
- optional: the world
-
addGroupTimedInheritance
@Deprecated public void addGroupTimedInheritance(Group group, TimedValue<Group> toadd)
Deprecated.Adds the toadd timed group to the group as inheritance- Parameters:
group
- the group which should inherittoadd
- the timed group which should be inherited
-
addGroupTimedInheritance
public void addGroupTimedInheritance(Group group, TimedValue<Group> toadd, java.lang.String server, java.lang.String world)
Adds the toadd timed group to the group as inheritance- Parameters:
group
- the group which should inherittoadd
- the timed group which should be inheritedserver
- optional: the serverworld
- optional: the world
-
removeGroupInheritance
@Deprecated public void removeGroupInheritance(Group group, Group toremove)
Deprecated.Removes the toremove group from the group as inheritance- Parameters:
group
- the group which should no longer inherittoremove
- the group which should no longer be inherited
-
removeGroupInheritance
public void removeGroupInheritance(Group group, Group toremove, java.lang.String server, java.lang.String world)
Removes the toremove group from the group as inheritance- Parameters:
group
- the group which should no longer inherittoremove
- the group which should no longer be inheritedserver
- optional: the serverworld
- optional: the world
-
removeGroupTimedInheritance
@Deprecated public void removeGroupTimedInheritance(Group group, Group toremove)
Deprecated.Removes the toremove timed group from the group as inheritance- Parameters:
group
- the group which should no longer inherittoremove
- the timed group which should no longer be inherited
-
removeGroupTimedInheritance
public void removeGroupTimedInheritance(Group group, Group toremove, java.lang.String server, java.lang.String world)
Removes the toremove timed group from the group as inheritance- Parameters:
group
- the group which should no longer inherittoremove
- the timed group which should no longer be inheritedserver
- optional: the serverworld
- optional: the world
-
ladderGroup
public void ladderGroup(Group group, java.lang.String ladder)
Set the ladder for the group.- Parameters:
group
- the groupladder
- the ladder name
-
rankGroup
public void rankGroup(Group group, int rank)
Sets the rank for the group.- Parameters:
group
- the grouprank
- the rank
-
weightGroup
public void weightGroup(Group group, int weight)
Sets the weight for the group.- Parameters:
group
- the groupweight
- the weight
-
setGroupDefault
public void setGroupDefault(Group group, boolean isdefault)
Sets if the the group is a default group.- Parameters:
group
- the groupisdefault
- whether or not the group is aded by default to new users
-
setGroupDisplay
public void setGroupDisplay(Group group, java.lang.String display, java.lang.String server, java.lang.String world)
Sets the displayname of the group- Parameters:
group
- the groupdisplay
- the displayserver
- the server to set the display on; may be nullworld
- the world to ser the display in; may be null
-
setGroupPrefix
public void setGroupPrefix(Group group, java.lang.String prefix, java.lang.String server, java.lang.String world)
Sets the prefix for the group.- Parameters:
group
- the groupprefix
- the prefixserver
- the server to set the prefix on; may be nullworld
- the world to ser the prefix in; may be null
-
setGroupSuffix
public void setGroupSuffix(Group group, java.lang.String suffix, java.lang.String server, java.lang.String world)
Sets the suffix for the group.- Parameters:
group
- the groupsuffix
- the suffixserver
- the server to set the suffix on; may be nullworld
- the world to ser the suffix in; may be null
-
migrateBackEnd
public void migrateBackEnd(BackEndType bet)
Migrates the permissions to the given backnd type.- Parameters:
bet
- the backEnd type to migrate to
-
migrateUseUUID
public void migrateUseUUID(java.util.Map<java.lang.String,java.util.UUID> uuids)
Converts the permissions database to use UUIDs for player identification.- Parameters:
uuids
- a map of player names and their corresponding UUIDs
-
migrateUsePlayerNames
public void migrateUsePlayerNames(java.util.Map<java.util.UUID,java.lang.String> playernames)
Converts the permissions database to use player names for player identification.- Parameters:
playernames
- a map of UUIDs and their corresponding player names
-
reloadUser
public void reloadUser(java.lang.String user)
-
reloadUser
public void reloadUser(java.util.UUID uuid)
-
reloadGroup
public void reloadGroup(java.lang.String group)
-
reloadUsers
public void reloadUsers()
-
reloadGroups
public void reloadGroups()
-
addUserToCache
public void addUserToCache(User u)
-
removeUserFromCache
public void removeUserFromCache(User u)
-
addGroupToCache
public void addGroupToCache(Group g)
-
removeGroupFromCache
public void removeGroupFromCache(Group g)
-
-