Enum Class BroadcastType

java.lang.Object
java.lang.Enum<BroadcastType>
me.internalizable.numdrassl.api.messaging.channel.BroadcastType
All Implemented Interfaces:
Serializable, Comparable<BroadcastType>, Constable

public enum BroadcastType extends Enum<BroadcastType>
Types of cluster-wide broadcast messages.

Using an enum instead of raw strings ensures type safety and prevents typos in broadcast type handling.

Usage

// Publishing
broadcastHandler.broadcast(BroadcastType.ANNOUNCEMENT, "Server restarting in 5 minutes");

// Handling
switch (message.getBroadcastType()) {
    case ANNOUNCEMENT -> handleAnnouncement(message);
    case ALERT -> handleAlert(message);
    // ...
}
  • Enum Constant Details

    • ANNOUNCEMENT

      public static final BroadcastType ANNOUNCEMENT
      General announcement to all players.
    • ALERT

      public static final BroadcastType ALERT
      High-priority alert message.
    • MAINTENANCE

      public static final BroadcastType MAINTENANCE
      Maintenance notification.
    • CUSTOM

      public static final BroadcastType CUSTOM
      Custom/plugin-defined broadcast type. Used for extensibility when plugins need custom broadcast types.
  • Method Details

    • values

      public static BroadcastType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static BroadcastType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getId

      @Nonnull public String getId()
      Get the string identifier for this broadcast type.
      Returns:
      the type ID
    • fromId

      @Nullable public static BroadcastType fromId(@Nullable String id)
      Look up a broadcast type by its string ID.
      Parameters:
      id - the type ID
      Returns:
      the broadcast type, or null if not found
    • fromId

      @Nonnull public static BroadcastType fromId(@Nullable String id, @Nonnull BroadcastType defaultType)
      Look up a broadcast type by its string ID, with a default fallback.
      Parameters:
      id - the type ID
      defaultType - the default type if not found
      Returns:
      the broadcast type, or the default if not found
    • toString

      public String toString()
      Overrides:
      toString in class Enum<BroadcastType>