Compare commits

..
3 Commits
Author SHA1 Message Date
Hare 2e35905599 bump 26.1 paper-api & jvmToolchain 2026-04-27 17:35:35 +09:00
Hare 3c60d4a433 bump 26.1 2026-04-27 17:32:50 +09:00
Hare 9673e1e6e9 feat: Folia support 2026-03-11 17:15:56 +09:00
3 changed files with 32 additions and 8 deletions
+9 -4
View File
@@ -2,8 +2,8 @@ group = "net.hareworks"
version = "1.1"
plugins {
kotlin("jvm") version "2.2.21"
id("de.eldoria.plugin-yml.paper") version "0.8.0"
kotlin("jvm") version "2.3.21"
id("de.eldoria.plugin-yml.paper") version "0.9.0"
id("com.gradleup.shadow") version "9.2.2"
}
repositories {
@@ -12,9 +12,14 @@ repositories {
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:26.1.2.build.49-beta")
paperLibrary("org.jetbrains.kotlin:kotlin-stdlib")
}
kotlin {
jvmToolchain(25)
}
tasks {
withType<Jar> {
archiveBaseName.set("Permits-Lib")
@@ -30,7 +35,7 @@ paper {
name = "permits-lib"
description = "Permission Library"
version = getVersion().toString()
apiVersion = "1.21.10"
apiVersion = "26.1"
authors =
listOf(
"Hare-K02",
@@ -25,7 +25,7 @@ class AttachmentSynchronizer(
permissible: Permissible,
patch: AttachmentPatch,
) {
ThreadChecks.ensurePrimaryThread("AttachmentSynchronizer.applyPatch")
ThreadChecks.ensureRegionThread("AttachmentSynchronizer.applyPatch", permissible)
if (patch.changes.isEmpty()) return
val handle = ensureHandle(permissible)
patch.changes.forEach { (id, value) ->
@@ -58,7 +58,7 @@ class AttachmentSynchronizer(
}
fun clear(permissible: Permissible) {
ThreadChecks.ensurePrimaryThread("AttachmentSynchronizer.clear")
ThreadChecks.ensureRegionThread("AttachmentSynchronizer.clear", permissible)
handles.remove(permissible)?.attachment?.remove()
}
@@ -1,11 +1,30 @@
package net.hareworks.permits_lib.util
import org.bukkit.Bukkit
import org.bukkit.entity.Player
import org.bukkit.permissions.Permissible
internal object ThreadChecks {
/**
* For Bukkit-global operations (e.g. PluginManager permission registration).
* In Folia there is no single primary thread; callers should ensure they run
* on the global region scheduler (e.g. during onEnable / onDisable).
*/
fun ensurePrimaryThread(action: String) {
check(Bukkit.isPrimaryThread()) {
"$action must be invoked from the primary server thread."
// no-op for global ops: Folia has no single primary thread.
// PluginManager operations are safe when called from onEnable/onDisable
// or from the global region scheduler.
}
/**
* For player-bound operations (e.g. PermissionAttachment mutation).
* Verifies that the current thread owns the region for the given [permissible].
* Non-player permissibles are skipped since they have no region owner.
*/
fun ensureRegionThread(action: String, permissible: Permissible) {
val player = permissible as? Player ?: return
check(Bukkit.isOwnedByCurrentRegion(player)) {
"Action '$action' must be called on the owning region thread for ${player.name}"
}
}
}