Interface DynamicRegistry<T>
- 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> @NotNull DynamicRegistry
<T> create
(@NotNull net.kyori.adventure.key.Key key) static <T> @NotNull DynamicRegistry
<T> Creates a new empty registry of the given type.static <T> @NotNull DynamicRegistry
<T> create
(@NotNull net.kyori.adventure.key.Key key, @NotNull Codec<T> codec, @Nullable Registries registries, RegistryData.Resource resource) Creates a new registry of the given type.static <T> @NotNull DynamicRegistry
<T> create
(@NotNull net.kyori.adventure.key.Key key, @NotNull 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> @NotNull DynamicRegistry
<T> create
(@NotNull net.kyori.adventure.key.Key key, @NotNull Codec<T> codec, RegistryData.Resource resource) Creates a new registry of the given type.static @NotNull DynamicRegistry
<Enchantment> createForEnchantmentsWithSelfReferentialLoadingNightmare
(@NotNull net.kyori.adventure.key.Key key, @NotNull Codec<Enchantment> codec, RegistryData.Resource resource, @NotNull Registries registries) static <T> @NotNull DynamicRegistry
<T> fromMap
(@NotNull net.kyori.adventure.key.Key key, Map.Entry<net.kyori.adventure.key.Key, T>... entries) default @NotNull RegistryKey
<T> Register an object to this registry, overwriting the previous entry if any is present.default @NotNull RegistryKey
<T> default @NotNull RegistryKey
<T> @NotNull RegistryKey
<T> @NotNull SendablePacket
registryDataPacket
(@NotNull Registries registries, boolean excludeVanilla) Returns aSendablePacket
potentially excluding vanilla entries if possible.boolean
remove
(@NotNull 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 @NotNull static <T> @NotNull DynamicRegistry<T> fromMap(@NotNull @NotNull net.kyori.adventure.key.Key key, @NotNull Map.Entry<net.kyori.adventure.key.Key, T>... entries) -
create
@Internal @NotNull static <T> @NotNull DynamicRegistry<T> create(@NotNull @NotNull net.kyori.adventure.key.Key key) -
create
@Internal @NotNull static <T> @NotNull DynamicRegistry<T> create(@NotNull @NotNull net.kyori.adventure.key.Key key, @NotNull @NotNull Codec<T> codec) Creates a new empty registry of the given type. Should only be used internally.- See Also:
-
create
@Internal @NotNull static <T> @NotNull DynamicRegistry<T> create(@NotNull @NotNull net.kyori.adventure.key.Key key, @NotNull @NotNull Codec<T> codec, @NotNull RegistryData.Resource resource) Creates a new registry of the given type. Should only be used internally.- See Also:
-
create
@Internal @NotNull static <T> @NotNull DynamicRegistry<T> create(@NotNull @NotNull net.kyori.adventure.key.Key key, @NotNull @NotNull Codec<T> codec, @Nullable @Nullable Registries registries, @NotNull RegistryData.Resource resource) Creates a new registry of the given type. Should only be used internally.- See Also:
-
create
@Internal @NotNull static <T> @NotNull DynamicRegistry<T> create(@NotNull @NotNull net.kyori.adventure.key.Key key, @NotNull @NotNull Codec<T> codec, @Nullable @Nullable Registries registries, @NotNull 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 @NotNull static @NotNull DynamicRegistry<Enchantment> createForEnchantmentsWithSelfReferentialLoadingNightmare(@NotNull @NotNull net.kyori.adventure.key.Key key, @NotNull @NotNull Codec<Enchantment> codec, @NotNull RegistryData.Resource resource, @NotNull @NotNull 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
@NotNull default @NotNull RegistryKey<T> register(@NotNull @NotNull net.kyori.adventure.key.Key id, @NotNull T object) -
register
@Internal @NotNull default @NotNull RegistryKey<T> register(@NotNull @NotNull String id, @NotNull T object, @Nullable @Nullable DataPack pack) -
register
@Internal @NotNull @NotNull RegistryKey<T> register(@NotNull @NotNull net.kyori.adventure.key.Key id, @NotNull T object, @Nullable @Nullable DataPack pack) -
remove
boolean remove(@NotNull @NotNull net.kyori.adventure.key.Key key) throws UnsupportedOperationException 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
@Internal @NotNull @NotNull SendablePacket registryDataPacket(@NotNull @NotNull Registries registries, boolean excludeVanilla) 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
-