Class MutableRegistry.SimpleMutableRegistry<T extends org.bukkit.Keyed>

java.lang.Object
me.deecaad.core.utils.MutableRegistry.SimpleMutableRegistry<T>
Type Parameters:
T - the type of the entries in the registry
All Implemented Interfaces:
Iterable<T>, MutableRegistry<T>, org.bukkit.Registry<T>
Enclosing interface:
MutableRegistry<T extends org.bukkit.Keyed>

public static final class MutableRegistry.SimpleMutableRegistry<T extends org.bukkit.Keyed> extends Object implements MutableRegistry<T>
A simple implementation of MutableRegistry, backed by a hash map.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface me.deecaad.core.utils.MutableRegistry

    MutableRegistry.SimpleMutableRegistry<T extends org.bukkit.Keyed>

    Nested classes/interfaces inherited from interface org.bukkit.Registry

    org.bukkit.Registry.NotARegistry<A extends org.bukkit.Keyed>, org.bukkit.Registry.SimpleRegistry<T extends Enum<T> & org.bukkit.Keyed>
  • Field Summary

    Fields inherited from interface org.bukkit.Registry

    ADVANCEMENT, ART, ATTRIBUTE, BANNER_PATTERN, BIOME, BLOCK, BOSS_BARS, CAT_VARIANT, DAMAGE_TYPE, DATA_COMPONENT_TYPE, EFFECT, ENCHANTMENT, ENTITY_TYPE, FLUID, FROG_VARIANT, GAME_EVENT, GAME_RULE, INSTRUMENT, ITEM, JUKEBOX_SONG, LOOT_TABLES, MAP_DECORATION_TYPE, MATERIAL, MEMORY_MODULE_TYPE, MENU, MOB_EFFECT, PARTICLE_TYPE, POTION, POTION_EFFECT_TYPE, SOUND_EVENT, SOUNDS, STATISTIC, STRUCTURE, STRUCTURE_TYPE, TRIM_MATERIAL, TRIM_PATTERN, VILLAGER_PROFESSION, VILLAGER_TYPE, WOLF_VARIANT
  • Constructor Summary

    Constructors
    Constructor
    Description
    SimpleMutableRegistry(@NotNull Map<org.bukkit.NamespacedKey,T> entries)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(T entry)
    Tries to add the given entry to the registry.
    get(@NotNull org.bukkit.NamespacedKey namespacedKey)
     
    @Nullable org.bukkit.NamespacedKey
    getKey(T value)
     
    getOrThrow(@NotNull org.bukkit.NamespacedKey namespacedKey)
     
    io.papermc.paper.registry.tag.Tag<T>
    getTag(io.papermc.paper.registry.tag.TagKey<T> key)
     
    Collection<io.papermc.paper.registry.tag.Tag<T>>
     
    boolean
    hasTag(@NotNull io.papermc.paper.registry.tag.TagKey<T> key)
     
    @NotNull Iterator<T>
     
    Stream<org.bukkit.NamespacedKey>
    Returns a new stream, which contains all registry keys, which are registered to the registry.
    void
    overwrite(T entry)
    Adds (or, if it already exists, overwrites) the given entry to the registry.
    int
    Gets the size of the registry.
    @NotNull Stream<T>
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator

    Methods inherited from interface org.bukkit.Registry

    get, get, getKeyOrThrow, getOrThrow, getOrThrow, getTagValues, match
  • Constructor Details

    • SimpleMutableRegistry

      public SimpleMutableRegistry(@NotNull @NotNull Map<org.bukkit.NamespacedKey,T> entries)
  • Method Details

    • get

      @Nullable public T get(@NotNull @NotNull org.bukkit.NamespacedKey namespacedKey)
      Specified by:
      get in interface org.bukkit.Registry<T extends org.bukkit.Keyed>
    • getKey

      @Nullable public @Nullable org.bukkit.NamespacedKey getKey(T value)
      Specified by:
      getKey in interface org.bukkit.Registry<T extends org.bukkit.Keyed>
    • hasTag

      public boolean hasTag(@NotNull @NotNull io.papermc.paper.registry.tag.TagKey<T> key)
      Specified by:
      hasTag in interface org.bukkit.Registry<T extends org.bukkit.Keyed>
    • getTag

      public io.papermc.paper.registry.tag.Tag<T> getTag(io.papermc.paper.registry.tag.TagKey<T> key)
      Specified by:
      getTag in interface org.bukkit.Registry<T extends org.bukkit.Keyed>
    • getTags

      public Collection<io.papermc.paper.registry.tag.Tag<T>> getTags()
      Specified by:
      getTags in interface org.bukkit.Registry<T extends org.bukkit.Keyed>
    • getOrThrow

      @NotNull public T getOrThrow(@NotNull @NotNull org.bukkit.NamespacedKey namespacedKey)
      Specified by:
      getOrThrow in interface org.bukkit.Registry<T extends org.bukkit.Keyed>
    • stream

      @NotNull public @NotNull Stream<T> stream()
      Specified by:
      stream in interface org.bukkit.Registry<T extends org.bukkit.Keyed>
    • keyStream

      public Stream<org.bukkit.NamespacedKey> keyStream()
      Returns a new stream, which contains all registry keys, which are registered to the registry.
      Specified by:
      keyStream in interface org.bukkit.Registry<T extends org.bukkit.Keyed>
      Returns:
      a stream of all registry keys
    • size

      public int size()
      Gets the size of the registry.
      Specified by:
      size in interface org.bukkit.Registry<T extends org.bukkit.Keyed>
      Returns:
      the size of the registry
    • iterator

      @NotNull public @NotNull Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T extends org.bukkit.Keyed>
    • add

      public void add(@NotNull T entry) throws DuplicateRegistryValueException
      Description copied from interface: MutableRegistry
      Tries to add the given entry to the registry. If the entry already exists, a DuplicateRegistryValueException is thrown.
      Specified by:
      add in interface MutableRegistry<T extends org.bukkit.Keyed>
      Parameters:
      entry - the entry to add
      Throws:
      DuplicateRegistryValueException - if the entry already exists
    • overwrite

      public void overwrite(@NotNull T entry)
      Description copied from interface: MutableRegistry
      Adds (or, if it already exists, overwrites) the given entry to the registry.
      Specified by:
      overwrite in interface MutableRegistry<T extends org.bukkit.Keyed>
      Parameters:
      entry - the entry to add