Klasse VanishAPI

java.lang.Object
me.kzlyth.api.vanish.VanishAPI

public class VanishAPI extends Object
API for vanishing and unvanishing players in Zenith-Mod.

This API provides methods to make players invisible (vanished) or visible again. When a player is vanished, they are hidden from other players (except those with the see permission), and staff notifications are automatically sent if configured.

Database Compatibility: This API does not directly interact with the database, but vanished players are persisted to a JSON file for persistence across server restarts.

Important Notes:

  • Players must be online to be vanished/unvanished
  • Vanished players are hidden from other players without the see permission
  • Staff notifications are automatically sent when players vanish/unvanish
  • Vanished state is persisted across server restarts

Example usage:


 ZenithAPI api = ZenithAPI.getInstance();
 if (api != null) {
     VanishAPI vanishAPI = api.getVanishAPI();
     
     UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
     
     // Vanish player
     vanishAPI.vanish(playerUuid).thenAccept(success -> {
         if (success) {
             getLogger().info("Player vanished");
         }
     });
     
     // Check if vanished
     vanishAPI.isVanished(playerUuid).thenAccept(vanished -> {
         if (vanished) {
             getLogger().info("Player is vanished");
         }
     });
     
     // Unvanish player
     vanishAPI.unvanish(playerUuid).thenAccept(success -> {
         if (success) {
             getLogger().info("Player unvanished");
         }
     });
     
     // Get all vanished players
     vanishAPI.getVanishedPlayers().thenAccept(vanishedPlayers -> {
         getLogger().info("Currently vanished players: " + vanishedPlayers.size());
     });
 }
 
Seit:
1.2.3
Autor:
Zenith-Studios
  • Konstruktordetails

    • VanishAPI

      public VanishAPI(@NotNull @NotNull me.kzlyth.ZenithMod plugin, @NotNull @NotNull ZenithAPI api)
      Constructs a new VanishAPI instance.
      Parameter:
      plugin - The plugin instance
      api - The main API instance
  • Methodendetails

    • vanish

      @NotNull public @NotNull CompletableFuture<Boolean> vanish(@NotNull @NotNull UUID playerUuid)
      Makes a player invisible (vanished).

      When a player is vanished, they are hidden from other players (except those with the see permission), and staff notifications are automatically sent if configured.

      Example:

      
       UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       
       vanishAPI.vanish(playerUuid).thenAccept(success -> {
           if (success) {
               getLogger().info("Player vanished");
           }
       });
       
      Parameter:
      playerUuid - The UUID of the player to vanish
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • vanish

      @NotNull public @NotNull CompletableFuture<Boolean> vanish(@NotNull @NotNull String playerName)
      Makes a player invisible (vanished).

      This is an overloaded method that accepts a player name instead of UUID.

      Parameter:
      playerName - The name of the player to vanish
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • unvanish

      @NotNull public @NotNull CompletableFuture<Boolean> unvanish(@NotNull @NotNull UUID playerUuid)
      Makes a player visible again (unvanished).

      When a player is unvanished, they become visible to other players again, and staff notifications are automatically sent if configured.

      Example:

      
       UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       
       vanishAPI.unvanish(playerUuid).thenAccept(success -> {
           if (success) {
               getLogger().info("Player unvanished");
           }
       });
       
      Parameter:
      playerUuid - The UUID of the player to unvanish
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • unvanish

      @NotNull public @NotNull CompletableFuture<Boolean> unvanish(@NotNull @NotNull String playerName)
      Makes a player visible again (unvanished).

      This is an overloaded method that accepts a player name instead of UUID.

      Parameter:
      playerName - The name of the player to unvanish
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • toggleVanish

      @NotNull public @NotNull CompletableFuture<Boolean> toggleVanish(@NotNull @NotNull UUID playerUuid)
      Toggles the vanish state of a player.

      If the player is currently vanished, they will be unvanished. If they are not vanished, they will be vanished.

      Example:

      
       UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       
       vanishAPI.toggleVanish(playerUuid).thenAccept(success -> {
           if (success) {
               getLogger().info("Vanish state toggled");
           }
       });
       
      Parameter:
      playerUuid - The UUID of the player to toggle
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • toggleVanish

      @NotNull public @NotNull CompletableFuture<Boolean> toggleVanish(@NotNull @NotNull String playerName)
      Toggles the vanish state of a player.

      This is an overloaded method that accepts a player name instead of UUID.

      Parameter:
      playerName - The name of the player to toggle
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • isVanished

      @NotNull public @NotNull CompletableFuture<Boolean> isVanished(@NotNull @NotNull UUID playerUuid)
      Checks if a player is currently vanished.

      Example:

      
       UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       
       vanishAPI.isVanished(playerUuid).thenAccept(vanished -> {
           if (vanished) {
               getLogger().info("Player is vanished");
           }
       });
       
      Parameter:
      playerUuid - The UUID of the player to check
      Gibt zurück:
      A CompletableFuture that completes with true if vanished, false otherwise
    • isVanished

      @NotNull public @NotNull CompletableFuture<Boolean> isVanished(@NotNull @NotNull String playerName)
      Checks if a player is currently vanished.

      This is an overloaded method that accepts a player name instead of UUID.

      Parameter:
      playerName - The name of the player to check
      Gibt zurück:
      A CompletableFuture that completes with true if vanished, false otherwise
    • getVanishedPlayers

      @NotNull public @NotNull CompletableFuture<List<UUID>> getVanishedPlayers()
      Gets a list of all currently vanished players.

      This method returns the UUIDs of all players who are currently vanished.

      Example:

      
       vanishAPI.getVanishedPlayers().thenAccept(vanishedPlayers -> {
           getLogger().info("Currently vanished players: " + vanishedPlayers.size());
           for (UUID uuid : vanishedPlayers) {
               String name = api.getUserInfoAPI().getPlayerName(uuid).join();
               getLogger().info("- " + name);
           }
       });
       
      Gibt zurück:
      A CompletableFuture that completes with a list of UUIDs of vanished players