Klasse KickAPI

java.lang.Object
me.kzlyth.api.kick.KickAPI

public class KickAPI extends Object
API for kicking players in Zenith-Mod.

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.bypass permission 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
  • Konstruktordetails

    • KickAPI

      public KickAPI(@NotNull @NotNull me.kzlyth.ZenithMod plugin, @NotNull @NotNull ZenithAPI api)
      Constructs a new KickAPI instance.
      Parameter:
      plugin - The plugin instance
      api - 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.bypass permission.

      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 kick
      staffUuid - 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 kick
      staffName - 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 kick
      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, @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 kick
      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, @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 kick
      staffUuid - The UUID of the staff member performing the kick (can be null for console)
      reason - The reason for the kick
      additionalData - 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 kick
      staffName - The name of the staff member performing the kick (can be null for console)
      reason - The reason for the kick
      additionalData - 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)