Klasse ChatFreezeAPI

java.lang.Object
me.kzlyth.api.chatfreeze.ChatFreezeAPI

public class ChatFreezeAPI extends Object
API for freezing and unfreezing the chat in Zenith-Mod.

This API provides methods to freeze and unfreeze the entire server chat. When the chat is frozen, all players (except those with the zenith.chatfreeze.bypass permission) are prevented from sending chat messages. All freeze/unfreeze actions are automatically recorded in the history database.

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:

  • Freezing the chat prevents all players from sending messages (except those with bypass permission)
  • All freeze/unfreeze actions are recorded in the history database (zn_history)
  • Each action receives a unique case ID
  • Player notifications can be sent when chat is frozen/unfrozen (configurable)

Example usage:


 ZenithAPI api = ZenithAPI.getInstance();
 if (api != null) {
     ChatFreezeAPI chatFreezeAPI = api.getChatFreezeAPI();
     
     UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001");
     
     // Freeze the chat
     chatFreezeAPI.freezeChat(staffUuid, "Server announcement incoming").thenAccept(success -> {
         if (success) {
             getLogger().info("Chat frozen successfully");
         }
     });
     
     // Check if chat is frozen
     chatFreezeAPI.isChatFrozen().thenAccept(frozen -> {
         if (frozen) {
             getLogger().info("Chat is currently frozen");
         }
     });
     
     // Unfreeze the chat
     chatFreezeAPI.unfreezeChat(staffUuid, "Server announcement complete").thenAccept(success -> {
         if (success) {
             getLogger().info("Chat unfrozen successfully");
         }
     });
 }
 
Seit:
1.2.3
Autor:
Zenith-Studios
  • Konstruktordetails

    • ChatFreezeAPI

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

    • freezeChat

      @NotNull public @NotNull CompletableFuture<Boolean> freezeChat(@Nullable @Nullable UUID staffUuid, @NotNull @NotNull String reason)
      Freezes the chat, preventing all players from sending messages (except those with bypass permission).

      This method freezes the entire server chat and creates a history entry. Player notifications are automatically sent if configured.

      Example:

      
       UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001");
       
       chatFreezeAPI.freezeChat(staffUuid, "Server announcement incoming").thenAccept(success -> {
           if (success) {
               getLogger().info("Chat frozen successfully");
           }
       });
       
      Parameter:
      staffUuid - The UUID of the staff member performing the freeze (can be null for console)
      reason - The reason for freezing the chat
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • freezeChat

      @NotNull public @NotNull CompletableFuture<Boolean> freezeChat(@Nullable @Nullable String staffName, @NotNull @NotNull String reason)
      Freezes the chat, preventing all players from sending messages (except those with bypass permission).

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

      Example:

      
       chatFreezeAPI.freezeChat("AdminName", "Server announcement incoming").thenAccept(success -> {
           if (success) {
               getLogger().info("Chat frozen successfully");
           }
       });
       
      Parameter:
      staffName - The name of the staff member performing the freeze (can be null for console)
      reason - The reason for freezing the chat
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • unfreezeChat

      @NotNull public @NotNull CompletableFuture<Boolean> unfreezeChat(@Nullable @Nullable UUID staffUuid, @NotNull @NotNull String reason)
      Unfreezes the chat, allowing players to send messages again.

      This method unfreezes the entire server chat and creates a history entry. Player notifications are automatically sent if configured.

      Example:

      
       UUID staffUuid = UUID.fromString("00000000-0000-0000-0000-000000000001");
       
       chatFreezeAPI.unfreezeChat(staffUuid, "Server announcement complete").thenAccept(success -> {
           if (success) {
               getLogger().info("Chat unfrozen successfully");
           }
       });
       
      Parameter:
      staffUuid - The UUID of the staff member performing the unfreeze (can be null for console)
      reason - The reason for unfreezing the chat
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • unfreezeChat

      @NotNull public @NotNull CompletableFuture<Boolean> unfreezeChat(@Nullable @Nullable String staffName, @NotNull @NotNull String reason)
      Unfreezes the chat, allowing players to send messages again.

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

      Example:

      
       chatFreezeAPI.unfreezeChat("AdminName", "Server announcement complete").thenAccept(success -> {
           if (success) {
               getLogger().info("Chat unfrozen successfully");
           }
       });
       
      Parameter:
      staffName - The name of the staff member performing the unfreeze (can be null for console)
      reason - The reason for unfreezing the chat
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • isChatFrozen

      @NotNull public @NotNull CompletableFuture<Boolean> isChatFrozen()
      Checks if the chat is currently frozen.

      Example:

      
       chatFreezeAPI.isChatFrozen().thenAccept(frozen -> {
           if (frozen) {
               getLogger().info("Chat is currently frozen");
           } else {
               getLogger().info("Chat is not frozen");
           }
       });
       
      Gibt zurück:
      A CompletableFuture that completes with true if frozen, false otherwise