Interface VariableValueParameters.RegistryEntryBuilder<T>
- All Superinterfaces:
AbstractBuilder<ValueParameter<T>>
,Builder<ValueParameter<T>,
,VariableValueParameters.RegistryEntryBuilder<T>> ResettableBuilder<ValueParameter<T>,
VariableValueParameters.RegistryEntryBuilder<T>>
- Enclosing class:
- VariableValueParameters
ValueParameter
that attempts to get a
specific registry
entry by the supplied ID.-
Field Summary
Modifier and TypeFieldDescriptionstatic final Function<CommandContext,
@Nullable RegistryHolder> static final Function<CommandContext,
@Nullable RegistryHolder> static final Function<CommandContext,
@Nullable RegistryHolder> AFunction
that always provides theWorld
scopedRegistryHolder
from the firstServerWorld
in the providedCommandContext
.static final Function<CommandContext,
@Nullable RegistryHolder> AFunction
that always provides theWorld
scopedRegistryHolder
from the firstLocatable
in the providedCommandContext
. -
Method Summary
Modifier and TypeMethodDescriptionaddHolderFunction
(Function<CommandContext, @Nullable RegistryHolder> holderFunction) Adds an alternative function that retrieves aRegistryHolder
to attempt to get the selectedRegistryType
.build()
Tests for validity and creates thisValueParameter
defaultNamespace
(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 Details
-
GLOBAL_HOLDER_PROVIDER
-
SERVER_HOLDER_PROVIDER
-
WORLD_FROM_LOCATABLE_HOLDER_PROVIDER
AFunction
that always provides theWorld
scopedRegistryHolder
from the firstLocatable
in the providedCommandContext
. -
WORLD_FROM_CAUSE_HOLDER_PROVIDER
AFunction
that always provides theWorld
scopedRegistryHolder
from the firstServerWorld
in the providedCommandContext
.
-
-
Method Details
-
addHolderFunction
VariableValueParameters.RegistryEntryBuilder<T> addHolderFunction(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
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>
- Returns:
- The
ValueParameter
-