Skip to content

Commit

Permalink
chore(proxy/velocity): re-add vanish update event checks for `hook_ve…
Browse files Browse the repository at this point in the history
…locitab` feature and prevent redundant calls
  • Loading branch information
Syrent committed Oct 14, 2024
1 parent fc59f05 commit 44b56b6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -45,34 +46,33 @@ 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
private fun onServerPostConnect(event: ServerPostConnectEvent) {
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)
}
}

Expand All @@ -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)
}
}

0 comments on commit 44b56b6

Please sign in to comment.