Interface ChatTypeRegistry


public interface ChatTypeRegistry
Server-wide registry of chat types, holding both the vanilla ones and those added by plugins.
Since:
0.1.0
  • Method Details

    • register

      @Contract("_ -> param1") ChatTypeDefinition register(ChatTypeDefinition definition)
      Registers a new chat type.
      Parameters:
      definition - the chat type to add
      Returns:
      the registered definition
      Throws:
      IllegalStateException - if a chat type is already registered under the same key; use overwrite(ChatTypeDefinition) to replace it on purpose
      Since:
      0.1.0
    • register

      default ChatTypeDefinition register(ChatTypeBuilder builder)
      Builds and registers a new chat type.
      Parameters:
      builder - the builder describing the chat type
      Returns:
      the registered definition
      Throws:
      IllegalStateException - if a chat type is already registered under the same key
      Since:
      0.1.0
    • registerFromJson

      ChatTypeDefinition registerFromJson(Key key, String json)
      Reads a chat type from its data pack JSON representation and registers it.
      Parameters:
      key - the key to register the chat type under
      json - the JSON object describing the chat type
      Returns:
      the registered definition
      Throws:
      IllegalArgumentException - if the JSON is malformed or misses a mandatory field
      IllegalStateException - if a chat type is already registered under the same key
      Since:
      0.1.0
    • overwrite

      Registers a chat type, replacing any existing one sharing its key.
      Parameters:
      definition - the chat type to add or replace
      Returns:
      the definition previously registered under that key, if any
      Since:
      0.1.0
    • unregister

      boolean unregister(Key key)
      Removes a chat type from the registry.
      Parameters:
      key - the key of the chat type to remove
      Returns:
      true if a chat type was removed, false if none was registered
      Since:
      0.1.0
    • unregister

      default boolean unregister(TypedKey<ChatType> key)
      Removes a chat type from the registry.
      Parameters:
      key - the typed key of the chat type to remove
      Returns:
      true if a chat type was removed, false if none was registered
      Since:
      0.1.0
    • definition

      Optional<ChatTypeDefinition> definition(Key key)
      Returns the definition registered under key, if that chat type carries one.
      Parameters:
      key - the chat type key
      Returns:
      the definition registered under key, if that chat type carries one
      Since:
      0.1.0
    • contains

      boolean contains(Key key)
      Returns whether a chat type is registered under key.
      Parameters:
      key - the chat type key
      Returns:
      whether a chat type is registered under key
      Since:
      0.1.0
    • isCustom

      boolean isCustom(Key key)
      Returns whether key maps to a chat type defined by this server rather than a stock vanilla one.
      Parameters:
      key - the chat type key
      Returns:
      whether key maps to a chat type defined by this server rather than a stock vanilla one
      Since:
      0.1.0
    • keys

      @Contract(pure=true) Collection<Key> keys()
      Returns every registered chat type key, in network order.
      Returns:
      every registered chat type key, in network order
      Since:
      0.1.0
    • definitions

      Returns every chat type defined by this server, vanilla overrides included.
      Returns:
      every chat type defined by this server, vanilla overrides included
      Since:
      0.1.0
    • networkId

      int networkId(Key key)
      Returns the network identifier of key, or -1 if it is not registered.
      Parameters:
      key - the chat type key
      Returns:
      the network identifier of key, or -1 if it is not registered
      Since:
      0.1.0
    • totalRegistered

      int totalRegistered()
      Returns the number of registered chat types.
      Returns:
      the number of registered chat types
      Since:
      0.1.0