Klasse UserInfoAPI

java.lang.Object
me.kzlyth.api.userinfo.UserInfoAPI

public class UserInfoAPI extends Object
API class for retrieving user information.

This API provides methods to retrieve user data including UUID, player name, IP addresses, timestamps, and active case information.

Example usage:


 ZenithAPI api = ZenithAPI.getInstance();
 if (api != null) {
     UserInfoAPI userInfoAPI = api.getUserInfoAPI();
     UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
     userInfoAPI.getUser(uuid).thenAccept(user -> {
         if (user != null) {
             getLogger().info("Player: " + user.getPlayerName());
             getLogger().info("Latest IP: " + user.getLatestIp());
         }
     });
 }
 
Seit:
1.2.3
Autor:
Zenith-Studios
  • Konstruktordetails

    • UserInfoAPI

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

    • getUser

      @NotNull public @NotNull CompletableFuture<UserInfo> getUser(@NotNull @NotNull UUID uuid)
      Gets user information by UUID.

      This method retrieves public user information from the database including: UUID, player name, latest IP, IP array, first seen, last seen, and active case.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       userInfoAPI.getUser(uuid).thenAccept(user -> {
           if (user != null) {
               getLogger().info("Player: " + user.getPlayerName());
               getLogger().info("Latest IP: " + user.getLatestIp());
               getLogger().info("IP Array: " + user.getIpArray());
               getLogger().info("Active Case: " + user.getActiveCase());
           } else {
               getLogger().warning("User not found");
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with the UserInfo, or null if not found
      Löst aus:
      APIUnavailableException - if the API is not available
    • getUser

      @NotNull public @NotNull CompletableFuture<UserInfo> getUser(@NotNull @NotNull String playerName)
      Gets user information by player name.

      This method retrieves public user information from the database including: UUID, player name, latest IP, IP array, first seen, last seen, and active case.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       userInfoAPI.getUser("Steve").thenAccept(user -> {
           if (user != null) {
               getLogger().info("Player UUID: " + user.getUuid());
               getLogger().info("Latest IP: " + user.getLatestIp());
               getLogger().info("First Seen: " + new Date(user.getFirstSeen()));
               getLogger().info("Last Seen: " + new Date(user.getLastSeen()));
           } else {
               getLogger().warning("User not found");
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with the UserInfo, or null if not found
      Löst aus:
      APIUnavailableException - if the API is not available
    • getLastSeen

      @NotNull public @NotNull CompletableFuture<Long> getLastSeen(@NotNull @NotNull UUID uuid)
      Gets the last seen timestamp for a player by UUID.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       userInfoAPI.getLastSeen(uuid).thenAccept(lastSeen -> {
           if (lastSeen != null) {
               getLogger().info("Last seen: " + new Date(lastSeen));
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with the last seen timestamp, or null if not found
    • getLastSeen

      @NotNull public @NotNull CompletableFuture<Long> getLastSeen(@NotNull @NotNull String playerName)
      Gets the last seen timestamp for a player by name.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       userInfoAPI.getLastSeen("Steve").thenAccept(lastSeen -> {
           if (lastSeen != null) {
               getLogger().info("Last seen: " + new Date(lastSeen));
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with the last seen timestamp, or null if not found
    • getFirstSeen

      @NotNull public @NotNull CompletableFuture<Long> getFirstSeen(@NotNull @NotNull UUID uuid)
      Gets the first seen timestamp for a player by UUID.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       userInfoAPI.getFirstSeen(uuid).thenAccept(firstSeen -> {
           if (firstSeen != null) {
               getLogger().info("First seen: " + new Date(firstSeen));
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with the first seen timestamp, or null if not found
    • getFirstSeen

      @NotNull public @NotNull CompletableFuture<Long> getFirstSeen(@NotNull @NotNull String playerName)
      Gets the first seen timestamp for a player by name.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       userInfoAPI.getFirstSeen("Steve").thenAccept(firstSeen -> {
           if (firstSeen != null) {
               getLogger().info("First seen: " + new Date(firstSeen));
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with the first seen timestamp, or null if not found
    • getLatestIp

      @NotNull public @NotNull CompletableFuture<String> getLatestIp(@NotNull @NotNull UUID uuid)
      Gets the latest IP address for a player by UUID.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       userInfoAPI.getLatestIp(uuid).thenAccept(ip -> {
           if (ip != null) {
               getLogger().info("Latest IP: " + ip);
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with the latest IP address, or null if not found
    • getLatestIp

      @NotNull public @NotNull CompletableFuture<String> getLatestIp(@NotNull @NotNull String playerName)
      Gets the latest IP address for a player by name.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       userInfoAPI.getLatestIp("Steve").thenAccept(ip -> {
           if (ip != null) {
               getLogger().info("Latest IP: " + ip);
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with the latest IP address, or null if not found
    • getPlayerName

      @NotNull public @NotNull CompletableFuture<String> getPlayerName(@NotNull @NotNull UUID uuid)
      Gets the player name for a player by UUID.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       userInfoAPI.getPlayerName(uuid).thenAccept(name -> {
           if (name != null) {
               getLogger().info("Player name: " + name);
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with the player name, or null if not found
    • getUuid

      @NotNull public @NotNull CompletableFuture<UUID> getUuid(@NotNull @NotNull String playerName)
      Gets the UUID for a player by name.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       userInfoAPI.getUuid("Steve").thenAccept(uuid -> {
           if (uuid != null) {
               getLogger().info("Player UUID: " + uuid);
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with the UUID, or null if not found
    • getIpArray

      @NotNull public @NotNull CompletableFuture<List<String>> getIpArray(@NotNull @NotNull UUID uuid)
      Gets the IP array for a player by UUID.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       userInfoAPI.getIpArray(uuid).thenAccept(ipArray -> {
           if (ipArray != null) {
               getLogger().info("IP addresses: " + ipArray);
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with the IP array, or null if not found
    • getIpArray

      @NotNull public @NotNull CompletableFuture<List<String>> getIpArray(@NotNull @NotNull String playerName)
      Gets the IP array for a player by name.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       userInfoAPI.getIpArray("Steve").thenAccept(ipArray -> {
           if (ipArray != null) {
               getLogger().info("IP addresses: " + ipArray);
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with the IP array, or null if not found
    • getActiveCase

      @NotNull public @NotNull CompletableFuture<Integer> getActiveCase(@NotNull @NotNull UUID uuid)
      Gets the active case ID for a player by UUID.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       userInfoAPI.getActiveCase(uuid).thenAccept(activeCase -> {
           if (activeCase != null) {
               getLogger().info("Active case: " + activeCase);
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with the active case ID, or null if not found
    • getActiveCase

      @NotNull public @NotNull CompletableFuture<Integer> getActiveCase(@NotNull @NotNull String playerName)
      Gets the active case ID for a player by name.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       userInfoAPI.getActiveCase("Steve").thenAccept(activeCase -> {
           if (activeCase != null) {
               getLogger().info("Active case: " + activeCase);
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with the active case ID, or null if not found
    • getAlts

      @NotNull public @NotNull CompletableFuture<List<AltInfo>> getAlts(@NotNull @NotNull UUID uuid)
      Gets potential alt accounts for a player by UUID.

      This method finds all accounts that share the same IP addresses (latest_ip or ip_array) as the specified player. These accounts are considered potential alt accounts.

      If multiple accounts share IPs with the specified player, all of them will be returned in the list. Each account will only appear once in the result, even if it shares multiple IPs.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       userInfoAPI.getAlts(uuid).thenAccept(alts -> {
           if (alts.isEmpty()) {
               getLogger().info("No alt accounts found");
           } else {
               getLogger().info("Found " + alts.size() + " potential alt account(s):");
               for (AltInfo alt : alts) {
                   getLogger().info("  - " + alt.getPlayerName() + " (" + alt.getUuid() + ")");
               }
           }
       });
       
      Parameter:
      uuid - The UUID of the player to check for alt accounts
      Gibt zurück:
      A CompletableFuture that completes with a list of AltInfo objects containing player names and UUIDs of all potential alt accounts (can contain multiple entries), or an empty list if none found
      Löst aus:
      APIUnavailableException - if the API is not available
    • getAlts

      @NotNull public @NotNull CompletableFuture<List<AltInfo>> getAlts(@NotNull @NotNull String playerName)
      Gets potential alt accounts for a player by player name.

      This method finds all accounts that share the same IP addresses (latest_ip or ip_array) as the specified player. These accounts are considered potential alt accounts.

      If multiple accounts share IPs with the specified player, all of them will be returned in the list. Each account will only appear once in the result, even if it shares multiple IPs.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       userInfoAPI.getAlts("Steve").thenAccept(alts -> {
           if (alts.isEmpty()) {
               getLogger().info("No alt accounts found");
           } else {
               getLogger().info("Found " + alts.size() + " potential alt account(s):");
               for (AltInfo alt : alts) {
                   getLogger().info("  - " + alt.getPlayerName() + " (" + alt.getUuid() + ")");
               }
           }
       });
       
      Parameter:
      playerName - The name of the player to check for alt accounts
      Gibt zurück:
      A CompletableFuture that completes with a list of AltInfo objects containing player names and UUIDs of all potential alt accounts (can contain multiple entries), or an empty list if none found
      Löst aus:
      APIUnavailableException - if the API is not available
    • exists

      @NotNull public @NotNull CompletableFuture<Boolean> exists(@NotNull @NotNull UUID uuid)
      Checks if a user exists in the database by UUID.

      This method checks if a player with the specified UUID exists in the database. This is more efficient than getUser(UUID) if you only need to check existence.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       userInfoAPI.exists(uuid).thenAccept(exists -> {
           if (exists) {
               getLogger().info("User exists in database");
           } else {
               getLogger().info("User not found");
           }
       });
       
      Parameter:
      uuid - The UUID of the player to check
      Gibt zurück:
      A CompletableFuture that completes with true if the user exists, false otherwise
      Löst aus:
      APIUnavailableException - if the API is not available
    • exists

      @NotNull public @NotNull CompletableFuture<Boolean> exists(@NotNull @NotNull String playerName)
      Checks if a user exists in the database by player name.

      This method checks if a player with the specified name exists in the database. This is more efficient than getUser(String) if you only need to check existence.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       userInfoAPI.exists("Steve").thenAccept(exists -> {
           if (exists) {
               getLogger().info("User exists in database");
           }
       });
       
      Parameter:
      playerName - The name of the player to check
      Gibt zurück:
      A CompletableFuture that completes with true if the user exists, false otherwise
      Löst aus:
      APIUnavailableException - if the API is not available
    • getAllIps

      @NotNull public @NotNull CompletableFuture<List<String>> getAllIps(@NotNull @NotNull UUID uuid)
      Gets all IP addresses associated with a player by UUID.

      This method combines the latest_ip and ip_array into a single list of unique IP addresses. Duplicate IPs are removed, so each IP appears only once in the result.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       userInfoAPI.getAllIps(uuid).thenAccept(allIps -> {
           if (allIps != null) {
               getLogger().info("All IPs: " + allIps);
               getLogger().info("Total unique IPs: " + allIps.size());
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with a list of all unique IP addresses (latest_ip + ip_array), or null if user not found
      Löst aus:
      APIUnavailableException - if the API is not available
    • getAllIps

      @NotNull public @NotNull CompletableFuture<List<String>> getAllIps(@NotNull @NotNull String playerName)
      Gets all IP addresses associated with a player by name.

      This method combines the latest_ip and ip_array into a single list of unique IP addresses. Duplicate IPs are removed, so each IP appears only once in the result.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       userInfoAPI.getAllIps("Steve").thenAccept(allIps -> {
           if (allIps != null) {
               getLogger().info("All IPs: " + allIps);
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with a list of all unique IP addresses (latest_ip + ip_array), or null if user not found
      Löst aus:
      APIUnavailableException - if the API is not available
    • getIpCount

      @NotNull public @NotNull CompletableFuture<Integer> getIpCount(@NotNull @NotNull UUID uuid)
      Gets the count of unique IP addresses associated with a player by UUID.

      This method counts all unique IP addresses (latest_ip + ip_array) associated with the player.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       userInfoAPI.getIpCount(uuid).thenAccept(count -> {
           if (count != null) {
               getLogger().info("Player has used " + count + " unique IP address(es)");
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with the count of unique IP addresses, or null if user not found
      Löst aus:
      APIUnavailableException - if the API is not available
    • getIpCount

      @NotNull public @NotNull CompletableFuture<Integer> getIpCount(@NotNull @NotNull String playerName)
      Gets the count of unique IP addresses associated with a player by name.

      This method counts all unique IP addresses (latest_ip + ip_array) associated with the player.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       userInfoAPI.getIpCount("Steve").thenAccept(count -> {
           if (count != null) {
               getLogger().info("Player has used " + count + " unique IP address(es)");
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with the count of unique IP addresses, or null if user not found
      Löst aus:
      APIUnavailableException - if the API is not available
    • hasActiveCase

      @NotNull public @NotNull CompletableFuture<Boolean> hasActiveCase(@NotNull @NotNull UUID uuid)
      Checks if a player has an active case by UUID.

      This method checks if the player has an active case ID set (not null). This is more convenient than getActiveCase(UUID) if you only need a boolean check.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       userInfoAPI.hasActiveCase(uuid).thenAccept(hasCase -> {
           if (hasCase) {
               getLogger().info("Player has an active case");
           } else {
               getLogger().info("Player has no active case");
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with true if the player has an active case, false otherwise
      Löst aus:
      APIUnavailableException - if the API is not available
    • hasActiveCase

      @NotNull public @NotNull CompletableFuture<Boolean> hasActiveCase(@NotNull @NotNull String playerName)
      Checks if a player has an active case by name.

      This method checks if the player has an active case ID set (not null). This is more convenient than getActiveCase(String) if you only need a boolean check.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       userInfoAPI.hasActiveCase("Steve").thenAccept(hasCase -> {
           if (hasCase) {
               getLogger().info("Player has an active case");
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with true if the player has an active case, false otherwise
      Löst aus:
      APIUnavailableException - if the API is not available
    • isOnline

      @NotNull public @NotNull CompletableFuture<Boolean> isOnline(@NotNull @NotNull UUID uuid)
      Checks if a player is currently online by UUID.

      This method checks if the player with the specified UUID is currently online on the server. The check is performed synchronously using Bukkit's getPlayer method.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       userInfoAPI.isOnline(uuid).thenAccept(online -> {
           if (online) {
               getLogger().info("Player is currently online");
           } else {
               getLogger().info("Player is offline");
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with true if the player is online, false otherwise
      Löst aus:
      APIUnavailableException - if the API is not available
    • isOnline

      @NotNull public @NotNull CompletableFuture<Boolean> isOnline(@NotNull @NotNull String playerName)
      Checks if a player is currently online by name.

      This method checks if the player with the specified name is currently online on the server. The check is performed synchronously using Bukkit's getPlayer method.

      Example:

      
       UserInfoAPI userInfoAPI = api.getUserInfoAPI();
       userInfoAPI.isOnline("Steve").thenAccept(online -> {
           if (online) {
               getLogger().info("Player is currently online");
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with true if the player is online, false otherwise
      Löst aus:
      APIUnavailableException - if the API is not available