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

Make Bukkit permission children be a map #7

merged 1 commit into from
Apr 30, 2021

Conversation

Proximyst
Copy link
Contributor

Fixes #5

This makes the Bukkit permission children be a map instead of a list.

Code which says this is the case: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java#169-172

@stephan-gh
Copy link
Member

That's not entirely correct, children can be also a list: https://github.com/Bukkit/Bukkit/blob/f210234e59275330f83b994e199c76f6abd41ee7/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java#L727-L730, which I think covers the only useful case.

If you really want a map for some reason, then we should at least have an overload setter which accepts a list (for some sort of backwards compatibility).

@Proximyst
Copy link
Contributor Author

While Groovy might be able to handle a setter such as setChildren(List<String>) just fine, Kotlin won't let you compile as it tries that on the map field. Do you have any ideas on how to do it in that case?

@stephan-gh
Copy link
Member

Uh yeah. I forgot how/if that is possible in Kotlin... 🤔
(Haven't used Kotlin for months...)

@Proximyst
Copy link
Contributor Author

I suppose making it something à la this would work?

children = listOf("perm.node") // Old API delegates to the under:
childrenMap = mapOf("perm.node" to true)

@stephan-gh
Copy link
Member

@Proximyst Hm, yes. I suppose that would be the best solution. Thanks.

You would make children a @Transient @JsonIgnore so it doesn't get serialized. Then you add childrenMap with @JsonProperty("children"). That should work.

@stephan-gh stephan-gh merged commit 2b2627e into Minecrell:master Apr 30, 2021
@@ -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.

rainbowdashlabs pushed a commit to rainbowdashlabs/plugin-yml that referenced this pull request Oct 31, 2024
…rell#7)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Permissions' children are not a list
2 participants