API

API

THIS PAGE IS OUTDATED, PLEASE SEE SPIGOTMC FOR AN UP-TO-DATE API

 

First of all you have to add SuperVanish as a (soft-)dependency to your plugin.yml file:

# If your plugin works without SuperVanish
softdepend: [SuperVanish]
# If your plugin doesn't work without SuperVanish
depend: [SuperVanish]

The next step is to add the SuperVanish.jar file to your java buildpath if you are using sth like Eclipse.
(If you don't know how to do that just google it!)

Finally you can use the static methodes of my SVAPI class:

    import me.MyzelYam.SuperVanish.api.SVAPI;

    public void testTheApi(Player player) {
        // A Stringlist of the uuids of all players that are currently
        // invisible
        List<String> invisiblePlayers = SVAPI.getInvisiblePlayers();
        // Hide a player
        SVAPI.hidePlayer(player);
        // Show a player
        SVAPI.showPlayer(player);
        // Returns true if a player is invisible
        boolean b = SVAPI.isInvisible(player);
        // Reloads the configuration
        SVAPI.reloadConfig();
        // Returns a FileConfiguration of the config.yml file
        FileConfiguration config = SVAPI.getConfiguration();
        // Returns a FileConfiguration of the messages.yml file
        FileConfiguration messages = SVAPI.getMessages();
        // Returns a FileConfiguration of the playerdata.yml file
        FileConfiguration playerdata = SVAPI.getPlayerData();
    }

If you want to prevent vanishing/reappearing use SuperVanish's events. There are two events, PlayerHideEvent and PlayerShowEvent. PlayerHideEvent triggers when a player gets invisible. PlayerShowEvent triggers when a player reappears. Example:

@EventHandler
public void onVanish(PlayerHideEvent e){
  Player p = e.getPlayer();
  if(p.getName().equalsIgnoreCase("Notch")){
    e.setCancelled(true);
  }
}

Don't forget to register your event! The source of the SVAPI class is included in the jar file.
(Please pm me if you need the source of an other class)