Class Channels

java.lang.Object
me.internalizable.numdrassl.api.messaging.channel.Channels

public final class Channels extends Object
Registry of message channels with predefined system channels and custom channel support.

This class provides:

  • Predefined system channels (HEARTBEAT, CHAT, etc.)
  • Dynamic channel registration for plugins
  • Channel lookup by ID

Predefined Channels

Channels.HEARTBEAT  // numdrassl:heartbeat - Proxy health monitoring
Channels.PLAYER_COUNT // numdrassl:player-count - Player count updates
Channels.CHAT       // numdrassl:chat - Cross-proxy chat
Channels.TRANSFER   // numdrassl:transfer - Player transfers
Channels.PLUGIN     // numdrassl:plugin - Generic plugin messages
Channels.BROADCAST  // numdrassl:broadcast - Cluster-wide announcements

Custom Channels

// Register a custom channel for your plugin
MessageChannel myChannel = Channels.register("myplugin", "game-events");

// Use it for messaging
messaging.publish(myChannel, new PluginMessage(...));
messaging.subscribe(myChannel, handler);
  • Field Details

    • HEARTBEAT

      public static final MessageChannel HEARTBEAT
      Proxy heartbeat and registration. Used for proxy discovery and health monitoring.
    • PLAYER_COUNT

      public static final MessageChannel PLAYER_COUNT
      Player count updates. Proxies publish their current player count periodically.
    • CHAT

      public static final MessageChannel CHAT
      Cross-proxy chat messages. Used to send messages to players connected to other proxies.
    • TRANSFER

      public static final MessageChannel TRANSFER
      Player transfer coordination. Used when transferring players between proxies.
    • PLUGIN

      public static final MessageChannel PLUGIN
      Plugin-defined custom messages (generic). Plugins can use this channel for simple cross-proxy communication.
    • BROADCAST

      public static final MessageChannel BROADCAST
      Broadcast messages to all proxies. Used for cluster-wide announcements.
  • Method Details

    • register

      @Nonnull public static MessageChannel register(@Nonnull String namespace, @Nonnull String name)
      Register a custom message channel.

      The channel ID will be namespace:name. If a channel with this ID already exists, the existing channel is returned.

      Parameters:
      namespace - the namespace (typically your plugin ID)
      name - the channel name within the namespace
      Returns:
      the registered channel
      Throws:
      IllegalArgumentException - if namespace or name is invalid
    • register

      @Nonnull public static MessageChannel register(@Nonnull String channelId)
      Register a custom channel using full ID format.
      Parameters:
      channelId - the full channel ID (format: namespace:name)
      Returns:
      the registered channel
      Throws:
      IllegalArgumentException - if the ID format is invalid
    • get

      @Nullable public static MessageChannel get(@Nonnull String channelId)
      Get a channel by its ID.
      Parameters:
      channelId - the channel ID
      Returns:
      the channel, or null if not registered
    • getOrRegister

      @Nonnull public static MessageChannel getOrRegister(@Nonnull String channelId)
      Get a channel by its ID, registering it if not found.
      Parameters:
      channelId - the channel ID (format: namespace:name)
      Returns:
      the channel (existing or newly registered)
    • isRegistered

      public static boolean isRegistered(@Nonnull String channelId)
      Check if a channel is registered.
      Parameters:
      channelId - the channel ID
      Returns:
      true if registered
    • all

      @Nonnull public static Collection<MessageChannel> all()
      Get all registered channels.
      Returns:
      unmodifiable collection of all channels
    • unregister

      public static boolean unregister(@Nonnull String channelId)
      Unregister a custom channel.

      System channels (numdrassl:*) cannot be unregistered.

      Parameters:
      channelId - the channel ID to unregister
      Returns:
      true if the channel was unregistered