Klasse FreezeAPI
This API provides methods to freeze and unfreeze players. All freeze actions are automatically recorded in the history database with a case ID.
Features:
- Freeze and unfreeze players
- Check if a player is frozen
- Get list of all frozen players
- Automatic staff notifications
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.
Important Notes:
- Players must be online to be frozen
- Players with the
zenith.freeze.bypasspermission cannot be frozen - All freezes are recorded in the history database (zn_history)
- Each freeze receives a unique case ID
- Staff notifications are automatically sent to players with
zenith.freeze.notificationspermission
Example usage:
ZenithAPI api = ZenithAPI.getInstance();
if (api != null) {
FreezeAPI freezeAPI = api.getFreezeAPI();
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001");
// Freeze a player
freezeAPI.freeze(playerUuid, staffUuid, "Investigation").thenAccept(success -> {
if (success) {
getLogger().info("Player frozen successfully");
}
});
// Unfreeze a player
freezeAPI.unfreeze(playerUuid, staffUuid, "Investigation complete").thenAccept(success -> {
if (success) {
getLogger().info("Player unfrozen successfully");
}
});
// Check if player is frozen
freezeAPI.isFrozen(playerUuid).thenAccept(frozen -> {
if (frozen) {
getLogger().info("Player is frozen");
}
});
}
- Seit:
- 1.2.3
- Autor:
- Zenith-Studios
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibung@NotNull CompletableFuture<Boolean> Freezes a player with a specified reason.@NotNull CompletableFuture<Boolean> Freezes a player with a specified reason.@NotNull CompletableFuture<List<UUID>> Gets a list of UUIDs of all currently frozen players.@NotNull CompletableFuture<Boolean> Checks if a player is currently frozen.@NotNull CompletableFuture<Boolean> Checks if a player is currently frozen.@NotNull CompletableFuture<Boolean> Unfreezes a player with a specified reason.@NotNull CompletableFuture<Boolean> Unfreezes a player with a specified reason.
-
Konstruktordetails
-
FreezeAPI
Constructs a new FreezeAPI instance.- Parameter:
plugin- The plugin instanceapi- The main API instance
-
-
Methodendetails
-
freeze
@NotNull public @NotNull CompletableFuture<Boolean> freeze(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid, @NotNull @NotNull String reason) Freezes a player with a specified reason.This method freezes an online player with a custom reason. The freeze is recorded in the history database with a case ID. Staff notifications are automatically sent.
Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); freezeAPI.freeze(playerUuid, staffUuid, "Investigation").thenAccept(success -> { if (success) { getLogger().info("Player frozen successfully"); } else { getLogger().warning("Failed to freeze player"); } });- Parameter:
playerUuid- The UUID of the player to freezestaffUuid- The UUID of the staff member performing the freeze (can be null for console)reason- The reason for freezing- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
freeze
@NotNull public @NotNull CompletableFuture<Boolean> freeze(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName, @NotNull @NotNull String reason) Freezes a player with a specified reason.This is an overloaded method that accepts player and staff names instead of UUIDs.
Example:
freezeAPI.freeze("PlayerName", "AdminName", "Investigation").thenAccept(success -> { if (success) { getLogger().info("Player frozen successfully"); } });- Parameter:
playerName- The name of the player to freezestaffName- The name of the staff member performing the freeze (can be null for console)reason- The reason for freezing- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
unfreeze
@NotNull public @NotNull CompletableFuture<Boolean> unfreeze(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid, @NotNull @NotNull String reason) Unfreezes a player with a specified reason.This method unfreezes a previously frozen player with a custom reason. The unfreeze is recorded in the history database. Staff notifications are automatically sent.
Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); freezeAPI.unfreeze(playerUuid, staffUuid, "Investigation complete").thenAccept(success -> { if (success) { getLogger().info("Player unfrozen successfully"); } });- Parameter:
playerUuid- The UUID of the player to unfreezestaffUuid- The UUID of the staff member performing the unfreeze (can be null for console)reason- The reason for unfreezing- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
unfreeze
@NotNull public @NotNull CompletableFuture<Boolean> unfreeze(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName, @NotNull @NotNull String reason) Unfreezes a player with a specified reason.This is an overloaded method that accepts player and staff names instead of UUIDs.
Example:
freezeAPI.unfreeze("PlayerName", "AdminName", "Investigation complete").thenAccept(success -> { if (success) { getLogger().info("Player unfrozen successfully"); } });- Parameter:
playerName- The name of the player to unfreezestaffName- The name of the staff member performing the unfreeze (can be null for console)reason- The reason for unfreezing- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
isFrozen
Checks if a player is currently frozen.Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); freezeAPI.isFrozen(playerUuid).thenAccept(frozen -> { if (frozen) { getLogger().info("Player is frozen"); } else { getLogger().info("Player is not frozen"); } });- Parameter:
playerUuid- The UUID of the player to check- Gibt zurück:
- A CompletableFuture that completes with
trueif frozen,falseotherwise
-
isFrozen
Checks if a player is currently frozen.This is an overloaded method that accepts a player name instead of UUID.
Example:
freezeAPI.isFrozen("PlayerName").thenAccept(frozen -> { if (frozen) { getLogger().info("Player is frozen"); } });- Parameter:
playerName- The name of the player to check- Gibt zurück:
- A CompletableFuture that completes with
trueif frozen,falseotherwise
-
getFrozenPlayers
Gets a list of UUIDs of all currently frozen players.Example:
freezeAPI.getFrozenPlayers().thenAccept(frozenPlayers -> { getLogger().info("Currently frozen players: " + frozenPlayers.size()); for (UUID playerUuid : frozenPlayers) { String playerName = api.getUserInfoAPI().getPlayerName(playerUuid).join(); getLogger().info(" - " + playerName); } });- Gibt zurück:
- A CompletableFuture that completes with a list of UUIDs of frozen players
-