Interface TagTemplate.Builder<T extends Taggable<T>>
- All Superinterfaces:
AbstractBuilder<TagTemplate<T>>,Builder<TagTemplate<T>,,TagTemplate.Builder<T>> ResettableBuilder<TagTemplate<T>,,TagTemplate.Builder<T>> ResourceKeyedBuilder<TagTemplate<T>,TagTemplate.Builder<T>>
- Enclosing interface:
TagTemplate<T extends Taggable<T>>
-
Method Summary
Modifier and TypeMethodDescriptiondefault TagTemplate.Builder<T> Marks a tag with a givenRegistryKeyas a required child of the tag generated by this template.Marks a tag with a givenRegistryKeyas a child of the tag generated by this template.addChild(TagTemplate<T> childTag) Adds a child tag to this builder, using aTagTemplate.default TagTemplate.Builder<T> addChildren(Collection<Tag<T>> children) Adds multiple required children to this template.addChildren(Collection<Tag<T>> children, boolean required) Adds multiple children to this template.addChildren(Map<Tag<T>, Boolean> childrenMap) Adds multiple required children to this template, where each key-value pair in this map represents a childResourceKeyand whether the child is required.default TagTemplate.Builder<T> addValue(RegistryKey<T> value) Adds theRegistryKeyfor a value to the builder, marking it as required.addValue(RegistryKey<T> value, boolean required) Adds theRegistryKeyfor a value to the builder.default TagTemplate.Builder<T> addValues(Collection<RegistryKey<T>> values) Adds a collection ofRegistryKeys for values to this builder, marking all as required.addValues(Collection<RegistryKey<T>> values, boolean required) Adds a collection ofRegistryKeys for values to this builder.@NonNull TagTemplate<T> build()Creates aTagTemplatethat should be registered during theRegisterDataPackValueEvent.default TagTemplate.Builder<T> replace()Indicates that any existing values of a tag with the sameResourceKeyed.key()andRegistryTypeduring datapack (re)loading will have their values discarded and replaced by this template.replace(boolean replace) Sets whether the values contained by a tag template will replace existing values if a tag with the sameResourceKeyed.key()andRegistryTypealready exists when datapacks are (re)loaded.Methods inherited from interface org.spongepowered.api.util.ResourceKeyedBuilder
key
-
Method Details
-
replace
Sets whether the values contained by a tag template will replace existing values if a tag with the sameResourceKeyed.key()andRegistryTypealready 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
Indicates that any existing values of a tag with the sameResourceKeyed.key()andRegistryTypeduring datapack (re)loading will have their values discarded and replaced by this template.- Returns:
- This builder, for chaining
- See Also:
-
addValue
Adds theRegistryKeyfor a value to the builder.As the objects that this tag will contain may be available at this stage, their
resource key IDshould 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 therequiredparameter:- 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
Adds theRegistryKeyfor a value to the builder, marking it as required.- Parameters:
value- Value to add- Returns:
- This builder, for chaining
- See Also:
-
addValues
Adds a collection ofRegistryKeys 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:
-
addValues
Adds a collection ofRegistryKeys for values to this builder, marking all as required.- Parameters:
values- Values to add- Returns:
- This builder, for chaining.
- See Also:
-
addChild
Marks a tag with a givenRegistryKeyas a child of the tag generated by this template.A child
Tagis 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
Tags 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 torequireddetermines 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-RegistryKeyfor 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
Marks a tag with a givenRegistryKeyas a required child of the tag generated by this template.- Parameters:
childTag-RegistryKeyfor tag to be added.- Returns:
- This builder, for chaining
- See Also:
-
addChild
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 sameRegistryTypeas this builder.- See Also:
-
addChildren
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:
-
addChildren
Adds multiple required children to this template.- Parameters:
children- Children to add.- Returns:
- This builder, for chaining
- See Also:
-
addChildren
Adds multiple required children to this template, where each key-value pair in this map represents a childResourceKeyand whether the child is required.- Parameters:
childrenMap- Map of children, RegistryKey- Returns:
- This builder, for chaining.
- See Also:
-
build
@NonNull TagTemplate<T> build()Creates aTagTemplatethat should be registered during theRegisterDataPackValueEvent.- Specified by:
buildin interfaceAbstractBuilder<T extends Taggable<T>>- Returns:
- The built
TagTemplate.
-