Klasse PunishmentStatusAPI
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
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungPunishmentStatusAPI(@NotNull me.kzlyth.ZenithMod plugin, @NotNull ZenithAPI api) Constructs a new PunishmentStatusAPI instance. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibung@NotNull CompletableFuture<HistoryEntry> getActivePunishment(@NotNull String playerName, @NotNull String punishmentType) Gets the active punishment entry for a player by punishment type.@NotNull CompletableFuture<HistoryEntry> getActivePunishment(@NotNull UUID uuid, @NotNull String punishmentType) Gets the active punishment entry for a player by punishment type.@NotNull CompletableFuture<PunishmentStatus> getPunishmentStatus(@NotNull String playerName) Gets the complete punishment status for a player.@NotNull CompletableFuture<PunishmentStatus> getPunishmentStatus(@NotNull UUID uuid) Gets the complete punishment status for a player.@NotNull CompletableFuture<Boolean> hasActivePunishment(@NotNull String playerName) Checks if a player has any active punishment.@NotNull CompletableFuture<Boolean> hasActivePunishment(@NotNull UUID uuid) Checks if a player has any active punishment.@NotNull CompletableFuture<Boolean> Checks if a player is currently banned (non-IP ban).@NotNull CompletableFuture<Boolean> Checks if a player is currently banned (non-IP ban).@NotNull CompletableFuture<Boolean> isIpBanned(@NotNull String playerName) Checks if a player is currently IP-banned.@NotNull CompletableFuture<Boolean> isIpBanned(@NotNull UUID uuid) Checks if a player is currently IP-banned.@NotNull CompletableFuture<Boolean> Checks if a player is currently IP-muted.@NotNull CompletableFuture<Boolean> Checks if a player is currently IP-muted.@NotNull CompletableFuture<Boolean> Checks if a player is currently muted (non-IP mute).@NotNull CompletableFuture<Boolean> Checks if a player is currently muted (non-IP mute).
-
Konstruktordetails
-
PunishmentStatusAPI
public PunishmentStatusAPI(@NotNull @NotNull me.kzlyth.ZenithMod plugin, @NotNull @NotNull ZenithAPI api) Constructs a new PunishmentStatusAPI instance.- Parameter:
plugin- The plugin instanceapi- The main API instance
-
-
Methodendetails
-
isBanned
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
trueif banned,falseotherwise
-
isBanned
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
trueif banned,falseotherwise
-
isMuted
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
trueif muted,falseotherwise
-
isMuted
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
trueif muted,falseotherwise
-
isIpBanned
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
trueif IP-banned,falseotherwise
-
isIpBanned
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
trueif IP-banned,falseotherwise
-
isIpMuted
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
trueif IP-muted,falseotherwise
-
isIpMuted
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
trueif IP-muted,falseotherwise
-
getPunishmentStatus
@NotNull public @NotNull CompletableFuture<PunishmentStatus> getPunishmentStatus(@NotNull @NotNull UUID uuid) Gets the complete punishment status for a player.Returns a
PunishmentStatusobject 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
nullif 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
nullif 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 playerpunishmentType- The punishment type (e.g., "BAN", "MUTE", "WARN", "KICK")- Gibt zurück:
- A CompletableFuture that completes with the active punishment entry, or
nullif 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 playerpunishmentType- The punishment type (e.g., "BAN", "MUTE", "WARN", "KICK")- Gibt zurück:
- A CompletableFuture that completes with the active punishment entry, or
nullif none found
-
hasActivePunishment
@NotNull public @NotNull CompletableFuture<Boolean> hasActivePunishment(@NotNull @NotNull UUID uuid) Checks if a player has any active punishment.Returns
trueif 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
trueif player has an active punishment,falseotherwise
-
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
trueif player has an active punishment,falseotherwise
-