Class TownyPerms

java.lang.Object
com.palmergames.bukkit.towny.permissions.TownyPerms

public class TownyPerms extends Object
Author:
ElgarL
  • Field Details

    • registeredPermissions

      protected static final LinkedHashMap<String,org.bukkit.permissions.Permission> registeredPermissions
    • attachments

      protected static final Map<String,org.bukkit.permissions.PermissionAttachment> attachments
  • Constructor Details

    • TownyPerms

      public TownyPerms()
  • Method Details

    • initialize

      public static void initialize(Towny plugin)
    • loadPerms

      public static void loadPerms(@NotNull @NotNull Path permsYMLPath)
      Load the townyperms.yml file. If it doesn't exist create it from the resource file in the jar.
      Parameters:
      permsYMLPath - - Path to townyperms.yml in the data directory.
      Throws:
      TownyInitException - - Thrown when if we fail to copy or load townyperms.yml.
    • assignPermissions

      public static void assignPermissions(Resident resident, org.bukkit.entity.Player player)
      Register a specific residents permissions with Bukkit.
      Parameters:
      resident - - Resident to check if player is valid
      player - - Player to register permission
    • removeAttachment

      public static void removeAttachment(String name)
      Should only be called when a player leaves the server.
      Parameters:
      name - - Player's name to remove attachment of
    • updateOnlinePerms

      public static void updateOnlinePerms()
      Update the permissions for all online residents
    • updateTownPerms

      public static void updateTownPerms(Town town)
      Update the permissions for all residents of a town (if online)
      Parameters:
      town - - Town to target
    • updateNationPerms

      public static void updateNationPerms(Nation nation)
      Update the permissions for all residents of a nation (if online)
      Parameters:
      nation - - Nation to target
    • getResidentPerms

      public static LinkedHashMap<String,Boolean> getResidentPerms(Resident resident)
      Returns a sorted map of this residents current permissions.
      Parameters:
      resident - - Resident to check
      Returns:
      a sorted Map of permission nodes
    • registerPermissionNodes

      public static void registerPermissionNodes()
    • getDefault

      public static List<String> getDefault()
      Default permissions everyone gets
      Returns:
      a List of permissions
    • getTownRanks

      public static List<String> getTownRanks()
      Fetch a list of all available town ranks
      Returns:
      a list of rank names.
    • getTownDefault

      public static List<String> getTownDefault(String townName)
      Default permissions everyone in a town gets
      Parameters:
      townName - Name of town lowercased.
      Returns:
      a list of permissions
    • getTownMayor

      public static List<String> getTownMayor()
      A town mayors permissions
      Returns:
      a list of permissions
    • getTownRankPermissions

      public static List<String> getTownRankPermissions(String rank)
      Get a specific ranks permissions
      Parameters:
      rank - - Rank to check permissions for
      Returns:
      a List of permissions
    • getNationRanks

      public static List<String> getNationRanks()
      Fetch a list of all available nation ranks
      Returns:
      a list of rank names.
    • getNationDefault

      public static List<String> getNationDefault(String nationName)
      Default permissions everyone in a nation gets
      Parameters:
      nationName - Name of nation lowercased.
      Returns:
      a List of permissions
    • getNationKing

      public static List<String> getNationKing()
      A nations kings permissions
      Returns:
      a List of permissions
    • getNationRankPermissions

      public static List<String> getNationRankPermissions(String rank)
      Get a specific ranks permissions
      Parameters:
      rank - - Rank to get permissions of
      Returns:
      a List of Permissions
    • matchNationRank

      @Nullable public static @Nullable String matchNationRank(String rank)
      Used to match a given rank to a case-sensitive Nation Rank.
      Parameters:
      rank - String representing the rank the user typed in.
      Returns:
      String of the NationRank which matches or null;
    • matchTownRank

      @Nullable public static @Nullable String matchTownRank(String rank)
      Used to match a given rank to a case-sensitive Town Rank.
      Parameters:
      rank - String representing the rank the user typed in.
      Returns:
      String of the TownRank which matches or null;
    • hasPeacefulNodes

      public static boolean hasPeacefulNodes()
    • getResidentPrimaryRankPrefix

      public static String getResidentPrimaryRankPrefix(Resident resident)
    • getHighestPriorityRank

      public static String getHighestPriorityRank(Resident resident, List<String> ranks, Function<String,List<String>> rankFunction)
    • collectPermissions

      public static void collectPermissions()
      Update the list of permissions registered with bukkit
    • getAllRegisteredPermissions

      public List<String> getAllRegisteredPermissions(boolean includeChildren)
      Fetch all permissions which are registered with superperms. {can include child nodes)
      Parameters:
      includeChildren - - If child nodes should be included
      Returns:
      List of all permission nodes
    • getAllChildren

      public static Map<String,Boolean> getAllChildren(String node, Set<String> playerPermArray)
      Returns a map of ALL child permissions registered with bukkit null is empty
      Parameters:
      node - - Parent node
      playerPermArray - current list of perms to check against for negations
      Returns:
      Map of child permissions
    • getChildren

      public static Map<String,Boolean> getChildren(String node)
      Returns a map of the child permissions (1 node deep) as registered with Bukkit. null is empty
      Parameters:
      node - - Parent node
      Returns:
      Map of child permissions
    • getGroupList

      public static List<String> getGroupList()
    • mapHasGroup

      public static boolean mapHasGroup(String group)
    • getPermsOfGroup

      public static List<String> getPermsOfGroup(String group)
    • getTownyPermsFile

      public static CommentedConfiguration getTownyPermsFile()