Package org.geysermc.geyser.registry
Class ArrayRegistry<M>
java.lang.Object
org.geysermc.geyser.registry.Registry<M[]>
org.geysermc.geyser.registry.ArrayRegistry<M>
- Type Parameters:
M
- the mapping type
An array registry that stores mappings as an array defined by
ArrayRegistry
.
The M represents the value that is to be stored as part of this array.-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
ArrayRegistry(I input, RegistryLoader<I,M[]> registryLoader)
Creates a new array registry of this class with the given input andRegistryLoader
. -
Method Summary
Modifier and TypeMethodDescriptionstatic <I, M> ArrayRegistry<M>
create(I input, Supplier<RegistryLoader<I,M[]>> registryLoader)
Creates a new array registry with the givenRegistryLoader
supplier and input.static <I, M> ArrayRegistry<M>
create(I input, RegistryLoader<I,M[]> registryLoader)
Creates a new array registry with the givenRegistryLoader
and input.static <I, M> ArrayRegistry<M>
create(Supplier<RegistryLoader<I,M[]>> registryLoader)
Creates a new array registry with the givenRegistryLoader
supplier.static <I, M> ArrayRegistry<M>
create(RegistryLoader<I,M[]> registryLoader)
Creates a new array registry with the givenRegistryLoader
.get(int index)
Returns the value registered by the given index.getOrDefault(int index, M defaultValue)
Returns the value registered by the given index or the default value specified if null.Registers a new value into this registry with the given index.
-
Constructor Details
-
ArrayRegistry
Creates a new array registry of this class with the given input andRegistryLoader
. The input specified is what the registry loader needs to take in.- Parameters:
input
- the inputregistryLoader
- the registry loader
-
-
Method Details
-
get
Returns the value registered by the given index.- Parameters:
index
- the index- Returns:
- the value registered by the given index.
-
getOrDefault
Returns the value registered by the given index or the default value specified if null.- Parameters:
index
- the indexdefaultValue
- the default value- Returns:
- the value registered by the given key or the default value specified if null.
-
register
Registers a new value into this registry with the given index.- Parameters:
index
- the indexvalue
- the value- Returns:
- a new value into this registry with the given index.
-
create
Creates a new array registry with the givenRegistryLoader
supplier. The input type is not specified here, meaning the loader return type is either predefined, or the registry is populated at a later point.- Type Parameters:
I
- the input typeM
- the returned mappings type- Parameters:
registryLoader
- the registry loader supplier- Returns:
- a new registry with the given RegistryLoader supplier
-
create
public static <I, M> ArrayRegistry<M> create(I input, Supplier<RegistryLoader<I,M[]>> registryLoader)Creates a new array registry with the givenRegistryLoader
supplier and input.- Type Parameters:
I
- the input typeM
- the returned mappings type- Parameters:
input
- the inputregistryLoader
- the registry loader supplier- Returns:
- a new registry with the given RegistryLoader supplier
-
create
Creates a new array registry with the givenRegistryLoader
. The input type is not specified here, meaning the loader return type is either predefined, or the registry is populated at a later point.- Type Parameters:
I
- the input typeM
- the returned mappings type- Parameters:
registryLoader
- the registry loader- Returns:
- a new registry with the given RegistryLoader supplier
-
create
Creates a new array registry with the givenRegistryLoader
and input.- Type Parameters:
I
- the input typeM
- the returned mappings type- Parameters:
input
- the inputregistryLoader
- the registry loader- Returns:
- a new registry with the given RegistryLoader supplier
-