Interface TagTemplate.Builder<T extends Taggable<T>>
-
- All Superinterfaces:
Buildable.Builder<TagTemplate>
,Builder<TagTemplate,TagTemplate.Builder<T>>
,ResettableBuilder<TagTemplate,TagTemplate.Builder<T>>
,ResourceKeyedBuilder<TagTemplate,TagTemplate.Builder<T>>
- Enclosing interface:
- TagTemplate
public static interface TagTemplate.Builder<T extends Taggable<T>> extends ResourceKeyedBuilder<TagTemplate,TagTemplate.Builder<T>>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default TagTemplate.Builder<T>
addChild(RegistryKey<Tag<T>> childTag)
Marks a tag with a givenRegistryKey
as a required child of the tag generated by this template.TagTemplate.Builder<T>
addChild(RegistryKey<Tag<T>> childTag, boolean required)
Marks a tag with a givenRegistryKey
as a child of the tag generated by this template.TagTemplate.Builder<T>
addChild(TagTemplate childTag)
Adds a child tag to this builder, using aTagTemplate
.default TagTemplate.Builder<T>
addChildren(Collection<RegistryKey<Tag<T>>> children)
Adds multiple required children to this template.TagTemplate.Builder<T>
addChildren(Collection<RegistryKey<Tag<T>>> children, boolean required)
Adds multiple children to this template.TagTemplate.Builder<T>
addChildren(Map<RegistryKey<Tag<T>>,Boolean> childrenMap)
Adds multiple required children to this template, where each key-value pair in this map represents a childResourceKey
and whether the child is required.default TagTemplate.Builder<T>
addValue(RegistryKey<T> value)
Adds theRegistryKey
for a value to the builder, marking it as required.TagTemplate.Builder<T>
addValue(RegistryKey<T> value, boolean required)
Adds theRegistryKey
for a value to the builder.default TagTemplate.Builder<T>
addValues(Collection<RegistryKey<T>> values)
Adds a collection ofRegistryKey
s for values to this builder, marking all as required.TagTemplate.Builder<T>
addValues(Collection<RegistryKey<T>> values, boolean required)
Adds a collection ofRegistryKey
s for values to this builder.@NonNull TagTemplate
build()
Creates aTagTemplate
that should be registered during theRegisterDataPackValueEvent
.default TagTemplate.Builder<T>
replace()
Indicates that any existing values of a tag with the sameResourceKeyed.key()
andTagType
during datapack (re)loading will have their values discarded and replaced by this template.TagTemplate.Builder<T>
replace(boolean replace)
Sets whether the values contained by a tag template will replace existing values if a tag with the sameResourceKeyed.key()
andTagType
already exists when datapacks are (re)loaded.-
Methods inherited from interface org.spongepowered.api.util.ResourceKeyedBuilder
key
-
-
-
-
Method Detail
-
replace
TagTemplate.Builder<T> replace(boolean replace)
Sets whether the values contained by a tag template will replace existing values if a tag with the sameResourceKeyed.key()
andTagType
already exists when datapacks are (re)loaded.If this is set to
true
, any previous entries for this given key-tag type combination will be discarded and the data in the built template will replace the data. If this is set tofalse
, the entries in this template will be merged with any existing data. The default behavior is to merge data.As no guarantees are made to the order in which templates are applied when datapacks are (re)loaded, note that replacement will only act upon templates that have previously been applied.
- Parameters:
replace
- Whether to replace instead of merge.- Returns:
- This builder, for chaining.
-
replace
default TagTemplate.Builder<T> replace()
Indicates that any existing values of a tag with the sameResourceKeyed.key()
andTagType
during datapack (re)loading will have their values discarded and replaced by this template.- Returns:
- This builder, for chaining
- See Also:
replace(boolean)
-
addValue
TagTemplate.Builder<T> addValue(RegistryKey<T> value, boolean required)
Adds theRegistryKey
for a value to the builder.As the objects that this tag will contain may be available at this stage, their
resource key ID
should be provided instead. However, this gives rise to the possibility that a value may not be available when tags are generated. The behavior during tag generation if the a value for the supplied key is not present can be controlled with the argument passed to therequired
parameter:- if
true
, the entire tag will not be applied. - if
false
, the tag will be applied without the value.
- Parameters:
value
- Value to addrequired
- Whether this tag should fail to load if the value is not found while loading.- Returns:
- This builder, for chaining
- if
-
addValue
default TagTemplate.Builder<T> addValue(RegistryKey<T> value)
Adds theRegistryKey
for a value to the builder, marking it as required.- Parameters:
value
- Value to add- Returns:
- This builder, for chaining
- See Also:
addValue(RegistryKey, boolean)
-
addValues
TagTemplate.Builder<T> addValues(Collection<RegistryKey<T>> values, boolean required)
Adds a collection ofRegistryKey
s for values to this builder.- Parameters:
values
- Values to addrequired
- Whether the values are required. If required, the tag will fail to load if they are not found while loading.- Returns:
- This builder, for chaining.
- See Also:
addValue(RegistryKey, boolean)
-
addValues
default TagTemplate.Builder<T> addValues(Collection<RegistryKey<T>> values)
Adds a collection ofRegistryKey
s for values to this builder, marking all as required.- Parameters:
values
- Values to add- Returns:
- This builder, for chaining.
- See Also:
addValue(RegistryKey, boolean)
-
addChild
TagTemplate.Builder<T> addChild(RegistryKey<Tag<T>> childTag, boolean required)
Marks a tag with a givenRegistryKey
as a child of the tag generated by this template.A child
Tag
is considered a subset of its parent, that is, the tag generated from this template will include all values from all its children, as well as those directly provided via the addValue(s) methods.As
Tag
s may not be available at this stage, theirResourceKeyed.key()
should be provided instead. If the key does not point to a valid tag (or tag template) when datapacks are reloaded, the argument supplied torequired
determines whether this tag is ultimately generated, that is, if the supplied child key does not represent a tag:- if
true
, no tag will be generated. - if
false
, a tag will be generated without the given child.
- Parameters:
childTag
-RegistryKey
for tag to be added.required
- Whether loading this tag should fail if the child tag is not found.- Returns:
- This builder, for chaining
- if
-
addChild
default TagTemplate.Builder<T> addChild(RegistryKey<Tag<T>> childTag)
Marks a tag with a givenRegistryKey
as a required child of the tag generated by this template.- Parameters:
childTag
-RegistryKey
for tag to be added.- Returns:
- This builder, for chaining
- See Also:
addChild(RegistryKey)
-
addChild
TagTemplate.Builder<T> addChild(TagTemplate childTag) throws IllegalArgumentException
Adds a child tag to this builder, using aTagTemplate
.- Parameters:
childTag
- The child to be added.- Returns:
- This builder, for chaining
- Throws:
IllegalArgumentException
- If this TagTemplate is not the sameTagType
as this builder.- See Also:
addChild(RegistryKey, boolean)
-
addChildren
TagTemplate.Builder<T> addChildren(Collection<RegistryKey<Tag<T>>> children, boolean required)
Adds multiple children to this template.- Parameters:
children
- Children to add.required
- Whether to fail loading the tag if these children are not found.- Returns:
- This builder, for chaining
- See Also:
addChild(RegistryKey, boolean)
-
addChildren
default TagTemplate.Builder<T> addChildren(Collection<RegistryKey<Tag<T>>> children)
Adds multiple required children to this template.- Parameters:
children
- Children to add.- Returns:
- This builder, for chaining
- See Also:
addChild(RegistryKey, boolean)
-
addChildren
TagTemplate.Builder<T> addChildren(Map<RegistryKey<Tag<T>>,Boolean> childrenMap)
Adds multiple required children to this template, where each key-value pair in this map represents a childResourceKey
and whether the child is required.- Parameters:
childrenMap
- Map of children, RegistryKey- Returns:
- This builder, for chaining.
- See Also:
addChild(RegistryKey, boolean)
-
build
@NonNull TagTemplate build()
Creates aTagTemplate
that should be registered during theRegisterDataPackValueEvent
.- Specified by:
build
in interfaceBuildable.Builder<T extends Taggable<T>>
- Returns:
- The built
TagTemplate
.
-
-