Klasse FreezeAPI

java.lang.Object
me.kzlyth.api.freeze.FreezeAPI

public class FreezeAPI extends Object
API for freezing players in Zenith-Mod.

This API provides methods to freeze and unfreeze players. All freeze actions are automatically recorded in the history database with a case ID.

Features:

  • Freeze and unfreeze players
  • Check if a player is frozen
  • Get list of all frozen players
  • Automatic staff notifications

Database Compatibility: All methods in this API are fully compatible with H2, SQLite, MySQL, and MariaDB databases. The API automatically adapts to the configured database type from the configuration file.

Important Notes:

  • Players must be online to be frozen
  • Players with the zenith.freeze.bypass permission cannot be frozen
  • All freezes are recorded in the history database (zn_history)
  • Each freeze receives a unique case ID
  • Staff notifications are automatically sent to players with zenith.freeze.notifications permission

Example usage:


 ZenithAPI api = ZenithAPI.getInstance();
 if (api != null) {
     FreezeAPI freezeAPI = api.getFreezeAPI();
     
     UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
     UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001");
     
     // Freeze a player
     freezeAPI.freeze(playerUuid, staffUuid, "Investigation").thenAccept(success -> {
         if (success) {
             getLogger().info("Player frozen successfully");
         }
     });
     
     // Unfreeze a player
     freezeAPI.unfreeze(playerUuid, staffUuid, "Investigation complete").thenAccept(success -> {
         if (success) {
             getLogger().info("Player unfrozen successfully");
         }
     });
     
     // Check if player is frozen
     freezeAPI.isFrozen(playerUuid).thenAccept(frozen -> {
         if (frozen) {
             getLogger().info("Player is frozen");
         }
     });
 }
 
Seit:
1.2.3
Autor:
Zenith-Studios
  • Konstruktordetails

    • FreezeAPI

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

    • freeze

      @NotNull public @NotNull CompletableFuture<Boolean> freeze(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid, @NotNull @NotNull String reason)
      Freezes a player with a specified reason.

      This method freezes an online player with a custom reason. The freeze is recorded in the history database with a case ID. Staff notifications are automatically sent.

      Example:

      
       UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001");
       
       freezeAPI.freeze(playerUuid, staffUuid, "Investigation").thenAccept(success -> {
           if (success) {
               getLogger().info("Player frozen successfully");
           } else {
               getLogger().warning("Failed to freeze player");
           }
       });
       
      Parameter:
      playerUuid - The UUID of the player to freeze
      staffUuid - The UUID of the staff member performing the freeze (can be null for console)
      reason - The reason for freezing
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • freeze

      @NotNull public @NotNull CompletableFuture<Boolean> freeze(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName, @NotNull @NotNull String reason)
      Freezes a player with a specified reason.

      This is an overloaded method that accepts player and staff names instead of UUIDs.

      Example:

      
       freezeAPI.freeze("PlayerName", "AdminName", "Investigation").thenAccept(success -> {
           if (success) {
               getLogger().info("Player frozen successfully");
           }
       });
       
      Parameter:
      playerName - The name of the player to freeze
      staffName - The name of the staff member performing the freeze (can be null for console)
      reason - The reason for freezing
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • unfreeze

      @NotNull public @NotNull CompletableFuture<Boolean> unfreeze(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid, @NotNull @NotNull String reason)
      Unfreezes a player with a specified reason.

      This method unfreezes a previously frozen player with a custom reason. The unfreeze is recorded in the history database. Staff notifications are automatically sent.

      Example:

      
       UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001");
       
       freezeAPI.unfreeze(playerUuid, staffUuid, "Investigation complete").thenAccept(success -> {
           if (success) {
               getLogger().info("Player unfrozen successfully");
           }
       });
       
      Parameter:
      playerUuid - The UUID of the player to unfreeze
      staffUuid - The UUID of the staff member performing the unfreeze (can be null for console)
      reason - The reason for unfreezing
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • unfreeze

      @NotNull public @NotNull CompletableFuture<Boolean> unfreeze(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName, @NotNull @NotNull String reason)
      Unfreezes a player with a specified reason.

      This is an overloaded method that accepts player and staff names instead of UUIDs.

      Example:

      
       freezeAPI.unfreeze("PlayerName", "AdminName", "Investigation complete").thenAccept(success -> {
           if (success) {
               getLogger().info("Player unfrozen successfully");
           }
       });
       
      Parameter:
      playerName - The name of the player to unfreeze
      staffName - The name of the staff member performing the unfreeze (can be null for console)
      reason - The reason for unfreezing
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • isFrozen

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

      Example:

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

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

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

      Example:

      
       freezeAPI.isFrozen("PlayerName").thenAccept(frozen -> {
           if (frozen) {
               getLogger().info("Player is frozen");
           }
       });
       
      Parameter:
      playerName - The name of the player to check
      Gibt zurück:
      A CompletableFuture that completes with true if frozen, false otherwise
    • getFrozenPlayers

      @NotNull public @NotNull CompletableFuture<List<UUID>> getFrozenPlayers()
      Gets a list of UUIDs of all currently frozen players.

      Example:

      
       freezeAPI.getFrozenPlayers().thenAccept(frozenPlayers -> {
           getLogger().info("Currently frozen players: " + frozenPlayers.size());
           for (UUID playerUuid : frozenPlayers) {
               String playerName = api.getUserInfoAPI().getPlayerName(playerUuid).join();
               getLogger().info("  - " + playerName);
           }
       });
       
      Gibt zurück:
      A CompletableFuture that completes with a list of UUIDs of frozen players