Klasse EssentialsAPI

java.lang.Object
me.kzlyth.api.essentials.EssentialsAPI

public class EssentialsAPI extends Object
API for essentials functions in Zenith-Mod (God Mode, Fly Mode, Heal, Feed, Clear Inventory, Teleport).

This API provides methods to manage player essentials like god mode, fly mode, healing, feeding, clearing inventories, and teleportation. All actions support staff notifications.

Database Compatibility: This API does not directly interact with the database, but all methods are compatible with the underlying system that may use H2, SQLite, MySQL, or MariaDB databases.

Important Notes:

  • All players must be online for these operations
  • Staff notifications are automatically sent when actions are performed on other players
  • Players with bypass permissions are not affected by certain operations

Example usage:


 ZenithAPI api = ZenithAPI.getInstance();
 if (api != null) {
     EssentialsAPI essentialsAPI = api.getEssentialsAPI();
     
     UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
     UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001");
     
     // Set god mode
     essentialsAPI.setGodMode(playerUuid, staffUuid, true).thenAccept(success -> {
         if (success) {
             getLogger().info("God mode enabled");
         }
     });
     
     // Heal player
     essentialsAPI.heal(playerUuid, staffUuid).thenAccept(success -> {
         if (success) {
             getLogger().info("Player healed");
         }
     });
     
     // Teleport player
     UUID destinationUuid = UUID.fromString("987e6543-e21b-12d3-a456-426614174999");
     essentialsAPI.teleport(playerUuid, destinationUuid, staffUuid).thenAccept(success -> {
         if (success) {
             getLogger().info("Player teleported");
         }
     });
 }
 
Seit:
1.2.3
Autor:
Zenith-Studios
  • Konstruktordetails

    • EssentialsAPI

      public EssentialsAPI(@NotNull @NotNull me.kzlyth.ZenithMod plugin, @NotNull @NotNull ZenithAPI api)
      Constructs a new EssentialsAPI instance.
      Parameter:
      plugin - The plugin instance
      api - The main API instance
  • Methodendetails

    • setGodMode

      @NotNull public @NotNull CompletableFuture<Boolean> setGodMode(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid, boolean enabled)
      Sets god mode for a player (invulnerability).

      Example:

      
       essentialsAPI.setGodMode(playerUuid, staffUuid, true).thenAccept(success -> {
           if (success) {
               getLogger().info("God mode enabled");
           }
       });
       
      Parameter:
      playerUuid - The UUID of the player
      staffUuid - The UUID of the staff member (can be null for console)
      enabled - Whether to enable or disable god mode
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • setGodMode

      @NotNull public @NotNull CompletableFuture<Boolean> setGodMode(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName, boolean enabled)
      Sets god mode for a player (invulnerability).

      This is an overloaded method that accepts player and staff names instead of UUIDs.

      Parameter:
      playerName - The name of the player
      staffName - The name of the staff member (can be null for console)
      enabled - Whether to enable or disable god mode
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • isGodMode

      @NotNull public @NotNull CompletableFuture<Boolean> isGodMode(@NotNull @NotNull UUID playerUuid)
      Checks if a player has god mode enabled.

      Example:

      
       essentialsAPI.isGodMode(playerUuid).thenAccept(isGod -> {
           if (isGod) {
               getLogger().info("Player is in god mode");
           }
       });
       
      Parameter:
      playerUuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with true if god mode is enabled, false otherwise
    • isGodMode

      @NotNull public @NotNull CompletableFuture<Boolean> isGodMode(@NotNull @NotNull String playerName)
      Checks if a player has god mode enabled.

      This is an overloaded method that accepts a player name instead of UUID.

      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with true if god mode is enabled, false otherwise
    • setFlyMode

      @NotNull public @NotNull CompletableFuture<Boolean> setFlyMode(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid, boolean enabled)
      Sets fly mode for a player.

      Example:

      
       essentialsAPI.setFlyMode(playerUuid, staffUuid, true).thenAccept(success -> {
           if (success) {
               getLogger().info("Fly mode enabled");
           }
       });
       
      Parameter:
      playerUuid - The UUID of the player
      staffUuid - The UUID of the staff member (can be null for console)
      enabled - Whether to enable or disable fly mode
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • setFlyMode

      @NotNull public @NotNull CompletableFuture<Boolean> setFlyMode(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName, boolean enabled)
      Sets fly mode for a player.

      This is an overloaded method that accepts player and staff names instead of UUIDs.

      Parameter:
      playerName - The name of the player
      staffName - The name of the staff member (can be null for console)
      enabled - Whether to enable or disable fly mode
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • isFlying

      @NotNull public @NotNull CompletableFuture<Boolean> isFlying(@NotNull @NotNull UUID playerUuid)
      Checks if a player is currently flying.

      Example:

      
       essentialsAPI.isFlying(playerUuid).thenAccept(isFlying -> {
           if (isFlying) {
               getLogger().info("Player is flying");
           }
       });
       
      Parameter:
      playerUuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with true if flying, false otherwise
    • isFlying

      @NotNull public @NotNull CompletableFuture<Boolean> isFlying(@NotNull @NotNull String playerName)
      Checks if a player is currently flying.

      This is an overloaded method that accepts a player name instead of UUID.

      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with true if flying, false otherwise
    • heal

      @NotNull public @NotNull CompletableFuture<Boolean> heal(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid)
      Heals a player to full health, removes fire, and restores hunger.

      Example:

      
       essentialsAPI.heal(playerUuid, staffUuid).thenAccept(success -> {
           if (success) {
               getLogger().info("Player healed");
           }
       });
       
      Parameter:
      playerUuid - The UUID of the player to heal
      staffUuid - The UUID of the staff member performing the heal (can be null for console)
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • heal

      @NotNull public @NotNull CompletableFuture<Boolean> heal(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName)
      Heals a player to full health, removes fire, and restores hunger.

      This is an overloaded method that accepts player and staff names instead of UUIDs.

      Parameter:
      playerName - The name of the player to heal
      staffName - The name of the staff member performing the heal (can be null for console)
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • feed

      @NotNull public @NotNull CompletableFuture<Boolean> feed(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid)
      Feeds a player, restoring hunger and saturation to maximum.

      Example:

      
       essentialsAPI.feed(playerUuid, staffUuid).thenAccept(success -> {
           if (success) {
               getLogger().info("Player fed");
           }
       });
       
      Parameter:
      playerUuid - The UUID of the player to feed
      staffUuid - The UUID of the staff member performing the feed (can be null for console)
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • feed

      @NotNull public @NotNull CompletableFuture<Boolean> feed(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName)
      Feeds a player, restoring hunger and saturation to maximum.

      This is an overloaded method that accepts player and staff names instead of UUIDs.

      Parameter:
      playerName - The name of the player to feed
      staffName - The name of the staff member performing the feed (can be null for console)
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • clearInventory

      @NotNull public @NotNull CompletableFuture<Boolean> clearInventory(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid)
      Clears a player's inventory completely (including armor and offhand).

      Example:

      
       essentialsAPI.clearInventory(playerUuid, staffUuid).thenAccept(success -> {
           if (success) {
               getLogger().info("Inventory cleared");
           }
       });
       
      Parameter:
      playerUuid - The UUID of the player whose inventory to clear
      staffUuid - The UUID of the staff member performing the clear (can be null for console)
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • clearInventory

      @NotNull public @NotNull CompletableFuture<Boolean> clearInventory(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName)
      Clears a player's inventory completely (including armor and offhand).

      This is an overloaded method that accepts player and staff names instead of UUIDs.

      Parameter:
      playerName - The name of the player whose inventory to clear
      staffName - The name of the staff member performing the clear (can be null for console)
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • teleport

      @NotNull public @NotNull CompletableFuture<Boolean> teleport(@NotNull @NotNull UUID playerUuid, @NotNull @NotNull UUID destinationUuid, @Nullable @Nullable UUID staffUuid)
      Teleports a player to another player's location.

      Example:

      
       UUID destinationUuid = UUID.fromString("987e6543-e21b-12d3-a456-426614174999");
       essentialsAPI.teleport(playerUuid, destinationUuid, staffUuid).thenAccept(success -> {
           if (success) {
               getLogger().info("Player teleported");
           }
       });
       
      Parameter:
      playerUuid - The UUID of the player to teleport
      destinationUuid - The UUID of the destination player
      staffUuid - The UUID of the staff member performing the teleport (can be null for console)
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • teleport

      @NotNull public @NotNull CompletableFuture<Boolean> teleport(@NotNull @NotNull String playerName, @NotNull @NotNull String destinationName, @Nullable @Nullable String staffName)
      Teleports a player to another player's location.

      This is an overloaded method that accepts player names instead of UUIDs.

      Parameter:
      playerName - The name of the player to teleport
      destinationName - The name of the destination player
      staffName - The name of the staff member performing the teleport (can be null for console)
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • teleportHere

      @NotNull public @NotNull CompletableFuture<Boolean> teleportHere(@NotNull @NotNull UUID playerUuid, @NotNull @NotNull UUID staffUuid)
      Teleports a player to the staff member's location.

      Example:

      
       essentialsAPI.teleportHere(playerUuid, staffUuid).thenAccept(success -> {
           if (success) {
               getLogger().info("Player teleported to staff");
           }
       });
       
      Parameter:
      playerUuid - The UUID of the player to teleport
      staffUuid - The UUID of the staff member (destination, cannot be null)
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • teleportHere

      @NotNull public @NotNull CompletableFuture<Boolean> teleportHere(@NotNull @NotNull String playerName, @NotNull @NotNull String staffName)
      Teleports a player to the staff member's location.

      This is an overloaded method that accepts player names instead of UUIDs.

      Parameter:
      playerName - The name of the player to teleport
      staffName - The name of the staff member (destination, cannot be null)
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise