- ワイルドカードが利用できない不具合の修正
- 不使用のコードの削除
- groupの修正
This commit is contained in:
Keisuke Hirata 2025-11-28 07:36:26 +09:00
parent 9bab7d9c2c
commit 6c2f860df6
6 changed files with 37 additions and 58 deletions

View File

@ -75,6 +75,32 @@ class ExamplePlugin : JavaPlugin() {
} }
``` ```
### Procedural Edits with `MutablePermissionTree`
If you prefer an imperative style before handing the structure to Bukkit, you can clone any existing tree,
mutate it procedurally, and then apply the result:
```kotlin
val baseTree = permissionTree("example") {
node("command") { node("reload") }
}
val mutable = MutablePermissionTree.from(baseTree)
mutable.node("command") {
node("debug") {
description = "Allows /example debug"
defaultValue = PermissionDefault.OP
}
child("helper", value = false) // unlink helper if present
}
mutable.remove("command.legacy")
permits.applyTree(mutable.build())
```
The mutable API mirrors the DSL (`node`, `child`, `childAbsolute`, `remove`, `removeChild`, etc.) so you can
stage edits procedurally before ever touching `MutationSession`.
### Concepts ### Concepts
- **Permission tree** immutable graph of `PermissionNode`s. Nodes specify description, default value, - **Permission tree** immutable graph of `PermissionNode`s. Nodes specify description, default value,

View File

@ -1,7 +1,7 @@
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
group = "net.hareworks.hcu" group = "net.hareworks"
version = "1.0" version = "1.1"
plugins { plugins {
kotlin("jvm") version "2.2.21" kotlin("jvm") version "2.2.21"
@ -17,7 +17,6 @@ val exposedVersion = "1.0.0-rc-3"
dependencies { dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT")
compileOnly("org.jetbrains.kotlin:kotlin-stdlib")
} }
tasks { tasks {
shadowJar { shadowJar {
@ -27,7 +26,7 @@ tasks {
} }
paper { paper {
main = "net.hareworks.permits_lib.App" main = "net.hareworks.permits_lib.plugin.Plugin"
name = "permits-lib" name = "permits-lib"
description = "Permission Library" description = "Permission Library"
version = getVersion().toString() version = getVersion().toString()

View File

@ -1,9 +1 @@
/* rootProject.name = "permits-lib"
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
* For more detailed information on multi-project builds, please refer to https://docs.gradle.org/8.14.3/userguide/multi_project_builds.html in the Gradle documentation.
* This project uses @Incubating APIs which are subject to change.
*/
rootProject.name = "kommand-lib"

View File

@ -1,44 +0,0 @@
package net.hareworks.permits_lib
import net.hareworks.permits_lib.bukkit.MutationSession
import net.hareworks.permits_lib.dsl.permissionTree
import org.bukkit.permissions.PermissionDefault
import org.bukkit.plugin.java.JavaPlugin
class App : JavaPlugin() {
companion object {
lateinit var instance: App
private set
}
private lateinit var session: MutationSession
override fun onEnable() {
instance = this
session = MutationSession.create(this)
val baseTree = permissionTree("permits-lib") {
node("command") {
description = "Allows execution of all permits-lib commands."
defaultValue = PermissionDefault.OP
node("reload") {
description = "Allows /permitslib reload."
}
}
}
session.applyTree(baseTree)
// Example of mutating the existing tree without rebuilding everything.
session.edit {
node("command") {
node("debug") {
description = "Allows /permitslib debug utilities."
defaultValue = PermissionDefault.OP
wildcard = false
}
}
}
}
}

View File

@ -0,0 +1,6 @@
package net.hareworks.permits_lib.plugin
import org.bukkit.plugin.java.JavaPlugin
@Suppress("unused")
class Plugin : JavaPlugin() {}

View File

@ -12,7 +12,7 @@ value class PermissionId private constructor(val value: String) {
override fun toString(): String = value override fun toString(): String = value
companion object { companion object {
private val VALID_PATTERN = Regex("""^[a-z0-9_.-]+$""") private val VALID_PATTERN = Regex("""^[a-z0-9_.-]+(\.\*)?$""")
fun of(raw: String): PermissionId { fun of(raw: String): PermissionId {
val normalized = raw.trim().lowercase() val normalized = raw.trim().lowercase()