Klasse PunishmentStatusAPI

java.lang.Object
me.kzlyth.api.status.PunishmentStatusAPI

public class PunishmentStatusAPI extends Object
API for checking punishment status of players in Zenith-Mod.

This API provides methods to check if players are banned, muted, IP-banned, or IP-muted, as well as retrieve active punishment information and case IDs.

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.

Example usage:


 ZenithAPI api = ZenithAPI.getInstance();
 if (api != null) {
     PunishmentStatusAPI statusAPI = api.getPunishmentStatusAPI();
     
     UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
     
     // Check if player is banned
     statusAPI.isBanned(uuid).thenAccept(banned -> {
         if (banned) {
             getLogger().info("Player is banned");
         }
     });
     
     // Get complete punishment status
     statusAPI.getPunishmentStatus(uuid).thenAccept(status -> {
         if (status != null) {
             if (status.isBanned() || status.isIpBanned()) {
                 getLogger().info("Player is banned (regular or IP)");
             }
             if (status.isMuted() || status.isIpMuted()) {
                 getLogger().info("Player is muted (regular or IP)");
             }
             Integer activeCase = status.getActiveCase();
             if (activeCase != null) {
                 getLogger().info("Active case ID: " + activeCase);
             }
         }
     });
     
     // Check for active punishment
     statusAPI.hasActivePunishment(uuid).thenAccept(hasPunishment -> {
         if (hasPunishment) {
             getLogger().info("Player has an active punishment");
         }
     });
 }
 
Seit:
1.2.3
Autor:
Zenith-Studios
  • Konstruktordetails

    • PunishmentStatusAPI

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

    • isBanned

      @NotNull public @NotNull CompletableFuture<Boolean> isBanned(@NotNull @NotNull UUID uuid)
      Checks if a player is currently banned (non-IP ban).

      Example:

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

      @NotNull public @NotNull CompletableFuture<Boolean> isBanned(@NotNull @NotNull String playerName)
      Checks if a player is currently banned (non-IP ban).

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

      Example:

      
       statusAPI.isBanned("PlayerName").thenAccept(banned -> {
           if (banned) {
               getLogger().info("Player is banned");
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with true if banned, false otherwise
    • isMuted

      @NotNull public @NotNull CompletableFuture<Boolean> isMuted(@NotNull @NotNull UUID uuid)
      Checks if a player is currently muted (non-IP mute).

      Example:

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

      @NotNull public @NotNull CompletableFuture<Boolean> isMuted(@NotNull @NotNull String playerName)
      Checks if a player is currently muted (non-IP mute).

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

      Example:

      
       statusAPI.isMuted("PlayerName").thenAccept(muted -> {
           if (muted) {
               getLogger().info("Player is muted");
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with true if muted, false otherwise
    • isIpBanned

      @NotNull public @NotNull CompletableFuture<Boolean> isIpBanned(@NotNull @NotNull UUID uuid)
      Checks if a player is currently IP-banned.

      This method is a wrapper around IPAPI.isIpBanned(String) and uses the player's latest IP.

      Example:

      
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       statusAPI.isIpBanned(uuid).thenAccept(ipBanned -> {
           if (ipBanned) {
               getLogger().info("Player is IP-banned");
           } else {
               getLogger().info("Player is not IP-banned");
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with true if IP-banned, false otherwise
    • isIpBanned

      @NotNull public @NotNull CompletableFuture<Boolean> isIpBanned(@NotNull @NotNull String playerName)
      Checks if a player is currently IP-banned.

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

      Example:

      
       statusAPI.isIpBanned("PlayerName").thenAccept(ipBanned -> {
           if (ipBanned) {
               getLogger().info("Player is IP-banned");
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with true if IP-banned, false otherwise
    • isIpMuted

      @NotNull public @NotNull CompletableFuture<Boolean> isIpMuted(@NotNull @NotNull UUID uuid)
      Checks if a player is currently IP-muted.

      This method is a wrapper around IPAPI.isIpMuted(String) and uses the player's latest IP.

      Example:

      
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       statusAPI.isIpMuted(uuid).thenAccept(ipMuted -> {
           if (ipMuted) {
               getLogger().info("Player is IP-muted");
           } else {
               getLogger().info("Player is not IP-muted");
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with true if IP-muted, false otherwise
    • isIpMuted

      @NotNull public @NotNull CompletableFuture<Boolean> isIpMuted(@NotNull @NotNull String playerName)
      Checks if a player is currently IP-muted.

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

      Example:

      
       statusAPI.isIpMuted("PlayerName").thenAccept(ipMuted -> {
           if (ipMuted) {
               getLogger().info("Player is IP-muted");
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with true if IP-muted, false otherwise
    • getPunishmentStatus

      @NotNull public @NotNull CompletableFuture<PunishmentStatus> getPunishmentStatus(@NotNull @NotNull UUID uuid)
      Gets the complete punishment status for a player.

      Returns a PunishmentStatus object containing all punishment-related information including ban status, mute status (both regular and IP-based), and active case IDs.

      Example:

      
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       statusAPI.getPunishmentStatus(uuid).thenAccept(status -> {
           if (status != null) {
               if (status.isBanned() || status.isIpBanned()) {
                   getLogger().info("Player is banned (regular or IP)");
               }
               if (status.isMuted() || status.isIpMuted()) {
                   getLogger().info("Player is muted (regular or IP)");
               }
               Integer activeCase = status.getActiveCase();
               if (activeCase != null) {
                   getLogger().info("Active case ID: " + activeCase);
               }
               Integer banCase = status.getActiveBanCase();
               if (banCase != null) {
                   getLogger().info("Active ban case ID: " + banCase);
               }
               Integer muteCase = status.getActiveMuteCase();
               if (muteCase != null) {
                   getLogger().info("Active mute case ID: " + muteCase);
               }
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with the punishment status, or null if player not found
    • getPunishmentStatus

      @NotNull public @NotNull CompletableFuture<PunishmentStatus> getPunishmentStatus(@NotNull @NotNull String playerName)
      Gets the complete punishment status for a player.

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

      Example:

      
       statusAPI.getPunishmentStatus("PlayerName").thenAccept(status -> {
           if (status != null) {
               if (status.hasActivePunishment()) {
                   getLogger().info("Player has an active punishment");
               }
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with the punishment status, or null if player not found
    • getActivePunishment

      @NotNull public @NotNull CompletableFuture<HistoryEntry> getActivePunishment(@NotNull @NotNull UUID uuid, @NotNull @NotNull String punishmentType)
      Gets the active punishment entry for a player by punishment type.

      Returns the most recent active punishment entry of the specified type (e.g., "BAN", "MUTE", "WARN", "KICK").

      Example:

      
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       statusAPI.getActivePunishment(uuid, "BAN").thenAccept(entry -> {
           if (entry != null) {
               getLogger().info("Active ban found:");
               getLogger().info("Case ID: " + entry.getCaseId());
               getLogger().info("Reason: " + entry.getReason());
               getLogger().info("Staff: " + entry.getStaffName());
               getLogger().info("Date: " + new Date(entry.getTimestamp()));
           } else {
               getLogger().info("No active ban found");
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      punishmentType - The punishment type (e.g., "BAN", "MUTE", "WARN", "KICK")
      Gibt zurück:
      A CompletableFuture that completes with the active punishment entry, or null if none found
    • getActivePunishment

      @NotNull public @NotNull CompletableFuture<HistoryEntry> getActivePunishment(@NotNull @NotNull String playerName, @NotNull @NotNull String punishmentType)
      Gets the active punishment entry for a player by punishment type.

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

      Example:

      
       statusAPI.getActivePunishment("PlayerName", "MUTE").thenAccept(entry -> {
           if (entry != null) {
               getLogger().info("Active mute found: " + entry.getReason());
           }
       });
       
      Parameter:
      playerName - The name of the player
      punishmentType - The punishment type (e.g., "BAN", "MUTE", "WARN", "KICK")
      Gibt zurück:
      A CompletableFuture that completes with the active punishment entry, or null if none found
    • hasActivePunishment

      @NotNull public @NotNull CompletableFuture<Boolean> hasActivePunishment(@NotNull @NotNull UUID uuid)
      Checks if a player has any active punishment.

      Returns true if the player has any active ban, mute, warn, kick, or other active punishment.

      Example:

      
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       statusAPI.hasActivePunishment(uuid).thenAccept(hasPunishment -> {
           if (hasPunishment) {
               getLogger().info("Player has an active punishment");
           } else {
               getLogger().info("Player has no active punishments");
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with true if player has an active punishment, false otherwise
    • hasActivePunishment

      @NotNull public @NotNull CompletableFuture<Boolean> hasActivePunishment(@NotNull @NotNull String playerName)
      Checks if a player has any active punishment.

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

      Example:

      
       statusAPI.hasActivePunishment("PlayerName").thenAccept(hasPunishment -> {
           if (hasPunishment) {
               getLogger().info("Player has an active punishment");
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with true if player has an active punishment, false otherwise