Interface TagSet<T extends Keyed>

Type Parameters:
T - the Bukkit type of the elements
All Superinterfaces:
Keyed, Registerable<TagSet<T>>, Wrapper

@NullMarked @AsOf("3.1.0") public interface TagSet<T extends Keyed> extends Wrapper, Keyed, Registerable<TagSet<T>>
An abstraction over a set of registry entries that is either an explicit Set of elements or a reference to a named tag (ResourceKey). It mirrors Minecraft's HolderSet, which is likewise an inline list, or a tag. When this is a set of elements, this can be registered to a registry.
Since:
3.1.0
  • Method Details

    • resourceKey

      @AsOf("3.1.0") Optional<ResourceKey> resourceKey()
      The key of the tag set.
      Returns:
      the tag set key
      Since:
      3.1.0
    • registryId

      @AsOf("3.1.0") RegistryId registryId()
      The registry the elements of this tag set resolve against.
      Returns:
      the registry discriminator
      Since:
      3.1.0
    • value

      @AsOf("3.1.0") Either<Set<T>,TagKey> value()
      The contents of this tag set: either an explicit set of elements, or a reference to a named tag.
      Returns:
      the set of values contained in this tag set
      Since:
      3.1.0
    • asHolderSet

      @AsOf("3.1.0") <U> U asHolderSet()
      If this is a holder set, returns the underlying set. If this is a tag key, returns the underlying set for that key.
      Type Parameters:
      U - the type of the underlying set
      Returns:
      the underlying set, if present
      Since:
      3.1.0
    • asTagKey

      @AsOf("3.1.0") <U> U asTagKey()
      If this is a tag key, returns the underlying tag key. If this is a holder set, tries to find a tag key which matches the items in this set, otherwise throws.
      Type Parameters:
      U - the type of the underlying tag key
      Returns:
      the underlying tag key, if present
      Throws:
      IllegalStateException - if this is a holder set, and no matching tag key can be found
      Since:
      3.1.0
    • isBlockSet

      @AsOf("3.1.0") default boolean isBlockSet()
      Checks if this is a block tag set.
      Returns:
      true if this is a block tag set, false otherwise
      Since:
      3.1.0
    • isTag

      @AsOf("3.1.0") default boolean isTag()
      Checks if this is a tag set.
      Returns:
      true if this is a tag set, false otherwise
      Since:
      3.1.0
    • ofBlocks

      @AsOf("3.1.0") static TagSet<Material> ofBlocks(@Nullable ResourceKey resourceKey, Material... blocks)
      Creates a tag set of explicit block materials.
      Parameters:
      resourceKey - the resource key of the tag set
      blocks - the block materials
      Returns:
      a new block tag set
      Since:
      3.1.0
    • ofBlocks

      @AsOf("3.1.0") static TagSet<Material> ofBlocks(@Nullable ResourceKey resourceKey, Set<Material> blocks)
      Creates a tag set of explicit block materials.
      Parameters:
      resourceKey - the resource key of the tag set
      blocks - the block materials
      Returns:
      a new block tag set
      Since:
      3.1.0
    • ofBlocks

      @AsOf("3.1.0") static TagSet<Material> ofBlocks(Material... blocks)
      Creates a tag set of explicit block materials.
      Parameters:
      blocks - the block materials
      Returns:
      a new block tag set
      Since:
      3.1.0
    • ofBlocks

      @AsOf("3.1.0") static TagSet<Material> ofBlocks(Set<Material> blocks)
      Creates a tag set of explicit block materials.
      Parameters:
      blocks - the block materials
      Returns:
      a new block tag set
      Since:
      3.1.0
    • ofBlockTag

      @AsOf("3.1.0") static TagSet<Material> ofBlockTag(TagKey tag)
      Creates a tag set referencing a named block tag.
      Parameters:
      tag - the block tag key
      Returns:
      a new block tag set
      Since:
      3.1.0
    • ofBlockTag

      @AsOf("3.1.0") static TagSet<Material> ofBlockTag(ResourceKey key)
      Creates a key set referencing a named block key.
      Parameters:
      key - the block tag key
      Returns:
      a new block key set
      Since:
      3.1.0
    • ofTag

      @AsOf("3.1.0") static <T extends Keyed> TagSet<T> ofTag(TagKey tag)
      Creates a tag set referencing the given named tag.
      Type Parameters:
      T - the Bukkit type of the elements
      Parameters:
      tag - the tag key
      Returns:
      a new tag set
      Since:
      3.1.0
    • blocks

      @AsOf("3.1.0") static TagSet<Material> blocks(Either<Set<Material>, TagKey> value)
      Creates a block tag set from an Either of explicit materials or a named tag.
      Parameters:
      value - either the explicit block materials, or a named block tag
      Returns:
      a new block tag set
      Since:
      3.1.0
    • timelines

      @AsOf("3.2.0") static TagSet<Timeline> timelines(Either<Set<Timeline>, TagKey> value)
      Creates a tag set from an Either of explicit tags or a named tag.
      Parameters:
      value - either the explicit timelines, or a named timeline tag
      Returns:
      a new tag set
      Since:
      3.2.0
    • of

      @Internal static <T extends Keyed> TagSet<T> of(@Nullable ResourceKey resourceKey, RegistryId registry, Set<T> elements)
    • of

      @Internal static <T extends Keyed> TagSet<T> of(@Nullable ResourceKey resourceKey, RegistryId registry, Either<Set<T>,TagKey> value)
    • decodeBlocks

      @AsOf("3.3.0") static TagSet<Material> decodeBlocks(Object minecraftHolderSet)
      Reads a Minecraft block holder set, preserving a named tag when present.
      Parameters:
      minecraftHolderSet - the Minecraft block holder set
      Returns:
      the decoded block tag set
      Since:
      3.3.0
    • toBuilder

      @AsOf("3.1.0") default TagSet.Builder<T> toBuilder()
      Creates a new builder from this tag set.
      Returns:
      a new builder
      Since:
      3.1.0
    • builder

      @AsOf("3.1.0") static <T extends Keyed> TagSet.Builder<T> builder()
      Creates a new builder.
      Type Parameters:
      T - the Bukkit type of the elements
      Returns:
      a new builder
      Since:
      3.1.0
    • blocks

      @AsOf("3.1.0") static TagSet.Builder<Material> blocks()
      Creates a new builder for block tag sets.
      Returns:
      a new builder
      Since:
      3.1.0
    • timelines

      @AsOf("3.2.0") static TagSet.Builder<Timeline> timelines()
      Creates a new builder for timeline tag sets.
      Returns:
      a new builder
      Since:
      3.2.0