Resource Vanish Support

Discussion in 'Spigot Plugin Development' started by Oribuin, Jan 15, 2020.

  1. Information
    I thought I would put this here as it may help someone. While working on my FlightTrails plugin (heh) I spent a while trying to figure out how to add Vanish Plugin Support, It took many attempts and seeing what would work and what doesn't, After many attempts, I managed to figure it out and I thought I'd post it here.

    Plugin Info
    There are two main Vanish Plugins almost every server typically uses which is what this thread will be based around, SuperVanish and EssentialsX. These two use different methods which can suck at times.

    When using EssentialsX Vanish, You have to spawn particles per player whether they can see them or not, You can use the Player#canSee(Player) Method to do this.

    When using SuperVanish they use MetaDataValues, Using this means you have to use List<MetadataValue> and to check if someone has the value of "vanished"


    With all this in mind, you are able to apply a ForEach to it, Here is how I have done it inside my plugins and hope it helps.
    Code (Java):

                for(Player pl : player.getServer().getOnlinePlayers()) {
                    if (player.getGameMode() == GameMode.SPECTATOR)

                    for (MetadataValue meta : player.getMetadata("vanished")) {
                        if (meta.asBoolean())

                    if (!pl.canSee(player)) return;
    You don't have to use this method, there is most likely a much better way of doing this but this is the way that I found to be successful.
  2. Both SuperVanish (API) and EssentialsX (API) have API's where you can listen to changes to players vanish states, so why not use that instead? :)
    • Like Like x 1
  3. Generally compiling the apis inside the plugin can be very awkward, especially in gradle, This method could potentially support any other vanish plugin outside of those two which would prevent having to rely on adding apis into your plugin.
  4. You wouldn't have to compile their API inside your plugin. If you add them as a dependency, and just set them to provide, they won't compile, then you can just initialize your stuff if the server utilizes those other plugins.
    • Agree Agree x 1