Make Bukkit permissions support maps

This commit is contained in:
Mariell Hoversholm 2020-04-14 15:36:00 +02:00 committed by Minecrell
parent ac4f48ec8b
commit 2b2627e2db
2 changed files with 12 additions and 3 deletions

View file

@ -63,7 +63,9 @@ bukkit {
permissions { permissions {
'testplugin.*' { 'testplugin.*' {
children = ['testplugin.test'] children = ['testplugin.test'] // Defaults permissions to true
// You can also specify the values of the permissions
childrenMap = ['testplugin.test': false]
} }
'testplugin.test' { 'testplugin.test' {
description = 'Allows you to run the test command' description = 'Allows you to run the test command'
@ -118,7 +120,9 @@ bukkit {
permissions { permissions {
"testplugin.*" { "testplugin.*" {
children = listOf("testplugin.test") children = listOf("testplugin.test") // Defaults permissions to true
// You can also specify the values of the permissions
childrenMap = mapOf("testplugin.test" to true)
} }
"testplugin.test" { "testplugin.test" {
description = "Allows you to run the test command" description = "Allows you to run the test command"

View file

@ -78,7 +78,12 @@ class BukkitPluginDescription(project: Project) : Serializable {
data class Permission(@Transient @JsonIgnore val name: String) : Serializable { data class Permission(@Transient @JsonIgnore val name: String) : Serializable {
var description: String? = null var description: String? = null
var default: Default? = null var default: Default? = null
var children: List<String>? = null var children: List<String>? // No @[Transient JsonIgnore] needed as it has no backing value
get() = childrenMap?.filterValues { it }?.keys?.toList()
set(value) {
childrenMap = value?.map { it to true }?.toMap()
}
@JsonProperty("children") var childrenMap: Map<String, Boolean>? = null
enum class Default { enum class Default {
@JsonProperty("true") TRUE, @JsonProperty("true") TRUE,