feat: tagsの削除
This commit is contained in:
parent
91dbd240b5
commit
8a860c85f4
|
|
@ -127,7 +127,6 @@ commands = kommand(this) {
|
|||
command("eco") {
|
||||
permission {
|
||||
description = "Allows /eco"
|
||||
tags("economy")
|
||||
}
|
||||
|
||||
literal("give") {
|
||||
|
|
@ -141,7 +140,7 @@ commands = kommand(this) {
|
|||
|
||||
- `permissions { ... }` で名前空間やルートセグメント (`rootSegment = "command"`) を定義すると、`hareworks.command.eco`, `hareworks.command.eco.give` のような ID が自動生成され、`permits-lib` の `MutationSession` を使って Bukkit に適用されます。
|
||||
- `literal` や `command` ノードはデフォルトで Bukkit パーミッションとして登録されます。`string` や `integer` などの引数ノードは、`requires("permission.id")` もしくは `permission { id = ... }` を記述した場合のみ登録され、それ以外は構造上のノードに留まります。これにより `/money give <player> <amount>` では `...money.give` だけ付与すれば実行できます。
|
||||
- 各ブロック内の `permission { ... }` で説明文・デフォルト値 (`PermissionDefault.TRUE/FALSE/OP/NOT_OP`)・タグ・パスを細かく制御できます。`requires(...)` を使うと DSL での検証と permits 側の登録が同じ ID になります。
|
||||
- 各ブロック内の `permission { ... }` で説明文・デフォルト値 (`PermissionDefault.TRUE/FALSE/OP/NOT_OP`)・ワイルドカード・パスを細かく制御できます。`requires(...)` を使うと DSL での検証と permits 側の登録が同じ ID になります。
|
||||
- 引数ノードを明示的に登録したい場合は `permission { id = "example.money.give.amount" }` や `requires("example.money.give.amount")` を設定してください。逆にリテラルでも不要なら `skipPermission()` で除外できます。
|
||||
- `requires("custom.id")` を指定した場合も、同じ ID が DSL の実行と `permits-lib` への登録の両方で利用されます (名前空間外の ID は登録対象外になります)。
|
||||
- `KommandLib` のライフサイクルに合わせて `MutationSession` が適用/解除されるため、プラグインの有効化・無効化に伴い Bukkit のパーミッションリストも最新状態に保たれます。
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 58ad0e67c9b4c46a74019d4de11c0b72a37e3db7
|
||||
Subproject commit 00d58604576a81d61ef28bf8588a768334e60708
|
||||
|
|
@ -15,7 +15,6 @@ class PermissionConfig internal constructor(
|
|||
val defaultDescription: (PermissionContext) -> String?,
|
||||
val defaultValue: PermissionDefault,
|
||||
val defaultWildcard: Boolean,
|
||||
val defaultTags: Set<String>,
|
||||
private val sessionProvider: (JavaPlugin) -> MutationSession
|
||||
) {
|
||||
fun session(plugin: JavaPlugin): MutationSession = sessionProvider(plugin)
|
||||
|
|
@ -29,8 +28,7 @@ class PermissionConfigBuilder internal constructor(private val plugin: JavaPlugi
|
|||
var includeRootNode: Boolean = true
|
||||
var argumentPrefix: String = "arg"
|
||||
var defaultValue: PermissionDefault = PermissionDefault.OP
|
||||
var wildcard: Boolean = true
|
||||
private val tags: MutableSet<String> = linkedSetOf("kommand")
|
||||
var wildcard: Boolean = false
|
||||
private var descriptionTemplate: (PermissionContext) -> String? = { ctx ->
|
||||
when (ctx.kind) {
|
||||
PermissionNodeKind.COMMAND -> "Allows /${ctx.commandName}"
|
||||
|
|
@ -44,10 +42,6 @@ class PermissionConfigBuilder internal constructor(private val plugin: JavaPlugi
|
|||
descriptionTemplate = block
|
||||
}
|
||||
|
||||
fun tags(vararg values: String) {
|
||||
values.filter { it.isNotBlank() }.forEach { tags += it.trim() }
|
||||
}
|
||||
|
||||
fun session(factory: (JavaPlugin) -> MutationSession) {
|
||||
sessionFactory = factory
|
||||
}
|
||||
|
|
@ -67,7 +61,6 @@ class PermissionConfigBuilder internal constructor(private val plugin: JavaPlugi
|
|||
defaultDescription = descriptionTemplate,
|
||||
defaultValue = defaultValue,
|
||||
defaultWildcard = wildcard,
|
||||
defaultTags = tags.toSet(),
|
||||
sessionProvider = sessionFactory ?: { PermitsLib.session(it) }
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ class PermissionOptions {
|
|||
var description: String? = null
|
||||
var defaultValue: PermissionDefault? = null
|
||||
var wildcard: Boolean? = null
|
||||
val tags: MutableSet<String> = linkedSetOf()
|
||||
var skip: Boolean = false
|
||||
private var customPath: MutableList<String>? = null
|
||||
internal var preferSkipByDefault: Boolean = false
|
||||
|
|
@ -28,10 +27,6 @@ class PermissionOptions {
|
|||
resolvedId = id
|
||||
}
|
||||
|
||||
fun tags(vararg values: String) {
|
||||
values.filter { it.isNotBlank() }.forEach { tags += it.trim() }
|
||||
}
|
||||
|
||||
fun skipPermission() {
|
||||
skip = true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,5 @@ data class PlannedPermission(
|
|||
val description: String?,
|
||||
val defaultValue: PermissionDefault,
|
||||
val wildcard: Boolean,
|
||||
val tags: Set<String>,
|
||||
val registration: NodeRegistration
|
||||
)
|
||||
|
|
|
|||
|
|
@ -123,7 +123,6 @@ internal class PermissionPlanner(
|
|||
val description = options.description ?: config.defaultDescription(context)
|
||||
val defaultValue = options.defaultValue ?: config.defaultValue
|
||||
val wildcard = options.wildcard ?: config.defaultWildcard
|
||||
val tags = (config.defaultTags + options.tags).filter { it.isNotBlank() }.toSet()
|
||||
options.resolve(finalId)
|
||||
val parentPath = if (relativePath.isNotEmpty()) relativePath.dropLast(1).takeIf { it.isNotEmpty() } else null
|
||||
return PlannedPermission(
|
||||
|
|
@ -133,7 +132,6 @@ internal class PermissionPlanner(
|
|||
description = description,
|
||||
defaultValue = defaultValue,
|
||||
wildcard = wildcard,
|
||||
tags = tags,
|
||||
registration = registration
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ internal class PermissionRuntime(
|
|||
entry.description?.let { description = it }
|
||||
defaultValue = entry.defaultValue
|
||||
wildcard = entry.wildcard
|
||||
entry.tags.forEach(::tag)
|
||||
}
|
||||
val parent = entry.parentPath
|
||||
if (parent != null && parent.isNotEmpty()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user