Class EntityPredicate

java.lang.Object
com.github.darksoulq.abyssallib.world.entity.EntityPredicate
All Implemented Interfaces:
Predicate<org.bukkit.entity.Entity>

@Experimental public class EntityPredicate extends Object implements Predicate<org.bukkit.entity.Entity>
A predicate used to evaluate and filter Entity instances based on their identity and raw serialized data. This class allows for complex conditional checks against an entity's JSON-like data structure, identity keys, and nested predicate logic.
  • Nested Class Summary

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

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

    Constructors
    Constructor
    Description
    EntityPredicate(net.kyori.adventure.key.Key id, List<Condition<Map.Entry<String, com.fasterxml.jackson.databind.JsonNode>>> data, List<Condition<EntityPredicate>> predicates)
    Constructs a new EntityPredicate with the specified conditional rules.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a new fluent builder instance for constructing an EntityPredicate.
    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.entity.Entity info)
    Evaluates an Entity 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<EntityPredicate> CODEC
      The primary codec used to serialize and deserialize entire EntityPredicate instances. Supports resolving registered predicates by their String ID or parsing full nested objects.
  • Constructor Details

    • EntityPredicate

      public EntityPredicate(net.kyori.adventure.key.Key id, List<Condition<Map.Entry<String, com.fasterxml.jackson.databind.JsonNode>>> data, List<Condition<EntityPredicate>> predicates)
      Constructs a new EntityPredicate with the specified conditional rules.
      Parameters:
      id - The identity Key that must match (nullable for any entity).
      data - The list of specific value-matching JSON data conditions.
      predicates - The list of nested predicate conditions.
  • Method Details

    • builder

      public static EntityPredicate.Builder builder()
      Creates a new fluent builder instance for constructing an EntityPredicate.
      Returns:
      A new EntityPredicate.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 EntityPredicate.
    • 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.entity.Entity info)
      Evaluates an Entity against all configured conditions within this predicate.
      Specified by:
      test in interface Predicate<org.bukkit.entity.Entity>
      Parameters:
      info - The entity information to test.
      Returns:
      True if the entity satisfies all identity, data, and nested rules; false otherwise.