Skip to content

Commit

Permalink
feat(paper): SuperVanish show and hide events integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Apehum committed Dec 30, 2023
1 parent 15b0c63 commit bd9d6d5
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ ustats = "1.0.2"
universalcraft = "320"
bstats = "3.0.2"

supervanish = "6.2.18-3"

[libraries]
lombok = { module = "org.projectlombok:lombok", version = "1.18.24" }
annotations = { module = "org.jetbrains:annotations", version = "23.0.0" }
Expand All @@ -30,6 +32,8 @@ kotlinx-coroutines-jdk8 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-j

crowdin-lib = { module = "su.plo.crowdin:lib", version.ref = "crowdin" }

supervanish = { module = "com.github.LeonMangler:SuperVanish", version.ref = "supervanish" }

[plugins]
architectury-plugin = { id = "architectury-plugin", version = "3.4-SNAPSHOT" }
architectury-loom = { id = "dev.architectury.loom", version = "0.12.0-SNAPSHOT" }
Expand Down
2 changes: 2 additions & 0 deletions server/paper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ dependencies {

compileOnly(project(":server:common"))

compileOnly(libs.supervanish)

// shadow projects
listOf(
project(":api:common"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import su.plo.ustats.UStats
import su.plo.ustats.paper.PaperUStatsPlatform
import su.plo.voice.paper.connection.PaperServerChannelHandler
import su.plo.voice.paper.connection.PaperServerServiceChannelHandler
import su.plo.voice.paper.integration.SuperVanishIntegration
import su.plo.voice.paper.integration.VoicePlaceholder
import su.plo.voice.server.BaseVoiceServer
import su.plo.voice.server.player.PermissionSupplier
Expand Down Expand Up @@ -67,6 +68,13 @@ class PaperVoiceServer(
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
VoicePlaceholder(this).register()
}

if (Bukkit.getPluginManager().getPlugin("SuperVanish") != null ||
Bukkit.getPluginManager().getPlugin("PremiumVanish") != null
) {
plugin.server.pluginManager.registerEvents(SuperVanishIntegration(this), plugin)
LOGGER.info("SuperVanish event listener attached")
}
}

public override fun onShutdown() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package su.plo.voice.paper.integration

import de.myzelyam.api.vanish.PlayerHideEvent
import de.myzelyam.api.vanish.PostPlayerShowEvent
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import su.plo.voice.api.server.PlasmoVoiceServer

class SuperVanishIntegration(
private val voiceServer: PlasmoVoiceServer
) : Listener {

@EventHandler
fun onPlayerHide(event: PlayerHideEvent) {
val player = voiceServer.playerManager.wrap(event.player)
if (!player.hasVoiceChat()) return

voiceServer.tcpConnectionManager.broadcastPlayerDisconnect(player)
}

@EventHandler
fun onPlayerShow(event: PostPlayerShowEvent) {
val player = voiceServer.playerManager.wrap(event.player)
if (!player.hasVoiceChat()) return

voiceServer.tcpConnectionManager.broadcastPlayerInfoUpdate(player)
}
}
2 changes: 2 additions & 0 deletions server/paper/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ authors: [ Apehum ]
softdepend:
- LuckPerms
- PlaceholderAPI
- SuperVanish
- PremiumVanish
#depend:
# - kotlin-stdlib

Expand Down

0 comments on commit bd9d6d5

Please sign in to comment.