Klasse EssentialsAPI
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
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungEssentialsAPI(@NotNull me.kzlyth.ZenithMod plugin, @NotNull ZenithAPI api) Constructs a new EssentialsAPI instance. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibung@NotNull CompletableFuture<Boolean> clearInventory(@NotNull String playerName, @Nullable String staffName) Clears a player's inventory completely (including armor and offhand).@NotNull CompletableFuture<Boolean> clearInventory(@NotNull UUID playerUuid, @Nullable UUID staffUuid) Clears a player's inventory completely (including armor and offhand).@NotNull CompletableFuture<Boolean> Feeds a player, restoring hunger and saturation to maximum.@NotNull CompletableFuture<Boolean> Feeds a player, restoring hunger and saturation to maximum.@NotNull CompletableFuture<Boolean> Heals a player to full health, removes fire, and restores hunger.@NotNull CompletableFuture<Boolean> Heals a player to full health, removes fire, and restores hunger.@NotNull CompletableFuture<Boolean> Checks if a player is currently flying.@NotNull CompletableFuture<Boolean> Checks if a player is currently flying.@NotNull CompletableFuture<Boolean> Checks if a player has god mode enabled.@NotNull CompletableFuture<Boolean> Checks if a player has god mode enabled.@NotNull CompletableFuture<Boolean> setFlyMode(@NotNull String playerName, @Nullable String staffName, boolean enabled) Sets fly mode for a player.@NotNull CompletableFuture<Boolean> setFlyMode(@NotNull UUID playerUuid, @Nullable UUID staffUuid, boolean enabled) Sets fly mode for a player.@NotNull CompletableFuture<Boolean> setGodMode(@NotNull String playerName, @Nullable String staffName, boolean enabled) Sets god mode for a player (invulnerability).@NotNull CompletableFuture<Boolean> setGodMode(@NotNull UUID playerUuid, @Nullable UUID staffUuid, boolean enabled) Sets god mode for a player (invulnerability).@NotNull CompletableFuture<Boolean> Teleports a player to another player's location.@NotNull CompletableFuture<Boolean> Teleports a player to another player's location.@NotNull CompletableFuture<Boolean> teleportHere(@NotNull String playerName, @NotNull String staffName) Teleports a player to the staff member's location.@NotNull CompletableFuture<Boolean> teleportHere(@NotNull UUID playerUuid, @NotNull UUID staffUuid) Teleports a player to the staff member's location.
-
Konstruktordetails
-
EssentialsAPI
Constructs a new EssentialsAPI instance.- Parameter:
plugin- The plugin instanceapi- 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 playerstaffUuid- 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
trueif successful,falseotherwise
-
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 playerstaffName- 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
trueif successful,falseotherwise
-
isGodMode
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
trueif god mode is enabled,falseotherwise
-
isGodMode
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
trueif god mode is enabled,falseotherwise
-
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 playerstaffUuid- 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
trueif successful,falseotherwise
-
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 playerstaffName- 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
trueif successful,falseotherwise
-
isFlying
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
trueif flying,falseotherwise
-
isFlying
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
trueif flying,falseotherwise
-
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 healstaffUuid- The UUID of the staff member performing the heal (can be null for console)- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
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 healstaffName- The name of the staff member performing the heal (can be null for console)- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
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 feedstaffUuid- The UUID of the staff member performing the feed (can be null for console)- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
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 feedstaffName- The name of the staff member performing the feed (can be null for console)- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
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 clearstaffUuid- The UUID of the staff member performing the clear (can be null for console)- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
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 clearstaffName- The name of the staff member performing the clear (can be null for console)- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
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 teleportdestinationUuid- The UUID of the destination playerstaffUuid- The UUID of the staff member performing the teleport (can be null for console)- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
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 teleportdestinationName- The name of the destination playerstaffName- The name of the staff member performing the teleport (can be null for console)- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
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 teleportstaffUuid- The UUID of the staff member (destination, cannot be null)- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
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 teleportstaffName- The name of the staff member (destination, cannot be null)- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-