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 Summary
Modifier and TypeMethodDescriptionbooleanReturns whether a chat type is registered underkey.definition(Key key) Returns the definition registered underkey, if that chat type carries one.Returns every chat type defined by this server, vanilla overrides included.booleanReturns whetherkeymaps to a chat type defined by this server rather than a stock vanilla one.keys()Returns every registered chat type key, in network order.intReturns the network identifier ofkey, or-1if it is not registered.overwrite(ChatTypeDefinition definition) Registers a chat type, replacing any existing one sharing its key.default ChatTypeDefinitionregister(ChatTypeBuilder builder) Builds and registers a new chat type.register(ChatTypeDefinition definition) Registers a new chat type.registerFromJson(Key key, String json) Reads a chat type from its data pack JSON representation and registers it.intReturns the number of registered chat types.default booleanunregister(TypedKey<ChatType> key) Removes a chat type from the registry.booleanunregister(Key key) Removes a chat type from the registry.
-
Method Details
-
register
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; useoverwrite(ChatTypeDefinition)to replace it on purpose- Since:
- 0.1.0
-
register
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
Reads a chat type from its data pack JSON representation and registers it.- Parameters:
key- the key to register the chat type underjson- the JSON object describing the chat type- Returns:
- the registered definition
- Throws:
IllegalArgumentException- if the JSON is malformed or misses a mandatory fieldIllegalStateException- 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
Removes a chat type from the registry.- Parameters:
key- the key of the chat type to remove- Returns:
trueif a chat type was removed,falseif none was registered- Since:
- 0.1.0
-
unregister
-
definition
Returns the definition registered underkey, 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
Returns whether a chat type is registered underkey.- Parameters:
key- the chat type key- Returns:
- whether a chat type is registered under
key - Since:
- 0.1.0
-
isCustom
Returns whetherkeymaps to a chat type defined by this server rather than a stock vanilla one.- Parameters:
key- the chat type key- Returns:
- whether
keymaps to a chat type defined by this server rather than a stock vanilla one - Since:
- 0.1.0
-
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
Returns the network identifier ofkey, or-1if it is not registered.- Parameters:
key- the chat type key- Returns:
- the network identifier of
key, or-1if 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
-