Class SimpleJavaRegistry<T>
- All Implemented Interfaces:
Iterable<T>,JavaRegistry<T>,JavaRegistryLookup<T>,MutableJavaRegistry<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbind(IntFunction<T> binder) Binds this registry, if there were any unbound entries.voidclear()Clears this registry.voidforEachEntry(Consumer<RegistryEntryData<T>> action) Iteratesactionfor eachRegistryEntryDataof this registry.voidfreeze()Freezes this registry, if it was not frozen already.get(int networkId) Gets theJavaRegistryLookupfor the givennetworkIdin this registry, or returns an empty optional if it didn't exist.get(net.kyori.adventure.key.Key key) Gets theJavaRegistryLookupfor the givenkeyin this registry, or returns an empty optional if it didn't exist.getById(int networkId) Gets theRegistryEntryDatafor the givennetworkIdin this registry, or returns an empty optional if it didn't exist.getByKey(net.kyori.adventure.key.Key key) Gets theRegistryEntryDatafor the givenkeyin this registry, or returns an empty optional if it didn't exist.getByValue(T object) Gets theRegistryEntryDatafor the givenobjectin this registry, or returns an empty optional if it didn't exist.iterator()Collection<net.kyori.adventure.key.Key> keys()Returns a collection of all keys in this registry.voidregister(RegistryEntryData<T> entry) Adds a new entry to this registry.intsize()toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.geysermc.geyser.registry.java.JavaRegistry
isEmpty, parallelStream, spliterator, streamMethods inherited from interface org.geysermc.geyser.registry.java.JavaRegistryLookup
getId, getId, getIdOrThrow, getIdOrThrow, getKey, getKey, getKeyOrThrow, getKeyOrThrow, getOrThrow, getOrThrowMethods inherited from interface org.geysermc.geyser.registry.java.MutableJavaRegistry
register, register, register, register
-
Constructor Details
-
SimpleJavaRegistry
-
-
Method Details
-
get
Description copied from interface:JavaRegistryLookupGets theJavaRegistryLookupfor the givennetworkIdin this registry, or returns an empty optional if it didn't exist.- Specified by:
getin interfaceJavaRegistryLookup<T>- Parameters:
networkId- the network ID to look up- Returns:
- the
JavaRegistryLookupcorrelating to the network ID, or an empty optional if it didn't exist
-
get
Description copied from interface:JavaRegistryLookupGets theJavaRegistryLookupfor the givenkeyin this registry, or returns an empty optional if it didn't exist.- Specified by:
getin interfaceJavaRegistryLookup<T>- Parameters:
key- the key to look up- Returns:
- the
JavaRegistryLookupcorrelating to the key, or an empty optional if it didn't exist
-
getById
Description copied from interface:JavaRegistryLookupGets theRegistryEntryDatafor the givennetworkIdin this registry, or returns an empty optional if it didn't exist.- Specified by:
getByIdin interfaceJavaRegistryLookup<T>- Parameters:
networkId- the network ID to look up- Returns:
- the
RegistryEntryDatacorrelating to the network ID, or an empty optional if it didn't exist
-
getByKey
Description copied from interface:JavaRegistryLookupGets theRegistryEntryDatafor the givenkeyin this registry, or returns an empty optional if it didn't exist.- Specified by:
getByKeyin interfaceJavaRegistryLookup<T>- Parameters:
key- the key to look up- Returns:
- the
RegistryEntryDatacorrelating to the key, or an empty optional if it didn't exist
-
getByValue
Description copied from interface:JavaRegistryLookupGets theRegistryEntryDatafor the givenobjectin this registry, or returns an empty optional if it didn't exist.- Specified by:
getByValuein interfaceJavaRegistryLookup<T>- Parameters:
object- the object to look up- Returns:
- the
RegistryEntryDatacorrelating to the object, or an empty optional if it didn't exist
-
keys
Description copied from interface:JavaRegistryReturns a collection of all keys in this registry.Note that this collection may not necessarily be sorted by network ID.
- Specified by:
keysin interfaceJavaRegistry<T>- Returns:
- a collection of all keys in this registry
-
size
public int size()- Specified by:
sizein interfaceJavaRegistry<T>- Returns:
- the amount of entries in this registry
-
register
Description copied from interface:MutableJavaRegistryAdds a new entry to this registry.- Specified by:
registerin interfaceMutableJavaRegistry<T>- Parameters:
entry- the entry to add
-
clear
public void clear()Description copied from interface:MutableJavaRegistryClears this registry. All entries will be wiped, and the registry will be mutable again, if it was frozen.- Specified by:
clearin interfaceMutableJavaRegistry<T>
-
freeze
public void freeze()Description copied from interface:MutableJavaRegistryFreezes this registry, if it was not frozen already.If all entries were bound at the time of registering, then
MutableJavaRegistry.bind(IntFunction)is automatically called with a no-op binder, ensuring this registry is bound and fully functional.If the registry was already frozen, this method does nothing.
- Specified by:
freezein interfaceMutableJavaRegistry<T>- See Also:
-
bind
Description copied from interface:MutableJavaRegistryBinds this registry, if there were any unbound entries. The registry must be frozen before binding it.This method uses the given
IntFunctionto bind all unbound registry entries. As a result, after calling this method, all registry entries should be bound.The
IntFunctionis given a network ID, and it is expected to return aMutableJavaRegistryfor that respective network ID. If it returnsnull, aNullPointerExceptionis thrown.If the registry was already bound, this method does nothing. If the binder throws a
RuntimeException, the exception will be caught, and this method will silently return. The registry will be left unbound.- Specified by:
bindin interfaceMutableJavaRegistry<T>- Parameters:
binder- the function used to bind unbound registry entries- See Also:
-
forEachEntry
Description copied from interface:JavaRegistryIteratesactionfor eachRegistryEntryDataof this registry.The action is executed in order of network ID.
- Specified by:
forEachEntryin interfaceJavaRegistry<T>- Parameters:
action- the action to execute for eachRegistryEntryData
-
iterator
-
toString
-