Skip to content
This repository was archived by the owner on Dec 7, 2024. It is now read-only.

Make Bukkit permission children be a map #7

Merged
merged 1 commit into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ bukkit {

permissions {
'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' {
description = 'Allows you to run the test command'
Expand Down Expand Up @@ -118,7 +120,9 @@ bukkit {

permissions {
"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" {
description = "Allows you to run the test command"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ class BukkitPluginDescription(project: Project) : Serializable {
data class Permission(@Transient @JsonIgnore val name: String) : Serializable {
var description: String? = null
var default: Default? = null
var children: List<String>? = null
var children: List<String>? // No @[Transient JsonIgnore] needed as it has no backing value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this comment doesn't seem to be correct:

Execution failed for task ':Bukkit:generateBukkitPluginDescription'.
> com.fasterxml.jackson.databind.JsonMappingException: Conflicting getter definitions for property "children": net.minecrell.pluginyml.bukkit.BukkitPluginDescription$Permission#getChildren() vs net.minecrell.pluginyml.bukkit.BukkitPluginDescription$Permission#getChildrenMap() (through reference chain: net.minecrell.pluginyml.bukkit.BukkitPluginDescription["permissions"])

@JsonIgnore is needed on the getter to make it work.

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 {
@JsonProperty("true") TRUE,
Expand Down