Interface DynamicRegistry<T>

Type Parameters:
T - The type of the registry entries
All Superinterfaces:
net.kyori.adventure.key.Keyed, Registry<T>

public sealed interface DynamicRegistry<T> extends 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 Details

    • fromMap

      @SafeVarargs static <T> DynamicRegistry<T> fromMap(net.kyori.adventure.key.Key key, Map.Entry<net.kyori.adventure.key.Key,T>... entries)
    • create

      @Internal static <T> DynamicRegistry<T> create(net.kyori.adventure.key.Key key)
    • create

      @Internal static <T> DynamicRegistry<T> create(net.kyori.adventure.key.Key key, Codec<T> codec)
      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

      default RegistryKey<T> register(String id, T object)

      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 to true.

      Parameters:
      object - The entry to register
      Returns:
      The new ID of the registered object
    • register

      default RegistryKey<T> register(net.kyori.adventure.key.Key id, T object)
    • register

      @Internal default RegistryKey<T> register(String id, T object, @Nullable @Nullable DataPack pack)
    • register

      @Internal RegistryKey<T> register(net.kyori.adventure.key.Key id, T object, @Nullable @Nullable DataPack pack)
    • remove

      boolean remove(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 to true.

      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 property minestom.registry.unsafe-remove is not set to true
    • registryDataPacket

      @Internal SendablePacket registryDataPacket(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. via register(Key, T).

      Parameters:
      registries - Registries provider
      excludeVanilla - Whether to exclude vanilla entries
      Returns:
      A SendablePacket containing the registry data