Skip to content

Commit

Permalink
fix(velocity): better permission level handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Syrent committed Jan 11, 2025
1 parent fea8055 commit aae43a2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
7 changes: 4 additions & 3 deletions sayanvanish-bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {

stickynote {
modules(StickyNoteModules.BUKKIT, StickyNoteModules.BUKKIT_NMS)
relocate(!gradle.startParameter.getTaskNames().any { it.startsWith("runServer") || it.startsWith("runFolia") || it.startsWith("runVelocity") })
// relocate(!gradle.startParameter.getTaskNames().any { it.startsWith("runServer") || it.startsWith("runFolia") || it.startsWith("runVelocity") })
}

dependencies {
Expand All @@ -32,7 +32,7 @@ tasks.withType(xyz.jpenilla.runtask.task.AbstractRun::class) {
vendor = JvmVendorSpec.JETBRAINS
languageVersion = JavaLanguageVersion.of(21)
}
jvmArgs("-XX:+AllowEnhancedClassRedefinition")
jvmArgs("-XX:+AllowEnhancedClassRedefinition", "-Dnet.kyori.adventure.text.warnWhenLegacyFormattingDetected=false")
}

tasks {
Expand Down Expand Up @@ -72,10 +72,11 @@ tasks {
// url("https://github.com/NEZNAMY/TAB/releases/download/4.1.6/TAB.v4.1.6.jar")
// url("https://ci.lucko.me/job/spark/418/artifact/spark-bukkit/build/libs/spark-1.10.73-bukkit.jar")
// url("https://github.com/Insprill/custom-join-messages/releases/download/v17.5.0/custom-join-messages-17.5.0.jar")
url("https://github.com/NEZNAMY/TAB-Bridge/releases/download/6.0.0/TAB-Bridge.v6.0.0.jar")
url("https://github.com/NEZNAMY/TAB-Bridge/releases/download/6.0.1/TAB-Bridge.v6.0.1.jar")
url("https://github.com/EssentialsX/Essentials/releases/download/2.20.1/EssentialsX-2.20.1.jar")
url("https://download.luckperms.net/1567/bukkit/loader/LuckPerms-Bukkit-5.4.150.jar")
}
jvmArgs("-Dnet.kyori.adventure.text.warnWhenLegacyFormattingDetected=false")
}

runPaper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ open class BukkitUser(
} else {
SayanVanishAPI.getInstance().database.hasBasicUser(uniqueId, true)
}
override var vanishLevel: Int = 1
override var vanishLevel: Int = 0
get() = if (Features.getFeature<FeatureLevel>().levelMethod == FeatureLevel.LevelMethod.PERMISSION) {
player()?.let { player ->
player.effectivePermissions
.filter { it.permission.startsWith("sayanvanish.level.") }
.maxOfOrNull { it.permission.substringAfter("sayanvanish.level.").toIntOrNull() ?: 1 } ?: 1
} ?: 1
.maxOfOrNull { it.permission.substringAfter("sayanvanish.level.").toIntOrNull() ?: field }
?: if (hasPermission(Permission.VANISH)) 1 else {
if (isVanished) 1 else field
}
} ?: field
} else {
field
}
Expand Down
11 changes: 10 additions & 1 deletion sayanvanish-proxy/sayanvanish-proxy-velocity/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,21 @@ dependencies {
api(project(":sayanvanish-proxy"))
}

tasks.withType(xyz.jpenilla.runtask.task.AbstractRun::class) {
javaLauncher = javaToolchains.launcherFor {
vendor = JvmVendorSpec.JETBRAINS
languageVersion = JavaLanguageVersion.of(21)
}
jvmArgs("-XX:+AllowEnhancedClassRedefinition", "-Dnet.kyori.adventure.text.warnWhenLegacyFormattingDetected=false")
}


tasks {
runVelocity {
velocityVersion("3.4.0-SNAPSHOT")

downloadPlugins {
url("https://github.com/NEZNAMY/TAB/releases/download/5.0.2/TAB.v5.0.2.jar")
url("https://github.com/NEZNAMY/TAB/releases/download/5.0.3/TAB.v5.0.3.jar")
url("https://download.luckperms.net/1560/velocity/LuckPerms-Velocity-5.4.145.jar")
// url("https://cdn.modrinth.com/data/Q10irTG0/versions/eXh7ktan/Velocitab-1.7.2-67931d8.jar")
// url("https://github.com/Syrent/EnhancedVelocity/releases/download/1.3.3/EnhancedVelocity.v1.3.3.jar")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.sayandev.sayanvanish.velocity.api

import com.velocitypowered.api.proxy.Player
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver
import org.sayandev.sayanvanish.api.Permission
import org.sayandev.sayanvanish.api.SayanVanishAPI
import org.sayandev.sayanvanish.api.User
import org.sayandev.sayanvanish.api.VanishOptions
Expand Down Expand Up @@ -29,14 +30,16 @@ open class VelocityUser(
override var currentOptions = VanishOptions.defaultOptions()
override var isVanished = false
override var isOnline: Boolean = SayanVanishAPI.getInstance().database.hasBasicUser(uniqueId, true)
override var vanishLevel: Int = 1
override var vanishLevel: Int = 0
get() = player()?.let { player ->
val luckPermsHook = Features.getFeature<FeatureLuckPermsHook>()
if (luckPermsHook.isActive()) {
luckPermsHook.getPermissions(uniqueId)
.filter { it.startsWith("sayanvanish.level.") }
.maxOfOrNull { it.substringAfter("sayanvanish.level.").toIntOrNull() ?: field }
?: field
?: if (hasPermission(Permission.VANISH)) 1 else {
if (isVanished) 1 else field
}
} else {
field
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,15 @@ import org.spongepowered.configurate.objectmapping.ConfigSerializable
class FeatureHookTAB: HookFeature("hook_tab", "tab") {

override fun enable() {
warn("checking for tab hook")
if (hasPlugin()) {
warn("found tab. registering integration...")
VanishIntegrationTAB().register()
warn("registered")
}
super.enable()
}

override fun disable() {
warn("checking for tab hook")
if (hasPlugin()) {
warn("found tab. unregistering integration...")
VanishIntegrationTAB().unregister()
warn("unregistered")
}
super.disable()
}
Expand Down

0 comments on commit aae43a2

Please sign in to comment.