Skip to content

Commit

Permalink
Merge pull request #23 from MCCasper/main
Browse files Browse the repository at this point in the history
Added support for other plugins checking vanished metadata
  • Loading branch information
quantiom authored Jan 12, 2023
2 parents 8fa1311 + 31cde5c commit b96bb55
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,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 @@ -37,8 +38,11 @@ object AdvancedVanishAPI {
if (prePlayerVanishEvent.isCancelled) return

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()
val previousEffects: MutableList<PotionEffect> = Lists.newArrayList();

// add potion effects
Config.getValueOrDefault("when-vanished.give-potion-effects", Lists.newArrayList<String>())
Expand Down Expand Up @@ -120,6 +124,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 b96bb55

Please sign in to comment.