From 3c70eb795221a0718c72f0f81e5fd1cc1a102e2c Mon Sep 17 00:00:00 2001 From: Syrent Date: Fri, 9 Dec 2022 15:47:10 +0330 Subject: [PATCH] Spigot | Add permission based vanish level system (velocityvanish.level.) --- .../ir/syrent/velocityvanish/spigot/core/VanishManager.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/ir/syrent/velocityvanish/spigot/core/VanishManager.kt b/src/main/java/ir/syrent/velocityvanish/spigot/core/VanishManager.kt index 731aad4c..0cf5e9dc 100644 --- a/src/main/java/ir/syrent/velocityvanish/spigot/core/VanishManager.kt +++ b/src/main/java/ir/syrent/velocityvanish/spigot/core/VanishManager.kt @@ -79,7 +79,13 @@ class VanishManager( } fun hidePlayer(player: Player) { + val vanishLevel = player.effectivePermissions.map { it.permission } + .filter { it.startsWith("velocityvanish.level.") }.maxOfOrNull { it.split(".")[2].toInt() } ?: 0 for (onlinePlayer in Ruom.getOnlinePlayers().filter { !it.hasPermission("velocityvanish.admin.seevanished") }) { + val onlinePlayerVanishLevel = onlinePlayer.effectivePermissions.map { it.permission } + .filter { it.startsWith("velocityvanish.level.") }.maxOfOrNull { it.split(".")[2].toInt() } ?: 0 + if (onlinePlayerVanishLevel > vanishLevel) continue + @Suppress("DEPRECATION") onlinePlayer.hidePlayer(player) }