Klasse IPAPI

java.lang.Object
me.kzlyth.api.ip.IPAPI

public class IPAPI extends Object
API class for IP address related functionality.

This API provides methods to check IP ban status, mute status, and retrieve active cases associated with IP addresses.

Example usage:


 ZenithAPI api = ZenithAPI.getInstance();
 if (api != null) {
     IPAPI ipAPI = api.getIPAPI();
     ipAPI.isIpBanned("192.168.1.1").thenAccept(banned -> {
         if (banned) {
             getLogger().info("IP is banned");
         }
     });
 }
 
Seit:
1.2.3
Autor:
Zenith-Studios
  • Konstruktordetails

    • IPAPI

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

    • isIpBanned

      @NotNull public @NotNull CompletableFuture<Boolean> isIpBanned(@NotNull @NotNull String ipAddress)
      Checks if an IP address is banned.

      This method checks if any account with the specified IP address has IP ban status set to true. The check is performed by querying accounts where the IP matches either the latest_ip or is contained in the ip_array.

      Example:

      
       IPAPI ipAPI = api.getIPAPI();
       ipAPI.isIpBanned("192.168.1.1").thenAccept(banned -> {
           if (banned) {
               getLogger().info("IP is banned");
           } else {
               getLogger().info("IP is not banned");
           }
       });
       
      Parameter:
      ipAddress - The IP address to check
      Gibt zurück:
      A CompletableFuture that completes with true if the IP is banned, false otherwise
      Löst aus:
      APIUnavailableException - if the API is not available
    • isIpMuted

      @NotNull public @NotNull CompletableFuture<Boolean> isIpMuted(@NotNull @NotNull String ipAddress)
      Checks if an IP address is muted.

      This method checks if any account with the specified IP address has IP mute status set to true. The check is performed by querying accounts where the IP matches either the latest_ip or is contained in the ip_array.

      Example:

      
       IPAPI ipAPI = api.getIPAPI();
       ipAPI.isIpMuted("192.168.1.1").thenAccept(muted -> {
           if (muted) {
               getLogger().info("IP is muted");
           } else {
               getLogger().info("IP is not muted");
           }
       });
       
      Parameter:
      ipAddress - The IP address to check
      Gibt zurück:
      A CompletableFuture that completes with true if the IP is muted, false otherwise
      Löst aus:
      APIUnavailableException - if the API is not available
    • getActiveCasesForIp

      @NotNull public @NotNull CompletableFuture<List<Integer>> getActiveCasesForIp(@NotNull @NotNull String ipAddress)
      Gets all active case IDs for an IP address.

      This method finds all accounts that have used the specified IP address (either as latest_ip or in their ip_array) and returns a list of all active_case IDs associated with those accounts.

      The list is sorted by last_seen timestamp in descending order (most recently seen accounts first). Only unique active_case IDs are returned (duplicates are removed).

      If multiple accounts share the same IP and have active cases, all unique active case IDs will be returned. If no accounts are found with this IP, or if none of the found accounts have an active_case set, an empty list will be returned.

      Example:

      
       IPAPI ipAPI = api.getIPAPI();
       ipAPI.getActiveCasesForIp("192.168.1.1").thenAccept(activeCases -> {
           if (activeCases.isEmpty()) {
               getLogger().info("No active cases found for this IP");
           } else {
               getLogger().info("Found " + activeCases.size() + " active case(s):");
               for (Integer caseId : activeCases) {
                   getLogger().info("  - Case ID: " + caseId);
               }
           }
       });
       
      Parameter:
      ipAddress - The IP address to check
      Gibt zurück:
      A CompletableFuture that completes with a list of active case IDs associated with accounts using this IP, sorted by most recently seen first, or an empty list if none found
      Löst aus:
      APIUnavailableException - if the API is not available
    • getPlayerCountForIp

      @NotNull public @NotNull CompletableFuture<Integer> getPlayerCountForIp(@NotNull @NotNull String ipAddress)
      Gets the count of accounts that have used the specified IP address.

      This method counts all accounts where the IP matches either the latest_ip or is contained in the ip_array. Each unique account is counted only once, even if the IP appears multiple times in their ip_array.

      Example:

      
       IPAPI ipAPI = api.getIPAPI();
       ipAPI.getPlayerCountForIp("192.168.1.1").thenAccept(count -> {
           getLogger().info("Found " + count + " account(s) using this IP");
       });
       
      Parameter:
      ipAddress - The IP address to check
      Gibt zurück:
      A CompletableFuture that completes with the count of unique accounts using this IP, or 0 if none found
      Löst aus:
      APIUnavailableException - if the API is not available
    • getPlayersForIp

      @NotNull public @NotNull CompletableFuture<List<AltInfo>> getPlayersForIp(@NotNull @NotNull String ipAddress)
      Gets all accounts that have used the specified IP address.

      This method finds all accounts where the IP matches either the latest_ip or is contained in the ip_array. Each account is returned as an AltInfo object containing the UUID and player name. The results are sorted by last_seen timestamp in descending order (most recently seen accounts first).

      Example:

      
       IPAPI ipAPI = api.getIPAPI();
       ipAPI.getPlayersForIp("192.168.1.1").thenAccept(players -> {
           if (players.isEmpty()) {
               getLogger().info("No accounts found for this IP");
           } else {
               getLogger().info("Found " + players.size() + " account(s):");
               for (AltInfo player : players) {
                   getLogger().info("  - " + player.getPlayerName() + " (" + player.getUuid() + ")");
               }
           }
       });
       
      Parameter:
      ipAddress - The IP address to check
      Gibt zurück:
      A CompletableFuture that completes with a list of AltInfo objects containing all unique accounts using this IP, sorted by most recently seen first, or an empty list if none found
      Löst aus:
      APIUnavailableException - if the API is not available
    • getFirstSeenForIp

      @NotNull public @NotNull CompletableFuture<Long> getFirstSeenForIp(@NotNull @NotNull String ipAddress)
      Gets the first seen timestamp for an IP address.

      This method finds all accounts that have used the specified IP address (either as latest_ip or in their ip_array) and returns the earliest first_seen timestamp among all those accounts. This represents when this IP was first seen on the server.

      Example:

      
       IPAPI ipAPI = api.getIPAPI();
       ipAPI.getFirstSeenForIp("192.168.1.1").thenAccept(firstSeen -> {
           if (firstSeen != null) {
               getLogger().info("IP first seen: " + new Date(firstSeen));
           } else {
               getLogger().info("No accounts found for this IP");
           }
       });
       
      Parameter:
      ipAddress - The IP address to check
      Gibt zurück:
      A CompletableFuture that completes with the earliest first_seen timestamp for accounts using this IP, or null if no accounts found
      Löst aus:
      APIUnavailableException - if the API is not available
    • getLastSeenForIp

      @NotNull public @NotNull CompletableFuture<Long> getLastSeenForIp(@NotNull @NotNull String ipAddress)
      Gets the last seen timestamp for an IP address.

      This method finds all accounts that have used the specified IP address (either as latest_ip or in their ip_array) and returns the most recent last_seen timestamp among all those accounts. This represents when this IP was last seen on the server.

      Example:

      
       IPAPI ipAPI = api.getIPAPI();
       ipAPI.getLastSeenForIp("192.168.1.1").thenAccept(lastSeen -> {
           if (lastSeen != null) {
               getLogger().info("IP last seen: " + new Date(lastSeen));
           } else {
               getLogger().info("No accounts found for this IP");
           }
       });
       
      Parameter:
      ipAddress - The IP address to check
      Gibt zurück:
      A CompletableFuture that completes with the most recent last_seen timestamp for accounts using this IP, or null if no accounts found
      Löst aus:
      APIUnavailableException - if the API is not available
    • hasBannedAccounts

      @NotNull public @NotNull CompletableFuture<Boolean> hasBannedAccounts(@NotNull @NotNull String ipAddress)
      Checks if any account using the specified IP address is banned.

      This method checks if any account with the specified IP address has a ban status set to true. This includes both regular bans (banned) and IP bans (ip_banned). The check is performed by querying accounts where the IP matches either the latest_ip or is contained in the ip_array.

      This differs from isIpBanned(java.lang.String) as it checks for any type of ban, not just IP bans.

      Example:

      
       IPAPI ipAPI = api.getIPAPI();
       ipAPI.hasBannedAccounts("192.168.1.1").thenAccept(hasBanned -> {
           if (hasBanned) {
               getLogger().info("This IP has banned accounts");
           } else {
               getLogger().info("No banned accounts for this IP");
           }
       });
       
      Parameter:
      ipAddress - The IP address to check
      Gibt zurück:
      A CompletableFuture that completes with true if any account with this IP is banned, false otherwise
      Löst aus:
      APIUnavailableException - if the API is not available
    • hasMutedAccounts

      @NotNull public @NotNull CompletableFuture<Boolean> hasMutedAccounts(@NotNull @NotNull String ipAddress)
      Checks if any account using the specified IP address is muted.

      This method checks if any account with the specified IP address has a mute status set to true. This includes both regular mutes (muted) and IP mutes (ip_muted). The check is performed by querying accounts where the IP matches either the latest_ip or is contained in the ip_array.

      This differs from isIpMuted(java.lang.String) as it checks for any type of mute, not just IP mutes.

      Example:

      
       IPAPI ipAPI = api.getIPAPI();
       ipAPI.hasMutedAccounts("192.168.1.1").thenAccept(hasMuted -> {
           if (hasMuted) {
               getLogger().info("This IP has muted accounts");
           } else {
               getLogger().info("No muted accounts for this IP");
           }
       });
       
      Parameter:
      ipAddress - The IP address to check
      Gibt zurück:
      A CompletableFuture that completes with true if any account with this IP is muted, false otherwise
      Löst aus:
      APIUnavailableException - if the API is not available