diff --git a/sayanvanish-proxy/sayanvanish-proxy-velocity/build.gradle.kts b/sayanvanish-proxy/sayanvanish-proxy-velocity/build.gradle.kts index 43b4d47..3478118 100644 --- a/sayanvanish-proxy/sayanvanish-proxy-velocity/build.gradle.kts +++ b/sayanvanish-proxy/sayanvanish-proxy-velocity/build.gradle.kts @@ -23,7 +23,7 @@ tasks { downloadPlugins { url("https://download.luckperms.net/1556/velocity/LuckPerms-Velocity-5.4.141.jar") - url("https://cdn.modrinth.com/data/Q10irTG0/versions/WOxOraBS/Velocitab-1.7.1-5470d19.jar") + url("https://cdn.modrinth.com/data/Q10irTG0/versions/JPcYpUcS/Velocitab-1.7.1-cf7c92e.jar") url("https://github.com/Syrent/EnhancedVelocity/releases/download/1.3.3/EnhancedVelocity.v1.3.3.jar") url("https://cdn.modrinth.com/data/HQyibRsN/versions/FfO1vuOg/MiniPlaceholders-Velocity-2.2.4.jar") // url("https://hangarcdn.papermc.io/plugins/Andre_601/AdvancedServerList/versions/4.11.1/VELOCITY/AdvancedServerList-Velocity-4.11.1.jar") diff --git a/sayanvanish-proxy/sayanvanish-proxy-velocity/src/main/kotlin/org/sayandev/sayanvanish/velocity/feature/features/hook/FeatureHookVelocitab.kt b/sayanvanish-proxy/sayanvanish-proxy-velocity/src/main/kotlin/org/sayandev/sayanvanish/velocity/feature/features/hook/FeatureHookVelocitab.kt index 2d5c7b2..a83cd6f 100644 --- a/sayanvanish-proxy/sayanvanish-proxy-velocity/src/main/kotlin/org/sayandev/sayanvanish/velocity/feature/features/hook/FeatureHookVelocitab.kt +++ b/sayanvanish-proxy/sayanvanish-proxy-velocity/src/main/kotlin/org/sayandev/sayanvanish/velocity/feature/features/hook/FeatureHookVelocitab.kt @@ -3,18 +3,19 @@ package org.sayandev.sayanvanish.velocity.feature.features.hook import com.velocitypowered.api.event.Subscribe import com.velocitypowered.api.event.connection.PostLoginEvent import com.velocitypowered.api.event.player.ServerPostConnectEvent +import com.velocitypowered.api.proxy.Player import net.william278.velocitab.api.VelocitabAPI import net.william278.velocitab.vanish.VanishIntegration import org.sayandev.sayanvanish.api.feature.RegisteredFeature import org.sayandev.sayanvanish.velocity.api.SayanVanishVelocityAPI import org.sayandev.sayanvanish.velocity.api.SayanVanishVelocityAPI.Companion.getOrCreateUser -import org.sayandev.sayanvanish.velocity.feature.HookFeature import org.sayandev.sayanvanish.velocity.api.SayanVanishVelocityAPI.Companion.user import org.sayandev.sayanvanish.velocity.event.VelocityUserUnVanishEvent import org.sayandev.sayanvanish.velocity.event.VelocityUserVanishEvent -import org.spongepowered.configurate.objectmapping.ConfigSerializable +import org.sayandev.sayanvanish.velocity.feature.HookFeature import org.sayandev.stickynote.velocity.StickyNote import org.sayandev.stickynote.velocity.registerListener +import org.spongepowered.configurate.objectmapping.ConfigSerializable @RegisteredFeature @ConfigSerializable @@ -45,19 +46,18 @@ private class VelocitabImpl : VanishIntegration { override fun isVanished(name: String): Boolean { return StickyNote.getPlayer(name)?.getOrCreateUser()?.isVanished == true - }/* + } @Subscribe private fun onVanish(event: VelocityUserVanishEvent) { val player = event.user.player() ?: return - VelocitabAPI.getInstance().vanishPlayer(player) - VelocitabAPI.getInstance().tabList.updateDisplayNames() + vanish(player) } @Subscribe private fun onUnVanish(event: VelocityUserUnVanishEvent) { val player = event.user.player() ?: return - VelocitabAPI.getInstance().unVanishPlayer(player) + unVanish(player) } @Subscribe @@ -65,14 +65,14 @@ private class VelocitabImpl : VanishIntegration { val player = event.player ?: return for (vanishedUser in SayanVanishVelocityAPI.getInstance().getVanishedUsers()) { val vanishedPlayer = vanishedUser.player() ?: continue - VelocitabAPI.getInstance().vanishPlayer(vanishedPlayer) + vanish(vanishedPlayer) } val user = player.user() ?: return if (user.isVanished) { - VelocitabAPI.getInstance().vanishPlayer(player) + vanish(player) } else { - VelocitabAPI.getInstance().unVanishPlayer(player) + unVanish(player) } } @@ -81,14 +81,26 @@ private class VelocitabImpl : VanishIntegration { val player = event.player ?: return for (vanishedUser in SayanVanishVelocityAPI.getInstance().getVanishedUsers()) { val vanishedPlayer = vanishedUser.player() ?: continue - VelocitabAPI.getInstance().vanishPlayer(vanishedPlayer) + vanish(vanishedPlayer) } val user = player.user() ?: return if (user.isVanished) { - VelocitabAPI.getInstance().vanishPlayer(player) + vanish(player) } else { - VelocitabAPI.getInstance().unVanishPlayer(player) + unVanish(player) } - }*/ + } + + private fun vanish(player: Player) { + val tabPlayer = VelocitabAPI.getInstance().tabList.getTabPlayer(player.uniqueId) + if (tabPlayer.isEmpty) return + VelocitabAPI.getInstance().vanishPlayer(player) + } + + private fun unVanish(player: Player) { + val tabPlayer = VelocitabAPI.getInstance().tabList.getTabPlayer(player.uniqueId) + if (tabPlayer.isEmpty) return + VelocitabAPI.getInstance().unVanishPlayer(player) + } } \ No newline at end of file