Class ItemPredicate

java.lang.Object
com.github.darksoulq.abyssallib.world.item.ItemPredicate
All Implemented Interfaces:
Predicate<org.bukkit.inventory.ItemStack>

public class ItemPredicate extends Object implements Predicate<org.bukkit.inventory.ItemStack>
A sophisticated predicate used to evaluate and filter ItemStack instances. This class allows for complex conditional checks against an item's identity, the presence or absence of specific data components, exact component values, and evaluation of nested predicates.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A fluent builder pattern class designed to easily construct ItemPredicate instances.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Codec<ItemPredicate>
    The primary codec used to serialize and deserialize entire ItemPredicate instances.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ItemPredicate(List<Condition<net.kyori.adventure.key.Key>> without, List<Condition<net.kyori.adventure.key.Key>> with, List<Condition<DataComponent<?>>> valued, List<Condition<ItemPredicate>> predicates, net.kyori.adventure.key.Key id)
    Constructs a new ItemPredicate with the specified conditional rules.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a new fluent builder instance for constructing an ItemPredicate.
    boolean
    Compares this predicate against another object for logical equivalence.
    int
    Generates a hash code based on the predicate's underlying conditions.
    boolean
    test(org.bukkit.inventory.ItemStack stack)
    Evaluates an ItemStack against all configured conditions within this predicate.

    Methods inherited from class Object

    getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface Predicate

    and, negate, or
  • Field Details

    • CODEC

      public static final Codec<ItemPredicate> CODEC
      The primary codec used to serialize and deserialize entire ItemPredicate instances. Supports resolving registered predicates by their String ID or parsing full nested objects.
  • Constructor Details

    • ItemPredicate

      public ItemPredicate(List<Condition<net.kyori.adventure.key.Key>> without, List<Condition<net.kyori.adventure.key.Key>> with, List<Condition<DataComponent<?>>> valued, List<Condition<ItemPredicate>> predicates, net.kyori.adventure.key.Key id)
      Constructs a new ItemPredicate with the specified conditional rules.
      Parameters:
      without - The list of exclusionary component conditions.
      with - The list of inclusionary component conditions.
      valued - The list of specific value-matching component conditions.
      predicates - The list of nested predicate conditions.
      id - The base item Key that must match (nullable for any item).
  • Method Details

    • builder

      public static ItemPredicate.Builder builder()
      Creates a new fluent builder instance for constructing an ItemPredicate.
      Returns:
      A new ItemPredicate.Builder instance.
    • equals

      public boolean equals(Object o)
      Compares this predicate against another object for logical equivalence.
      Overrides:
      equals in class Object
      Parameters:
      o - The object to compare.
      Returns:
      True if the object is an identical ItemPredicate.
    • hashCode

      public int hashCode()
      Generates a hash code based on the predicate's underlying conditions.
      Overrides:
      hashCode in class Object
      Returns:
      The integer hash code.
    • test

      public boolean test(org.bukkit.inventory.ItemStack stack)
      Evaluates an ItemStack against all configured conditions within this predicate.
      Specified by:
      test in interface Predicate<org.bukkit.inventory.ItemStack>
      Parameters:
      stack - The ItemStack to test.
      Returns:
      True if the item satisfies all rules; false if it fails any rule or is null/air.