Repository: PaperMC/Paper
File: paper-api/src/main/java/org/bukkit/Registry.java (Java)

Code before:
    @Deprecated(since = "1.21.3") // Paper
    Registry<Biome> BIOME = legacyRegistryFor(Biome.class);
    /**
     * Server block types.
     *
     * @see BlockType
     */
    @ApiStatus.Experimental
    Registry<BlockType> BLOCK = registryFor(RegistryKey.BLOCK);
    /**
     * Custom boss bars.
     *
     * @see Bukkit#getBossBar(org.bukkit.NamespacedKey)
     * @see Bukkit#getBossBars()
     * @deprecated use {@link Bukkit#getBossBar(NamespacedKey)} and {@link Bukkit#getBossBars()}
     */
    @Deprecated(since = "1.21.4", forRemoval = true)
    Registry<KeyedBossBar> BOSS_BARS = new NotARegistry<>() {

        @Override
        public @Nullable KeyedBossBar get(final NamespacedKey key) {
            return Bukkit.getBossBar(key);
        }

        @Override
        public int size() {
            return Iterables.size(this);
        }

        @Override
        public Iterator<KeyedBossBar> iterator() {
            return Bukkit.getBossBars();
        }
    };
    /**
     * Server cat types.
     *
     * @see Cat.Type
     */
    Registry<Cat.Type> CAT_VARIANT = registryFor(RegistryKey.CAT_VARIANT);
    /**
     * Server enchantments.
     *
     * @see Enchantment
     * @deprecated use {@link RegistryAccess#getRegistry(RegistryKey)} with {@link RegistryKey#ENCHANTMENT}
     */
    @Deprecated(since = "1.21")
    Registry<Enchantment> ENCHANTMENT = legacyRegistryFor(Enchantment.class);
    /**
     * Server entity types.
     *

Review comment (performance):
This could probably just be a default method.

Like, by default we use Iterables.size and then override this for delegate, map based and internal reg.
It is 100% fine for the deprecated registries to be a bit slower like this.

Code after:
     * @see BlockType
     */
    @ApiStatus.Experimental
    Registry<BlockType> BLOCK = registryFor(RegistryKey.BLOCK);
    /**
     * Custom boss bars.
     *
     * @see Bukkit#getBossBar(org.bukkit.NamespacedKey)
     * @see Bukkit#getBossBars()
     * @deprecated use {@link Bukkit#getBossBar(NamespacedKey)} and {@link Bukkit#getBossBars()}
     */
    @Deprecated(since = "1.21.4", forRemoval = true)
    Registry<KeyedBossBar> BOSS_BARS = new NotARegistry<>() {

        @Override
        public @Nullable KeyedBossBar get(final NamespacedKey key) {
            return Bukkit.getBossBar(key);
        }

        @Override
        public Iterator<KeyedBossBar> iterator() {
            return Bukkit.getBossBars();
        }
    };
    /**
     * Server cat types.
     *
     * @see Cat.Type
     */
    Registry<Cat.Type> CAT_VARIANT = registryFor(RegistryKey.CAT_VARIANT);
    /**
     * Server enchantments.
     *
     * @see Enchantment
     * @deprecated use {@link RegistryAccess#getRegistry(RegistryKey)} with {@link RegistryKey#ENCHANTMENT}
     */
    @Deprecated(since = "1.21")
    Registry<Enchantment> ENCHANTMENT = legacyRegistryFor(Enchantment.class);
    /**
     * Server entity types.
     *
     * @see EntityType
     */
    Registry<EntityType> ENTITY_TYPE = registryFor(RegistryKey.ENTITY_TYPE);
    /**
     * Server instruments.
     *
     * @see MusicInstrument
     * @deprecated use {@link RegistryAccess#getRegistry(RegistryKey)} with {@link RegistryKey#INSTRUMENT}
     */
    @Deprecated(since = "1.21.2")