Klasse KickAPI
This API provides methods to kick players from the server. All kicks are automatically recorded in the history database with a case ID.
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 kicked
- Players with the
zenith.kick.bypasspermission cannot be kicked - All kicks are recorded in the history database (zn_history)
- Each kick receives a unique case ID
Example usage:
ZenithAPI api = ZenithAPI.getInstance();
if (api != null) {
KickAPI kickAPI = api.getKickAPI();
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001");
// Kick a player with a reason
kickAPI.kick(playerUuid, staffUuid, "Inappropriate behavior").thenAccept(caseId -> {
if (caseId > 0) {
getLogger().info("Player kicked successfully. Case ID: " + caseId);
} else {
getLogger().warning("Failed to kick player");
}
});
// Kick a player from console (no staff member)
kickAPI.kick(playerUuid, "Server maintenance").thenAccept(caseId -> {
if (caseId > 0) {
getLogger().info("Player kicked by console. Case ID: " + caseId);
}
});
}
- Seit:
- 1.2.3
- Autor:
- Zenith-Studios
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibung@NotNull CompletableFuture<Integer> Kicks a player from the server (by console).@NotNull CompletableFuture<Integer> Kicks a player from the server.@NotNull CompletableFuture<Integer> kick(@NotNull String playerName, @Nullable String staffName, @NotNull String reason, @Nullable String additionalData) Kicks a player from the server with additional data.@NotNull CompletableFuture<Integer> Kicks a player from the server (by console).@NotNull CompletableFuture<Integer> Kicks a player from the server.@NotNull CompletableFuture<Integer> kick(@NotNull UUID playerUuid, @Nullable UUID staffUuid, @NotNull String reason, @Nullable String additionalData) Kicks a player from the server with additional data.
-
Konstruktordetails
-
KickAPI
Constructs a new KickAPI instance.- Parameter:
plugin- The plugin instanceapi- The main API instance
-
-
Methodendetails
-
kick
@NotNull public @NotNull CompletableFuture<Integer> kick(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid, @NotNull @NotNull String reason) Kicks a player from the server.The kick is recorded in the history database with a case ID. The player must be online and must not have the
zenith.kick.bypasspermission.Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); kickAPI.kick(playerUuid, staffUuid, "Inappropriate behavior").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player kicked successfully. Case ID: " + caseId); } else { getLogger().warning("Failed to kick player (player may be offline or have bypass permission)"); } });- Parameter:
playerUuid- The UUID of the player to kickstaffUuid- The UUID of the staff member performing the kick (can be null for console)reason- The reason for the kick- Gibt zurück:
- A CompletableFuture that completes with the case ID (positive if successful, -1 if failed)
-
kick
@NotNull public @NotNull CompletableFuture<Integer> kick(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName, @NotNull @NotNull String reason) Kicks a player from the server.This is an overloaded method that accepts a player name instead of UUID.
Example:
kickAPI.kick("PlayerName", "AdminName", "Inappropriate behavior").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player kicked successfully. Case ID: " + caseId); } });- Parameter:
playerName- The name of the player to kickstaffName- The name of the staff member performing the kick (can be null for console)reason- The reason for the kick- Gibt zurück:
- A CompletableFuture that completes with the case ID (positive if successful, -1 if failed)
-
kick
@NotNull public @NotNull CompletableFuture<Integer> kick(@NotNull @NotNull UUID playerUuid, @NotNull @NotNull String reason) Kicks a player from the server (by console).This is a convenience method that kicks a player without a staff member (console kick).
Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); kickAPI.kick(playerUuid, "Server maintenance").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player kicked by console. Case ID: " + caseId); } });- Parameter:
playerUuid- The UUID of the player to kickreason- The reason for the kick- Gibt zurück:
- A CompletableFuture that completes with the case ID (positive if successful, -1 if failed)
-
kick
@NotNull public @NotNull CompletableFuture<Integer> kick(@NotNull @NotNull String playerName, @NotNull @NotNull String reason) Kicks a player from the server (by console).This is an overloaded method that accepts a player name instead of UUID.
Example:
kickAPI.kick("PlayerName", "Server maintenance").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player kicked by console. Case ID: " + caseId); } });- Parameter:
playerName- The name of the player to kickreason- The reason for the kick- Gibt zurück:
- A CompletableFuture that completes with the case ID (positive if successful, -1 if failed)
-
kick
@NotNull public @NotNull CompletableFuture<Integer> kick(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid, @NotNull @NotNull String reason, @Nullable @Nullable String additionalData) Kicks a player from the server with additional data.This method allows you to provide additional data (JSON string) that will be stored with the kick history entry.
Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); String additionalData = "{\"source\":\"api\",\"custom_field\":\"value\"}"; kickAPI.kick(playerUuid, staffUuid, "Inappropriate behavior", additionalData).thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player kicked with additional data. Case ID: " + caseId); } });- Parameter:
playerUuid- The UUID of the player to kickstaffUuid- The UUID of the staff member performing the kick (can be null for console)reason- The reason for the kickadditionalData- Additional data to store with the kick (JSON string, can be null)- Gibt zurück:
- A CompletableFuture that completes with the case ID (positive if successful, -1 if failed)
-
kick
@NotNull public @NotNull CompletableFuture<Integer> kick(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName, @NotNull @NotNull String reason, @Nullable @Nullable String additionalData) Kicks a player from the server with additional data.This is an overloaded method that accepts player and staff names instead of UUIDs.
Example:
String additionalData = "{\"source\":\"api\",\"custom_field\":\"value\"}"; kickAPI.kick("PlayerName", "AdminName", "Inappropriate behavior", additionalData).thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player kicked with additional data. Case ID: " + caseId); } });- Parameter:
playerName- The name of the player to kickstaffName- The name of the staff member performing the kick (can be null for console)reason- The reason for the kickadditionalData- Additional data to store with the kick (JSON string, can be null)- Gibt zurück:
- A CompletableFuture that completes with the case ID (positive if successful, -1 if failed)
-