From 0179590ab0a338407f0c28f6d1252eb5774c3390 Mon Sep 17 00:00:00 2001 From: casper Date: Wed, 7 Dec 2022 22:58:59 -0600 Subject: [PATCH] Added support for other plugins checking vanished metadata --- .../quantiom/advancedvanish/util/AdvancedVanishAPI.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/kotlin/me/quantiom/advancedvanish/util/AdvancedVanishAPI.kt b/src/main/kotlin/me/quantiom/advancedvanish/util/AdvancedVanishAPI.kt index a2f47c7..1e809b5 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/util/AdvancedVanishAPI.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/util/AdvancedVanishAPI.kt @@ -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 @@ -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.* @@ -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 = Lists.newArrayList(); // add potion effects @@ -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 {