Klasse MuteAPI
This API provides methods to mute players (regular and IP mutes), mute using templates (custom mutes), and unmute players. All mutes are automatically recorded in the history database with a case ID.
Features:
- Regular mutes and IP mutes
- Template-based mutes with escalation support
- Online and offline player muting
- Unmute functionality
- Custom duration formats (e.g., "1d", "2h", "30m", "permanent")
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 with the
zenith.mute.bypasspermission cannot be muted - All mutes are recorded in the history database (zn_history)
- Each mute receives a unique case ID
- Templates support escalation (duration increases with repeat offenses)
Example usage:
ZenithAPI api = ZenithAPI.getInstance();
if (api != null) {
MuteAPI muteAPI = api.getMuteAPI();
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001");
// Regular mute with duration
muteAPI.mute(playerUuid, staffUuid, "Spam", "7d").thenAccept(caseId -> {
if (caseId > 0) {
getLogger().info("Player muted successfully. Case ID: " + caseId);
}
});
// IP mute
muteAPI.ipMute(playerUuid, staffUuid, "Toxicity", "30d").thenAccept(caseId -> {
if (caseId > 0) {
getLogger().info("Player IP muted successfully. Case ID: " + caseId);
}
});
// Mute using template (with escalation)
muteAPI.muteWithTemplate(playerUuid, staffUuid, "spam", "Spamming in chat").thenAccept(caseId -> {
if (caseId > 0) {
getLogger().info("Player muted with template. Case ID: " + caseId);
}
});
// Unmute
muteAPI.unmute(playerUuid, staffUuid, "Appeal accepted").thenAccept(success -> {
if (success) {
getLogger().info("Player unmuted successfully");
}
});
}
- Seit:
- 1.2.3
- Autor:
- Zenith-Studios
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibung@NotNull CompletableFuture<ActiveMuteInfo> getActiveMuteInfo(@NotNull String playerName) Gets complete information about the active mute for a player.@NotNull CompletableFuture<ActiveMuteInfo> getActiveMuteInfo(@NotNull UUID playerUuid) Gets complete information about the active mute for a player.@NotNull CompletableFuture<Integer> ipMute(@NotNull String playerName, @Nullable String staffName, @NotNull String reason, @NotNull String duration) IP mutes a player with a specified duration.@NotNull CompletableFuture<Integer> ipMute(@NotNull UUID playerUuid, @Nullable UUID staffUuid, @NotNull String reason, @NotNull String duration) IP mutes a player with a specified duration.@NotNull CompletableFuture<Integer> ipMuteOffline(@NotNull String playerName, @Nullable String staffName, @NotNull String reason, @NotNull String duration) IP mutes an offline player with a specified duration.@NotNull CompletableFuture<Integer> ipMuteOffline(@NotNull UUID playerUuid, @Nullable UUID staffUuid, @NotNull String reason, @NotNull String duration) IP mutes an offline player with a specified duration.@NotNull CompletableFuture<Integer> mute(@NotNull String playerName, @Nullable String staffName, @NotNull String reason, @NotNull String duration) Mutes a player with a specified duration.@NotNull CompletableFuture<Integer> mute(@NotNull UUID playerUuid, @Nullable UUID staffUuid, @NotNull String reason, @NotNull String duration) Mutes a player with a specified duration.@NotNull CompletableFuture<Integer> muteOffline(@NotNull String playerName, @Nullable String staffName, @NotNull String reason, @NotNull String duration) Mutes an offline player with a specified duration.@NotNull CompletableFuture<Integer> muteOffline(@NotNull UUID playerUuid, @Nullable UUID staffUuid, @NotNull String reason, @NotNull String duration) Mutes an offline player with a specified duration.@NotNull CompletableFuture<Integer> muteWithTemplate(@NotNull String playerName, @Nullable String staffName, @NotNull String templateKey, @Nullable String customReason) Mutes a player using a template (custom mute with escalation support).@NotNull CompletableFuture<Integer> muteWithTemplate(@NotNull UUID playerUuid, @Nullable UUID staffUuid, @NotNull String templateKey, @Nullable String customReason) Mutes a player using a template (custom mute with escalation support).@NotNull CompletableFuture<Boolean> Unmutes a player.@NotNull CompletableFuture<Boolean> unmute(@NotNull String playerName, @Nullable String staffName, @NotNull String reason, @Nullable String additionalData) Unmutes a player with additional data.@NotNull CompletableFuture<Boolean> Unmutes a player.@NotNull CompletableFuture<Boolean> unmute(@NotNull UUID playerUuid, @Nullable UUID staffUuid, @NotNull String reason, @Nullable String additionalData) Unmutes a player with additional data.
-
Konstruktordetails
-
MuteAPI
Constructs a new MuteAPI instance.- Parameter:
plugin- The plugin instanceapi- The main API instance
-
-
Methodendetails
-
mute
@NotNull public @NotNull CompletableFuture<Integer> mute(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid, @NotNull @NotNull String reason, @NotNull @NotNull String duration) Mutes a player with a specified duration.This method mutes an online player. If the player is offline, use
muteOffline(UUID, UUID, String, String). The mute is recorded in the history database with a case ID.Duration formats:
"permanent"or"perm"or"forever"- Permanent mute"1d"- 1 day"2h"- 2 hours"30m"- 30 minutes"45s"- 45 seconds"1w"- 1 week"1M"- 1 month
Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); muteAPI.mute(playerUuid, staffUuid, "Spam detected", "7d").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player muted successfully. Case ID: " + caseId); } else { getLogger().warning("Failed to mute player (player may be offline or have bypass permission)"); } });- Parameter:
playerUuid- The UUID of the player to mutestaffUuid- The UUID of the staff member performing the mute (can be null for console)reason- The reason for the muteduration- The duration string (e.g., "7d", "2h", "permanent")- Gibt zurück:
- A CompletableFuture that completes with the case ID (positive if successful, -1 if failed)
-
mute
@NotNull public @NotNull CompletableFuture<Integer> mute(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName, @NotNull @NotNull String reason, @NotNull @NotNull String duration) Mutes a player with a specified duration.This is an overloaded method that accepts player and staff names instead of UUIDs.
Example:
muteAPI.mute("PlayerName", "AdminName", "Spam detected", "7d").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player muted successfully. Case ID: " + caseId); } });- Parameter:
playerName- The name of the player to mutestaffName- The name of the staff member performing the mute (can be null for console)reason- The reason for the muteduration- The duration string (e.g., "7d", "2h", "permanent")- Gibt zurück:
- A CompletableFuture that completes with the case ID (positive if successful, -1 if failed)
-
muteOffline
@NotNull public @NotNull CompletableFuture<Integer> muteOffline(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid, @NotNull @NotNull String reason, @NotNull @NotNull String duration) Mutes an offline player with a specified duration.This method mutes a player that is currently offline. The player must exist in the database.
Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); muteAPI.muteOffline(playerUuid, staffUuid, "Spam detected", "7d").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Offline player muted successfully. Case ID: " + caseId); } });- Parameter:
playerUuid- The UUID of the player to mutestaffUuid- The UUID of the staff member performing the mute (can be null for console)reason- The reason for the muteduration- The duration string (e.g., "7d", "2h", "permanent")- Gibt zurück:
- A CompletableFuture that completes with the case ID (positive if successful, -1 if failed)
-
muteOffline
@NotNull public @NotNull CompletableFuture<Integer> muteOffline(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName, @NotNull @NotNull String reason, @NotNull @NotNull String duration) Mutes an offline player with a specified duration.This is an overloaded method that accepts player and staff names instead of UUIDs.
Example:
muteAPI.muteOffline("PlayerName", "AdminName", "Spam detected", "7d").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Offline player muted successfully. Case ID: " + caseId); } });- Parameter:
playerName- The name of the player to mutestaffName- The name of the staff member performing the mute (can be null for console)reason- The reason for the muteduration- The duration string (e.g., "7d", "2h", "permanent")- Gibt zurück:
- A CompletableFuture that completes with the case ID (positive if successful, -1 if failed)
-
ipMute
@NotNull public @NotNull CompletableFuture<Integer> ipMute(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid, @NotNull @NotNull String reason, @NotNull @NotNull String duration) IP mutes a player with a specified duration.This method IP mutes an online player. If the player is offline, use
ipMuteOffline(UUID, UUID, String, String). IP mutes affect all accounts using the same IP address.Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); muteAPI.ipMute(playerUuid, staffUuid, "Toxicity detected", "30d").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player IP muted successfully. Case ID: " + caseId); } });- Parameter:
playerUuid- The UUID of the player to IP mutestaffUuid- The UUID of the staff member performing the mute (can be null for console)reason- The reason for the muteduration- The duration string (e.g., "7d", "2h", "permanent")- Gibt zurück:
- A CompletableFuture that completes with the case ID (positive if successful, -1 if failed)
-
ipMute
@NotNull public @NotNull CompletableFuture<Integer> ipMute(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName, @NotNull @NotNull String reason, @NotNull @NotNull String duration) IP mutes a player with a specified duration.This is an overloaded method that accepts player and staff names instead of UUIDs.
Example:
muteAPI.ipMute("PlayerName", "AdminName", "Toxicity detected", "30d").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player IP muted successfully. Case ID: " + caseId); } });- Parameter:
playerName- The name of the player to IP mutestaffName- The name of the staff member performing the mute (can be null for console)reason- The reason for the muteduration- The duration string (e.g., "7d", "2h", "permanent")- Gibt zurück:
- A CompletableFuture that completes with the case ID (positive if successful, -1 if failed)
-
ipMuteOffline
@NotNull public @NotNull CompletableFuture<Integer> ipMuteOffline(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid, @NotNull @NotNull String reason, @NotNull @NotNull String duration) IP mutes an offline player with a specified duration.This method IP mutes a player that is currently offline. The player must exist in the database.
Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); muteAPI.ipMuteOffline(playerUuid, staffUuid, "Toxicity detected", "30d").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Offline player IP muted successfully. Case ID: " + caseId); } });- Parameter:
playerUuid- The UUID of the player to IP mutestaffUuid- The UUID of the staff member performing the mute (can be null for console)reason- The reason for the muteduration- The duration string (e.g., "7d", "2h", "permanent")- Gibt zurück:
- A CompletableFuture that completes with the case ID (positive if successful, -1 if failed)
-
ipMuteOffline
@NotNull public @NotNull CompletableFuture<Integer> ipMuteOffline(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName, @NotNull @NotNull String reason, @NotNull @NotNull String duration) IP mutes an offline player with a specified duration.This is an overloaded method that accepts player and staff names instead of UUIDs.
Example:
muteAPI.ipMuteOffline("PlayerName", "AdminName", "Toxicity detected", "30d").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Offline player IP muted successfully. Case ID: " + caseId); } });- Parameter:
playerName- The name of the player to IP mutestaffName- The name of the staff member performing the mute (can be null for console)reason- The reason for the muteduration- The duration string (e.g., "7d", "2h", "permanent")- Gibt zurück:
- A CompletableFuture that completes with the case ID (positive if successful, -1 if failed)
-
muteWithTemplate
@NotNull public @NotNull CompletableFuture<Integer> muteWithTemplate(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid, @NotNull @NotNull String templateKey, @Nullable @Nullable String customReason) Mutes a player using a template (custom mute with escalation support).Templates support escalation, meaning the mute duration increases with repeat offenses. The escalation can be tracked by IP address or by player UUID, depending on the template configuration.
Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); muteAPI.muteWithTemplate(playerUuid, staffUuid, "spam", "Spamming in chat").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player muted with template. Case ID: " + caseId); } });- Parameter:
playerUuid- The UUID of the player to mutestaffUuid- The UUID of the staff member performing the mute (can be null for console)templateKey- The template key (identifier, e.g., "spam", "toxicity")customReason- Optional custom reason (if null, uses template default reason)- Gibt zurück:
- A CompletableFuture that completes with the case ID (positive if successful, -1 if failed)
-
muteWithTemplate
@NotNull public @NotNull CompletableFuture<Integer> muteWithTemplate(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName, @NotNull @NotNull String templateKey, @Nullable @Nullable String customReason) Mutes a player using a template (custom mute with escalation support).This is an overloaded method that accepts player and staff names instead of UUIDs.
Example:
muteAPI.muteWithTemplate("PlayerName", "AdminName", "spam", "Spamming in chat").thenAccept(caseId -> { if (caseId > 0) { getLogger().info("Player muted with template. Case ID: " + caseId); } });- Parameter:
playerName- The name of the player to mutestaffName- The name of the staff member performing the mute (can be null for console)templateKey- The template key (identifier, e.g., "spam", "toxicity")customReason- Optional custom reason (if null, uses template default reason)- Gibt zurück:
- A CompletableFuture that completes with the case ID (positive if successful, -1 if failed)
-
unmute
@NotNull public @NotNull CompletableFuture<Boolean> unmute(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid, @NotNull @NotNull String reason) Unmutes a player.This method removes the mute status, creates an UNMUTE history entry, and deactivates any IP mutes associated with the player's IP address.
Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001"); muteAPI.unmute(playerUuid, staffUuid, "Appeal accepted").thenAccept(success -> { if (success) { getLogger().info("Player unmuted successfully"); } else { getLogger().warning("Failed to unmute player (player may not be muted)"); } });- Parameter:
playerUuid- The UUID of the player to unmutestaffUuid- The UUID of the staff member performing the unmute (can be null for console)reason- The reason for the unmute- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
unmute
@NotNull public @NotNull CompletableFuture<Boolean> unmute(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName, @NotNull @NotNull String reason) Unmutes a player.This is an overloaded method that accepts player and staff names instead of UUIDs.
Example:
muteAPI.unmute("PlayerName", "AdminName", "Appeal accepted").thenAccept(success -> { if (success) { getLogger().info("Player unmuted successfully"); } });- Parameter:
playerName- The name of the player to unmutestaffName- The name of the staff member performing the unmute (can be null for console)reason- The reason for the unmute- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
unmute
@NotNull public @NotNull CompletableFuture<Boolean> unmute(@NotNull @NotNull UUID playerUuid, @Nullable @Nullable UUID staffUuid, @NotNull @NotNull String reason, @Nullable @Nullable String additionalData) Unmutes a player with additional data.This method allows you to provide additional data (JSON string) that will be stored with the unmute 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\"}"; muteAPI.unmute(playerUuid, staffUuid, "Appeal accepted", additionalData).thenAccept(success -> { if (success) { getLogger().info("Player unmuted successfully"); } });- Parameter:
playerUuid- The UUID of the player to unmutestaffUuid- The UUID of the staff member performing the unmute (can be null for console)reason- The reason for the unmuteadditionalData- Additional data to store with the unmute (JSON string, can be null)- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
unmute
@NotNull public @NotNull CompletableFuture<Boolean> unmute(@NotNull @NotNull String playerName, @Nullable @Nullable String staffName, @NotNull @NotNull String reason, @Nullable @Nullable String additionalData) Unmutes a player 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\"}"; muteAPI.unmute("PlayerName", "AdminName", "Appeal accepted", additionalData).thenAccept(success -> { if (success) { getLogger().info("Player unmuted successfully"); } });- Parameter:
playerName- The name of the player to unmutestaffName- The name of the staff member performing the unmute (can be null for console)reason- The reason for the unmuteadditionalData- Additional data to store with the unmute (JSON string, can be null)- Gibt zurück:
- A CompletableFuture that completes with
trueif successful,falseotherwise
-
getActiveMuteInfo
@NotNull public @NotNull CompletableFuture<ActiveMuteInfo> getActiveMuteInfo(@NotNull @NotNull UUID playerUuid) Gets complete information about the active mute for a player.Returns detailed information about the player's active mute including case ID, reason, duration, expiration time, staff member, and whether it's an IP mute or permanent.
Example:
UUID playerUuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); muteAPI.getActiveMuteInfo(playerUuid).thenAccept(muteInfo -> { if (muteInfo != null) { getLogger().info("Player is muted:"); getLogger().info(" Case ID: " + muteInfo.getCaseId()); getLogger().info(" Reason: " + muteInfo.getReason()); getLogger().info(" Staff: " + muteInfo.getStaffName()); getLogger().info(" IP Mute: " + muteInfo.isIpMute()); if (muteInfo.isPermanent()) { getLogger().info(" Type: Permanent"); } else { getLogger().info(" Expires at: " + new Date(muteInfo.getExpiresAt())); } } else { getLogger().info("Player is not muted"); } });- Parameter:
playerUuid- The UUID of the player- Gibt zurück:
- A CompletableFuture that completes with the active mute information, or
nullif player is not muted
-
getActiveMuteInfo
@NotNull public @NotNull CompletableFuture<ActiveMuteInfo> getActiveMuteInfo(@NotNull @NotNull String playerName) Gets complete information about the active mute for a player.This is an overloaded method that accepts a player name instead of UUID.
Example:
muteAPI.getActiveMuteInfo("PlayerName").thenAccept(muteInfo -> { if (muteInfo != null) { getLogger().info("Player is muted. Case ID: " + muteInfo.getCaseId()); } });- Parameter:
playerName- The name of the player- Gibt zurück:
- A CompletableFuture that completes with the active mute information, or
nullif player is not muted or doesn't exist
-