Skip to content

Commit

Permalink
Added support for other plugins checking vanished metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
casperwtf committed Dec 8, 2022
1 parent 88b323d commit 0179590
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package me.quantiom.advancedvanish.util
import com.google.common.collect.Lists
import com.google.common.collect.Maps
import github.scarsz.discordsrv.DiscordSRV
import me.quantiom.advancedvanish.AdvancedVanish
import me.quantiom.advancedvanish.config.Config
import me.quantiom.advancedvanish.event.PlayerUnVanishEvent
import me.quantiom.advancedvanish.event.PlayerVanishEvent
Expand All @@ -14,6 +15,7 @@ import me.quantiom.advancedvanish.state.VanishStateManager
import org.bukkit.Bukkit
import org.bukkit.GameMode
import org.bukkit.entity.Player
import org.bukkit.metadata.FixedMetadataValue
import org.bukkit.potion.PotionEffect
import org.bukkit.potion.PotionEffectType
import java.util.*
Expand All @@ -39,6 +41,10 @@ object AdvancedVanishAPI {

this.vanishedPlayers.add(player.uniqueId)

// add vanished metadata to player for other plugins to use
player.setMetadata("vanished", FixedMetadataValue(AdvancedVanish.instance!!, true))


val previousEffects: MutableList<PotionEffect> = Lists.newArrayList();

// add potion effects
Expand Down Expand Up @@ -119,6 +125,10 @@ object AdvancedVanishAPI {
if (prePlayerUnVanishEvent.isCancelled) return

this.vanishedPlayers.remove(player.uniqueId)

// remove vanished metadata from player
player.removeMetadata("vanished", AdvancedVanish.instance!!)

VanishStateManager.interactEnabled.remove(player.uniqueId)

this.storedPotionEffects[player.uniqueId]?.let {
Expand Down

0 comments on commit 0179590

Please sign in to comment.