Interface WritableRegistry<T>
- Type Parameters:
T- the type of the values
- All Superinterfaces:
Registry<T>
A registry plugins can add entries to, on top of the vanilla ones.
Vanilla entries always stay registered: they can be replaced, and come back once the replacement is unregistered. Registries sent to clients should be changed while plugins load: a change once players are connected sends them back to the configuration phase.
- Since:
- 0.1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds an entry to a tag, creating the tag if needed.Registers an entry, replacing any existing one under the same key, vanilla ones included.Registers a new entry.default TRegisters a new entry under the key the value carries.registerFromJson(TypedKey<T> key, String json, Plugin owner) Reads an entry from its data pack JSON representation and registers it.booleanRemoves an entry from a tag.booleanunregister(TypedKey<T> key) Removes an entry added by a plugin, or restores the vanilla value of a replaced one.voidunregisterAll(Plugin owner) Removes every entry a plugin added, and restores every vanilla value it replaced.
-
Method Details
-
register
Registers a new entry.- Parameters:
key- the key to register it undervalue- the valueowner- the plugin registering it- Returns:
value- Throws:
IllegalStateException- if something is already registered underkey; useoverwrite(TypedKey, Object, Plugin)to replace itIllegalArgumentException- if the value is invalid, or carries a key other thankey- Since:
- 0.1.0
-
register
Registers a new entry under the key the value carries.- Parameters:
value- the value, carrying its keyowner- the plugin registering it- Returns:
value- Throws:
IllegalArgumentException- if the value does not carry its key, or is invalidIllegalStateException- if something is already registered under its key- Since:
- 0.1.0
-
registerFromJson
Reads an entry from its data pack JSON representation and registers it.- Parameters:
key- the key to register it underjson- the JSON, as found in a data packowner- the plugin registering it- Returns:
- the registered value
- Throws:
IllegalArgumentException- if the JSON is malformed or invalidIllegalStateException- if something is already registered underkey- Since:
- 0.1.0
-
overwrite
Registers an entry, replacing any existing one under the same key, vanilla ones included.- Parameters:
key- the key to register it undervalue- the valueowner- the plugin registering it- Returns:
- the value previously registered under that key, if any
- Throws:
IllegalArgumentException- if the value is invalid, or carries a key other thankey- Since:
- 0.1.0
-
unregister
-
unregisterAll
Removes every entry a plugin added, and restores every vanilla value it replaced.- Parameters:
owner- the plugin- Since:
- 0.1.0
-
addToTag
Adds an entry to a tag, creating the tag if needed.- Parameters:
tag- the tagkey- the key of the entryowner- the plugin registering it- Returns:
trueif the entry was added,falseif it already belonged to the tag- Throws:
IllegalArgumentException- if nothing is registered underkey- Since:
- 0.1.0
-
removeFromTag
-