Klasse AltLimitAPI
This API provides methods to retrieve custom alt limits for players and access the default alt limit from the configuration.
Example usage:
ZenithAPI api = ZenithAPI.getInstance();
if (api != null) {
AltLimitAPI altLimitAPI = api.getAltLimitAPI();
UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
altLimitAPI.getAltLimit(uuid).thenAccept(altLimit -> {
int effectiveLimit = altLimit != null ? altLimit : altLimitAPI.getDefaultAltLimit();
getLogger().info("Effective alt limit: " + effectiveLimit);
});
}
- Seit:
- 1.2.3
- Autor:
- Zenith-Studios
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungAltLimitAPI(@NotNull me.kzlyth.ZenithMod plugin, @NotNull ZenithAPI api) Constructs a new AltLimitAPI. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibung@NotNull CompletableFuture<Integer> getAltLimit(@NotNull String playerName) Gets the custom alt limit for a player by name.@NotNull CompletableFuture<Integer> getAltLimit(@NotNull UUID uuid) Gets the custom alt limit for a player by UUID.@NotNull CompletableFuture<Integer> getCurrentAltCount(@NotNull String playerName) Gets the current number of alt accounts for a player by name.@NotNull CompletableFuture<Integer> getCurrentAltCount(@NotNull UUID uuid) Gets the current number of alt accounts for a player by UUID.intGets the default alt limit from the configuration.@NotNull CompletableFuture<Integer> getEffectiveAltLimit(@NotNull String playerName) Gets the effective alt limit for a player by name.@NotNull CompletableFuture<Integer> getEffectiveAltLimit(@NotNull UUID uuid) Gets the effective alt limit for a player by UUID.@NotNull CompletableFuture<Integer> getRemainingAltSlots(@NotNull String playerName) Gets the remaining alt slots available for a player by name.@NotNull CompletableFuture<Integer> getRemainingAltSlots(@NotNull UUID uuid) Gets the remaining alt slots available for a player by UUID.@NotNull CompletableFuture<Boolean> isLimitExceeded(@NotNull String playerName) Checks if a player has exceeded their alt limit by name.@NotNull CompletableFuture<Boolean> isLimitExceeded(@NotNull UUID uuid) Checks if a player has exceeded their alt limit by UUID.@NotNull CompletableFuture<Boolean> isUnlimited(@NotNull String playerName) Checks if a player has unlimited alt accounts by name.@NotNull CompletableFuture<Boolean> isUnlimited(@NotNull UUID uuid) Checks if a player has unlimited alt accounts by UUID.@NotNull CompletableFuture<Boolean> removeAltLimit(@NotNull String playerName) Removes the custom alt limit for a player by name.@NotNull CompletableFuture<Boolean> removeAltLimit(@NotNull UUID uuid) Removes the custom alt limit for a player by UUID.@NotNull CompletableFuture<Boolean> setAltLimit(@NotNull String playerName, int maxAlts) Sets a custom alt limit for a player by name.@NotNull CompletableFuture<Boolean> setAltLimit(@NotNull UUID uuid, @NotNull String playerName, int maxAlts) Sets a custom alt limit for a player by UUID.
-
Konstruktordetails
-
AltLimitAPI
Constructs a new AltLimitAPI.- Parameter:
plugin- The plugin instanceapi- The main API instance
-
-
Methodendetails
-
getAltLimit
Gets the custom alt limit for a player by UUID.This method returns the custom alt limit set for the specific player. If the player does not have a custom alt limit,
nullis returned.To get the default alt limit from the configuration, use
getDefaultAltLimit().Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); altLimitAPI.getAltLimit(uuid).thenAccept(altLimit -> { if (altLimit != null) { getLogger().info("Player has custom alt limit: " + altLimit); } else { int defaultLimit = altLimitAPI.getDefaultAltLimit(); getLogger().info("Using default alt limit: " + defaultLimit); } });- Parameter:
uuid- The UUID of the player- Gibt zurück:
- A CompletableFuture that completes with the custom alt limit, or
nullif the player has no custom limit - Siehe auch:
-
getAltLimit
@NotNull public @NotNull CompletableFuture<Integer> getAltLimit(@NotNull @NotNull String playerName) Gets the custom alt limit for a player by name.This method returns the custom alt limit set for the specific player. If the player does not have a custom alt limit,
nullis returned.To get the default alt limit from the configuration, use
getDefaultAltLimit().Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); altLimitAPI.getAltLimit("Steve").thenAccept(altLimit -> { if (altLimit != null) { getLogger().info("Player has custom alt limit: " + altLimit); } else { int defaultLimit = altLimitAPI.getDefaultAltLimit(); getLogger().info("Using default alt limit: " + defaultLimit); } });- Parameter:
playerName- The name of the player- Gibt zurück:
- A CompletableFuture that completes with the custom alt limit, or
nullif the player has no custom limit - Siehe auch:
-
getDefaultAltLimit
public int getDefaultAltLimit()Gets the default alt limit from the configuration.This method returns the default alt limit configured in the limiter module configuration. This is the limit used for players who do not have a custom alt limit set.
Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); int defaultLimit = altLimitAPI.getDefaultAltLimit(); getLogger().info("Default alt limit: " + defaultLimit); // Check if player has custom limit UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); altLimitAPI.getAltLimit(uuid).thenAccept(customLimit -> { int effectiveLimit = customLimit != null ? customLimit : defaultLimit; getLogger().info("Effective alt limit: " + effectiveLimit); });- Gibt zurück:
- The default alt limit from the configuration
-
setAltLimit
@NotNull public @NotNull CompletableFuture<Boolean> setAltLimit(@NotNull @NotNull UUID uuid, @NotNull @NotNull String playerName, int maxAlts) Sets a custom alt limit for a player by UUID.This method sets a custom alt limit for the specified player. The limit will override the default alt limit from the configuration.
Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); altLimitAPI.setAltLimit(uuid, "Steve", 5).thenAccept(success -> { if (success) { getLogger().info("Alt limit set successfully"); } else { getLogger().warning("Failed to set alt limit"); } });- Parameter:
uuid- The UUID of the playerplayerName- The name of the playermaxAlts- The maximum number of alt accounts allowed (-1 for unlimited, 0 or higher for specific limit)- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise - Löst aus:
APIUnavailableException- if the API is not available
-
setAltLimit
@NotNull public @NotNull CompletableFuture<Boolean> setAltLimit(@NotNull @NotNull String playerName, int maxAlts) Sets a custom alt limit for a player by name.This method sets a custom alt limit for the specified player. The limit will override the default alt limit from the configuration.
Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); altLimitAPI.setAltLimit("Steve", 5).thenAccept(success -> { if (success) { getLogger().info("Alt limit set successfully"); } else { getLogger().warning("Failed to set alt limit"); } });- Parameter:
playerName- The name of the playermaxAlts- The maximum number of alt accounts allowed (-1 for unlimited, 0 or higher for specific limit)- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise - Löst aus:
APIUnavailableException- if the API is not available
-
removeAltLimit
Removes the custom alt limit for a player by UUID.This method removes a custom alt limit, causing the player to use the default alt limit from the configuration.
Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); altLimitAPI.removeAltLimit(uuid).thenAccept(success -> { if (success) { getLogger().info("Alt limit removed successfully"); } else { getLogger().warning("Failed to remove alt limit or player had no custom limit"); } });- Parameter:
uuid- The UUID of the player- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise - Löst aus:
APIUnavailableException- if the API is not available
-
removeAltLimit
@NotNull public @NotNull CompletableFuture<Boolean> removeAltLimit(@NotNull @NotNull String playerName) Removes the custom alt limit for a player by name.This method removes a custom alt limit, causing the player to use the default alt limit from the configuration.
Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); altLimitAPI.removeAltLimit("Steve").thenAccept(success -> { if (success) { getLogger().info("Alt limit removed successfully"); } else { getLogger().warning("Failed to remove alt limit or player had no custom limit"); } });- Parameter:
playerName- The name of the player- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise - Löst aus:
APIUnavailableException- if the API is not available
-
getEffectiveAltLimit
@NotNull public @NotNull CompletableFuture<Integer> getEffectiveAltLimit(@NotNull @NotNull UUID uuid) Gets the effective alt limit for a player by UUID.This method returns the alt limit that is actually used for the player. If the player has a custom alt limit, that is returned. Otherwise, the default alt limit from the configuration is returned.
Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); altLimitAPI.getEffectiveAltLimit(uuid).thenAccept(effectiveLimit -> { getLogger().info("Effective alt limit: " + effectiveLimit); // This could be a custom limit or the default limit });- Parameter:
uuid- The UUID of the player- Gibt zurück:
- A CompletableFuture that completes with the effective alt limit (custom or default)
- Löst aus:
APIUnavailableException- if the API is not available
-
getEffectiveAltLimit
@NotNull public @NotNull CompletableFuture<Integer> getEffectiveAltLimit(@NotNull @NotNull String playerName) Gets the effective alt limit for a player by name.This method returns the alt limit that is actually used for the player. If the player has a custom alt limit, that is returned. Otherwise, the default alt limit from the configuration is returned.
Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); altLimitAPI.getEffectiveAltLimit("Steve").thenAccept(effectiveLimit -> { getLogger().info("Effective alt limit: " + effectiveLimit); });- Parameter:
playerName- The name of the player- Gibt zurück:
- A CompletableFuture that completes with the effective alt limit (custom or default)
- Löst aus:
APIUnavailableException- if the API is not available
-
getCurrentAltCount
Gets the current number of alt accounts for a player by UUID.This method counts all accounts that share the same IP addresses with the specified player. The count represents how many potential alt accounts are associated with this player.
Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); altLimitAPI.getCurrentAltCount(uuid).thenAccept(count -> { getLogger().info("Current alt count: " + count); });- Parameter:
uuid- The UUID of the player- Gibt zurück:
- A CompletableFuture that completes with the current number of alt accounts
- Löst aus:
APIUnavailableException- if the API is not available
-
getCurrentAltCount
@NotNull public @NotNull CompletableFuture<Integer> getCurrentAltCount(@NotNull @NotNull String playerName) Gets the current number of alt accounts for a player by name.This method counts all accounts that share the same IP addresses with the specified player. The count represents how many potential alt accounts are associated with this player.
Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); altLimitAPI.getCurrentAltCount("Steve").thenAccept(count -> { getLogger().info("Current alt count: " + count); });- Parameter:
playerName- The name of the player- Gibt zurück:
- A CompletableFuture that completes with the current number of alt accounts
- Löst aus:
APIUnavailableException- if the API is not available
-
isUnlimited
Checks if a player has unlimited alt accounts by UUID.This method checks if the player's effective alt limit is set to -1 (unlimited). A player has unlimited alts if their custom limit is -1, or if the default limit is -1 and they have no custom limit.
Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); altLimitAPI.isUnlimited(uuid).thenAccept(unlimited -> { if (unlimited) { getLogger().info("Player has unlimited alt accounts"); } else { getLogger().info("Player has a limited number of alt accounts"); } });- Parameter:
uuid- The UUID of the player- Gibt zurück:
- A CompletableFuture that completes with true if the player has unlimited alts, false otherwise
- Löst aus:
APIUnavailableException- if the API is not available
-
isUnlimited
@NotNull public @NotNull CompletableFuture<Boolean> isUnlimited(@NotNull @NotNull String playerName) Checks if a player has unlimited alt accounts by name.This method checks if the player's effective alt limit is set to -1 (unlimited). A player has unlimited alts if their custom limit is -1, or if the default limit is -1 and they have no custom limit.
Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); altLimitAPI.isUnlimited("Steve").thenAccept(unlimited -> { if (unlimited) { getLogger().info("Player has unlimited alt accounts"); } });- Parameter:
playerName- The name of the player- Gibt zurück:
- A CompletableFuture that completes with true if the player has unlimited alts, false otherwise
- Löst aus:
APIUnavailableException- if the API is not available
-
getRemainingAltSlots
@NotNull public @NotNull CompletableFuture<Integer> getRemainingAltSlots(@NotNull @NotNull UUID uuid) Gets the remaining alt slots available for a player by UUID.This method calculates how many alt account slots are still available. The result is computed as: effectiveLimit - currentAltCount.
If the player has unlimited alts (-1), this method returns Integer.MAX_VALUE. If the limit is exceeded, the result will be negative.
Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); altLimitAPI.getRemainingAltSlots(uuid).thenAccept(remaining -> { if (remaining == Integer.MAX_VALUE) { getLogger().info("Player has unlimited alt slots"); } else if (remaining < 0) { getLogger().warning("Limit exceeded by: " + Math.abs(remaining)); } else { getLogger().info("Remaining alt slots: " + remaining); } });- Parameter:
uuid- The UUID of the player- Gibt zurück:
- A CompletableFuture that completes with the number of remaining alt slots, Integer.MAX_VALUE if unlimited, or a negative number if limit is exceeded
- Löst aus:
APIUnavailableException- if the API is not available
-
getRemainingAltSlots
@NotNull public @NotNull CompletableFuture<Integer> getRemainingAltSlots(@NotNull @NotNull String playerName) Gets the remaining alt slots available for a player by name.This method calculates how many alt account slots are still available. The result is computed as: effectiveLimit - currentAltCount.
If the player has unlimited alts (-1), this method returns Integer.MAX_VALUE. If the limit is exceeded, the result will be negative.
Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); altLimitAPI.getRemainingAltSlots("Steve").thenAccept(remaining -> { getLogger().info("Remaining alt slots: " + remaining); });- Parameter:
playerName- The name of the player- Gibt zurück:
- A CompletableFuture that completes with the number of remaining alt slots, Integer.MAX_VALUE if unlimited, or a negative number if limit is exceeded
- Löst aus:
APIUnavailableException- if the API is not available
-
isLimitExceeded
Checks if a player has exceeded their alt limit by UUID.This method compares the current alt count with the effective alt limit. If the current count exceeds the limit (and the limit is not unlimited), true is returned.
Players with unlimited alts (-1) will always return false.
Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); altLimitAPI.isLimitExceeded(uuid).thenAccept(exceeded -> { if (exceeded) { getLogger().warning("Player has exceeded their alt limit!"); } else { getLogger().info("Player is within their alt limit"); } });- Parameter:
uuid- The UUID of the player- Gibt zurück:
- A CompletableFuture that completes with true if the limit is exceeded, false otherwise
- Löst aus:
APIUnavailableException- if the API is not available
-
isLimitExceeded
@NotNull public @NotNull CompletableFuture<Boolean> isLimitExceeded(@NotNull @NotNull String playerName) Checks if a player has exceeded their alt limit by name.This method compares the current alt count with the effective alt limit. If the current count exceeds the limit (and the limit is not unlimited), true is returned.
Players with unlimited alts (-1) will always return false.
Example:
AltLimitAPI altLimitAPI = api.getAltLimitAPI(); altLimitAPI.isLimitExceeded("Steve").thenAccept(exceeded -> { if (exceeded) { getLogger().warning("Player has exceeded their alt limit!"); } });- Parameter:
playerName- The name of the player- Gibt zurück:
- A CompletableFuture that completes with true if the limit is exceeded, false otherwise
- Löst aus:
APIUnavailableException- if the API is not available
-