Skip to content

Commit

Permalink
feat: Reloadable Ranks (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
CoasterFreakDE authored May 22, 2024
1 parent 0467b57 commit 0b35e0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ import org.bukkit.permissions.PermissionDefault
class RankCommand : CommandExecutor, TabCompleter {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {

if (args.size == 1 && args[0].equals("reload", true)) {
RankManager.reloadRanks()
sender.sendMessagePrefixed("Ranks reloaded.")
return true
}

if (args.size < 2) {
sender.sendMessagePrefixed("/rank <player> <rank>")
sender.sendMessageBlock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object RankManager {
private val luckPerms = LuckPermsProvider.get()

init {
loadRanks()
reloadRanks()
}

/**
Expand All @@ -27,7 +27,7 @@ object RankManager {
* Once loaded, the `ranks` list is sorted by weight in ascending order.
* This method also logs the loaded ranks and their count.
*/
private fun loadRanks() {
fun reloadRanks() {
ranks = emptyList()
luckPerms.groupManager.loadedGroups.forEach { rank ->
val displayName = rank.displayName ?: rank.name
Expand Down

0 comments on commit 0b35e0f

Please sign in to comment.