Klasse VanishAPI
This API provides methods to make players invisible (vanished) or visible again. When a player is vanished, they are hidden from other players (except those with the see permission), and staff notifications are automatically sent if configured.
Database Compatibility: This API does not directly interact with the database, but vanished players are persisted to a JSON file for persistence across server restarts.
Important Notes:
- Players must be online to be vanished/unvanished
- Vanished players are hidden from other players without the see permission
- Staff notifications are automatically sent when players vanish/unvanish
- Vanished state is persisted across server restarts
Example usage:
ZenithAPI api = ZenithAPI.getInstance();
if (api != null) {
VanishAPI vanishAPI = api.getVanishAPI();
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
// Vanish player
vanishAPI.vanish(playerUuid).thenAccept(success -> {
if (success) {
getLogger().info("Player vanished");
}
});
// Check if vanished
vanishAPI.isVanished(playerUuid).thenAccept(vanished -> {
if (vanished) {
getLogger().info("Player is vanished");
}
});
// Unvanish player
vanishAPI.unvanish(playerUuid).thenAccept(success -> {
if (success) {
getLogger().info("Player unvanished");
}
});
// Get all vanished players
vanishAPI.getVanishedPlayers().thenAccept(vanishedPlayers -> {
getLogger().info("Currently vanished players: " + vanishedPlayers.size());
});
}
- Seit:
- 1.2.3
- Autor:
- Zenith-Studios
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibung@NotNull CompletableFuture<List<UUID>> Gets a list of all currently vanished players.@NotNull CompletableFuture<Boolean> isVanished(@NotNull String playerName) Checks if a player is currently vanished.@NotNull CompletableFuture<Boolean> isVanished(@NotNull UUID playerUuid) Checks if a player is currently vanished.@NotNull CompletableFuture<Boolean> toggleVanish(@NotNull String playerName) Toggles the vanish state of a player.@NotNull CompletableFuture<Boolean> toggleVanish(@NotNull UUID playerUuid) Toggles the vanish state of a player.@NotNull CompletableFuture<Boolean> Makes a player visible again (unvanished).@NotNull CompletableFuture<Boolean> Makes a player visible again (unvanished).@NotNull CompletableFuture<Boolean> Makes a player invisible (vanished).@NotNull CompletableFuture<Boolean> Makes a player invisible (vanished).
-
Konstruktordetails
-
VanishAPI
Constructs a new VanishAPI instance.- Parameter:
plugin- The plugin instanceapi- The main API instance
-
-
Methodendetails
-
vanish
Makes a player invisible (vanished).When a player is vanished, they are hidden from other players (except those with the see permission), and staff notifications are automatically sent if configured.
Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); vanishAPI.vanish(playerUuid).thenAccept(success -> { if (success) { getLogger().info("Player vanished"); } });- Parameter:
playerUuid- The UUID of the player to vanish- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
vanish
Makes a player invisible (vanished).This is an overloaded method that accepts a player name instead of UUID.
- Parameter:
playerName- The name of the player to vanish- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
unvanish
Makes a player visible again (unvanished).When a player is unvanished, they become visible to other players again, and staff notifications are automatically sent if configured.
Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); vanishAPI.unvanish(playerUuid).thenAccept(success -> { if (success) { getLogger().info("Player unvanished"); } });- Parameter:
playerUuid- The UUID of the player to unvanish- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
unvanish
Makes a player visible again (unvanished).This is an overloaded method that accepts a player name instead of UUID.
- Parameter:
playerName- The name of the player to unvanish- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
toggleVanish
Toggles the vanish state of a player.If the player is currently vanished, they will be unvanished. If they are not vanished, they will be vanished.
Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); vanishAPI.toggleVanish(playerUuid).thenAccept(success -> { if (success) { getLogger().info("Vanish state toggled"); } });- Parameter:
playerUuid- The UUID of the player to toggle- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
toggleVanish
@NotNull public @NotNull CompletableFuture<Boolean> toggleVanish(@NotNull @NotNull String playerName) Toggles the vanish state of a player.This is an overloaded method that accepts a player name instead of UUID.
- Parameter:
playerName- The name of the player to toggle- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
isVanished
Checks if a player is currently vanished.Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); vanishAPI.isVanished(playerUuid).thenAccept(vanished -> { if (vanished) { getLogger().info("Player is vanished"); } });- Parameter:
playerUuid- The UUID of the player to check- Gibt zurück:
- A CompletableFuture that completes with
trueif vanished,falseotherwise
-
isVanished
Checks if a player is currently vanished.This is an overloaded method that accepts a player name instead of UUID.
- Parameter:
playerName- The name of the player to check- Gibt zurück:
- A CompletableFuture that completes with
trueif vanished,falseotherwise
-
getVanishedPlayers
Gets a list of all currently vanished players.This method returns the UUIDs of all players who are currently vanished.
Example:
vanishAPI.getVanishedPlayers().thenAccept(vanishedPlayers -> { getLogger().info("Currently vanished players: " + vanishedPlayers.size()); for (UUID uuid : vanishedPlayers) { String name = api.getUserInfoAPI().getPlayerName(uuid).join(); getLogger().info("- " + name); } });- Gibt zurück:
- A CompletableFuture that completes with a list of UUIDs of vanished players
-