Enum Class BroadcastType
- All Implemented Interfaces:
Serializable, Comparable<BroadcastType>, Constable
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);
// ...
}
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionHigh-priority alert message.General announcement to all players.Custom/plugin-defined broadcast type.Maintenance notification. -
Method Summary
Modifier and TypeMethodDescriptionstatic BroadcastTypeLook up a broadcast type by its string ID.static BroadcastTypefromId(String id, BroadcastType defaultType) Look up a broadcast type by its string ID, with a default fallback.getId()Get the string identifier for this broadcast type.toString()static BroadcastTypeReturns the enum constant of this class with the specified name.static BroadcastType[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
ANNOUNCEMENT
General announcement to all players. -
ALERT
High-priority alert message. -
MAINTENANCE
Maintenance notification. -
CUSTOM
Custom/plugin-defined broadcast type. Used for extensibility when plugins need custom broadcast types.
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
getId
Get the string identifier for this broadcast type.- Returns:
- the type ID
-
fromId
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 IDdefaultType- the default type if not found- Returns:
- the broadcast type, or the default if not found
-
toString
- Overrides:
toStringin classEnum<BroadcastType>
-