- Type Parameters:
T
- The type of the registry entries
- All Superinterfaces:
net.kyori.adventure.key.Keyed
,Registry<T>
Holds registry data for any of the registries controlled by the server. Entries in registries should be referenced
using a RegistryKey
object as opposed to the record type. For example, a biome should be stored as
`RegistryKey Biome`, as opposed to `Biome` directly.
Builtin registries should be accessed via a Registries
instance (currently implemented by
ServerProcess
, or from MinecraftServer
static methods.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> DynamicRegistry
<T> create
(net.kyori.adventure.key.Key key) static <T> DynamicRegistry
<T> Creates a new empty registry of the given type.static <T> DynamicRegistry
<T> create
(net.kyori.adventure.key.Key key, Codec<T> codec, @Nullable Registries registries, RegistryData.Resource resource) Creates a new registry of the given type.static <T> DynamicRegistry
<T> create
(net.kyori.adventure.key.Key key, Codec<T> codec, @Nullable Registries registries, RegistryData.Resource resource, @Nullable Comparator<String> idComparator, @Nullable Codec<T> readCodec) Creates a new registry of the given type.static <T> DynamicRegistry
<T> create
(net.kyori.adventure.key.Key key, Codec<T> codec, RegistryData.Resource resource) Creates a new registry of the given type.static DynamicRegistry
<Dialog> createForDialogWithSelfReferentialLoadingNightmare
(net.kyori.adventure.key.Key key, Codec<Dialog> codec, RegistryData.Resource resource, Registries registries) static DynamicRegistry
<Enchantment> createForEnchantmentsWithSelfReferentialLoadingNightmare
(net.kyori.adventure.key.Key key, Codec<Enchantment> codec, RegistryData.Resource resource, Registries registries) static <T> DynamicRegistry
<T> default RegistryKey
<T> Register an object to this registry, overwriting the previous entry if any is present.default RegistryKey
<T> default RegistryKey
<T> registryDataPacket
(Registries registries, boolean excludeVanilla) Returns aSendablePacket
potentially excluding vanilla entries if possible.boolean
remove
(net.kyori.adventure.key.Key key) Removes an object from this registry.Methods inherited from interface net.kyori.adventure.key.Keyed
key
-
Method Details
-
fromMap
@SafeVarargs static <T> DynamicRegistry<T> fromMap(net.kyori.adventure.key.Key key, Map.Entry<net.kyori.adventure.key.Key, T>... entries) -
create
-
create
Creates a new empty registry of the given type. Should only be used internally.- See Also:
-
create
@Internal static <T> DynamicRegistry<T> create(net.kyori.adventure.key.Key key, Codec<T> codec, RegistryData.Resource resource) Creates a new registry of the given type. Should only be used internally.- See Also:
-
create
@Internal static <T> DynamicRegistry<T> create(net.kyori.adventure.key.Key key, Codec<T> codec, @Nullable @Nullable Registries registries, RegistryData.Resource resource) Creates a new registry of the given type. Should only be used internally.- See Also:
-
create
@Internal static <T> DynamicRegistry<T> create(net.kyori.adventure.key.Key key, Codec<T> codec, @Nullable @Nullable Registries registries, RegistryData.Resource resource, @Nullable @Nullable Comparator<String> idComparator, @Nullable @Nullable Codec<T> readCodec) Creates a new registry of the given type. Should only be used internally.- See Also:
-
createForEnchantmentsWithSelfReferentialLoadingNightmare
@Internal static DynamicRegistry<Enchantment> createForEnchantmentsWithSelfReferentialLoadingNightmare(net.kyori.adventure.key.Key key, Codec<Enchantment> codec, RegistryData.Resource resource, Registries registries) -
createForDialogWithSelfReferentialLoadingNightmare
@Internal static DynamicRegistry<Dialog> createForDialogWithSelfReferentialLoadingNightmare(net.kyori.adventure.key.Key key, Codec<Dialog> codec, RegistryData.Resource resource, Registries registries) -
register
Register an object to this registry, overwriting the previous entry if any is present.
Note: the new registry will not be sent to existing players. They must be returned to the configuration phase to receive new registry data. See
Player.startConfigurationPhase()
.WARNING: Updating an existing entry is an inherently unsafe operation as it may cause desync with existing structures. This behavior is disabled by default, and must be enabled by setting the system property
minestom.registry.unsafe-ops
totrue
.- Parameters:
object
- The entry to register- Returns:
- The new ID of the registered object
-
register
-
register
-
register
@Internal RegistryKey<T> register(net.kyori.adventure.key.Key id, T object, @Nullable @Nullable DataPack pack) -
remove
Removes an object from this registry.
WARNING: This operation will cause all subsequent IDs to be remapped, meaning that any loaded entry with existing IDs may be incorrect. For example, loading a world with 0=plains, 1=desert, 2=badlands would store those IDs in the palette. If you then deleted entry 1 (desert), any desert biomes in the loaded world would become badlands, and any badlands would become invalid. This behavior is disabled by default, and must be enabled by setting the system property
minestom.registry.unsafe-ops
totrue
.Note: the new registry will not be sent to existing players. They must be returned to the configuration phase to receive new registry data. See
Player.startConfigurationPhase()
.- Parameters:
key
- The id of the entry to remove- Returns:
- True if the object was removed, false if it was not present
- Throws:
UnsupportedOperationException
- If the system propertyminestom.registry.unsafe-remove
is not set totrue
-
registryDataPacket
Returns a
SendablePacket
potentially excluding vanilla entries if possible. It is never possible to exclude vanilla entries if one has been overridden (e.g. viaregister(Key, T)
.- Parameters:
registries
- Registries providerexcludeVanilla
- Whether to exclude vanilla entries- Returns:
- A
SendablePacket
containing the registry data
-