Class Attribute

java.lang.Object
org.woftnw.eof.attribute.Attribute
Direct Known Subclasses:
AttributeModifierAttribute, PotionEffectAttribute

public abstract class Attribute extends Object
Represents a tribal attribute.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected final @Nullable Predicate<org.bukkit.entity.Player>
     
    protected final boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Attribute(@Nullable Predicate<org.bukkit.entity.Player> predicate)
    Create a tribe attribute.
    Attribute(@Nullable Predicate<org.bukkit.entity.Player> predicate, boolean refreshOnPredicate)
    Create a tribe attribute.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    apply(org.bukkit.entity.Player player)
    Apply this attribute.
    boolean
    meetsPredicate(@NonNull org.bukkit.entity.Player player)
    Check if the player meets the predicate, if there is one.
    void
    tick(org.bukkit.entity.Player player)
    Tick this attribute.
    abstract void
    unapply(org.bukkit.entity.Player player)
    Unapply this attribute.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PREDICATE

      protected final @Nullable Predicate<org.bukkit.entity.Player> PREDICATE
    • REFRESH_ON_PREDICATE

      protected final boolean REFRESH_ON_PREDICATE
    • lastTest

      protected boolean lastTest
  • Constructor Details

    • Attribute

      public Attribute(@Nullable Predicate<org.bukkit.entity.Player> predicate, boolean refreshOnPredicate)
      Create a tribe attribute.
      Parameters:
      predicate - The predicate that must be true to apply the attribute or null if it should always be applied.
      refreshOnPredicate - Whether this attribute should only refresh when the predicate switches from false to true.
    • Attribute

      public Attribute(@Nullable Predicate<org.bukkit.entity.Player> predicate)
      Create a tribe attribute.
      Parameters:
      predicate - The predicate that must be true to apply the attribute or null if it should always be applied.
  • Method Details

    • meetsPredicate

      public boolean meetsPredicate(@NonNull org.bukkit.entity.Player player)
      Check if the player meets the predicate, if there is one. Otherwise, this will return true.
      Parameters:
      player - The player to check.
    • tick

      public void tick(org.bukkit.entity.Player player)
      Tick this attribute. Subclasses should use meetsPredicate(player) in this method.
      Parameters:
      player - The player to apply to.
    • apply

      public abstract void apply(org.bukkit.entity.Player player)
      Apply this attribute. This is only used when the player changes tribes or activates attributes. Subclasses should use meetsPredicate(player) in this method.
      Parameters:
      player - The player to apply to.
    • unapply

      public abstract void unapply(org.bukkit.entity.Player player)
      Unapply this attribute. This is only used when the player changes tribes or deactivates attributes. Subclasses should use meetsPredicate(player) in this method.
      Parameters:
      player - The player to unapply to.