Interface VariableValueParameters.RegistryEntryBuilder<T>
-
- All Superinterfaces:
AbstractBuilder<ValueParameter<T>>
,Buildable.Builder<ValueParameter<T>>
,Builder<ValueParameter<T>,VariableValueParameters.RegistryEntryBuilder<T>>
,ResettableBuilder<ValueParameter<T>,VariableValueParameters.RegistryEntryBuilder<T>>
- Enclosing class:
- VariableValueParameters
public static interface VariableValueParameters.RegistryEntryBuilder<T> extends Builder<ValueParameter<T>,VariableValueParameters.RegistryEntryBuilder<T>>
A builder that creates aValueParameter
that attempts to get a specificregistry
entry by the supplied ID.
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.function.Function<CommandContext,@Nullable RegistryHolder>
GLOBAL_HOLDER_PROVIDER
static java.util.function.Function<CommandContext,@Nullable RegistryHolder>
SERVER_HOLDER_PROVIDER
static java.util.function.Function<CommandContext,@Nullable RegistryHolder>
WORLD_FROM_CAUSE_HOLDER_PROVIDER
AFunction
that always provides theWorld
scopedRegistryHolder
from the firstServerWorld
in the providedCommandContext
.static java.util.function.Function<CommandContext,@Nullable RegistryHolder>
WORLD_FROM_LOCATABLE_HOLDER_PROVIDER
AFunction
that always provides theWorld
scopedRegistryHolder
from the firstLocatable
in the providedCommandContext
.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description VariableValueParameters.RegistryEntryBuilder<T>
addHolderFunction(java.util.function.Function<CommandContext,@Nullable RegistryHolder> holderFunction)
Adds an alternative function that retrieves aRegistryHolder
to attempt to get the selectedRegistryType
.ValueParameter<T>
build()
Tests for validity and creates thisValueParameter
VariableValueParameters.RegistryEntryBuilder<T>
defaultNamespace(java.lang.String prefix)
Adds a prefix that could be prepended to the input argument if it initially does not match any of the chosenRegistryKey
s.
-
-
-
Field Detail
-
GLOBAL_HOLDER_PROVIDER
static final java.util.function.Function<CommandContext,@Nullable RegistryHolder> GLOBAL_HOLDER_PROVIDER
-
SERVER_HOLDER_PROVIDER
static final java.util.function.Function<CommandContext,@Nullable RegistryHolder> SERVER_HOLDER_PROVIDER
-
WORLD_FROM_LOCATABLE_HOLDER_PROVIDER
static final java.util.function.Function<CommandContext,@Nullable RegistryHolder> WORLD_FROM_LOCATABLE_HOLDER_PROVIDER
AFunction
that always provides theWorld
scopedRegistryHolder
from the firstLocatable
in the providedCommandContext
.
-
WORLD_FROM_CAUSE_HOLDER_PROVIDER
static final java.util.function.Function<CommandContext,@Nullable RegistryHolder> WORLD_FROM_CAUSE_HOLDER_PROVIDER
AFunction
that always provides theWorld
scopedRegistryHolder
from the firstServerWorld
in the providedCommandContext
.
-
-
Method Detail
-
addHolderFunction
VariableValueParameters.RegistryEntryBuilder<T> addHolderFunction(java.util.function.Function<CommandContext,@Nullable RegistryHolder> holderFunction)
Adds an alternative function that retrieves aRegistryHolder
to attempt to get the selectedRegistryType
.The order that these functions are added determines their priority if there are multiple registries, specifically, the first function that is provided will have the highest priority.
Standard functions are available on
VariableValueParameters.RegistryEntryBuilder
.- Parameters:
holderFunction
- The holder function- Returns:
- This, for chaining
-
defaultNamespace
VariableValueParameters.RegistryEntryBuilder<T> defaultNamespace(java.lang.String prefix)
Adds a prefix that could be prepended to the input argument if it initially does not match any of the chosenRegistryKey
s. Any prefixes that are prepended will include the ":" identifier, this should not be part of the supplied prefix in this method.Consider the following example. Assume that we have a catalog type that this element targets with the following IDs currently registered:
- sponge:test
- minecraft:test
- test:test
Now consider that the argument "test:test" is passed (with any capitalization thereof). It's an exact match, so there is no bother, it's returned by the parameter.
Then consider that the argument "test" is passed - this is NOT an exact match. Without specifying any prefixes - this parameter will fail to parse the argument. Sometimes, this isn't desired, and plugins will want to allow players to not have to specify a prefix. So, if the prefix "sponge" is specified here, then "test" will match "sponge:test".
Multiple prefixes can be specified. They will be tested in order - in the example above, if the following is specified:
prefix("sponge").prefix("minecraft").prefix("test")
then if the argument "test" is passed to the parameter, it will check "test", "sponge:test", "minecraft:test" then "test:test". In the above example, this would match "sponge:test" and return that element.
- Parameters:
prefix
- The prefix, without the ":" suffix, to add to the argument if the parameter fails to find a catalog type without such a prefix- Returns:
- This builder, for chaining.
-
build
ValueParameter<T> build()
Tests for validity and creates thisValueParameter
- Specified by:
build
in interfaceAbstractBuilder<T>
- Specified by:
build
in interfaceBuildable.Builder<T>
- Returns:
- The
ValueParameter
-
-