Class EnchantTrigger<T extends org.bukkit.event.Event>

java.lang.Object
redempt.redlib.enchants.trigger.EnchantTrigger<T>
Type Parameters:
T - The event type this EventTrigger passes
Direct Known Subclasses:
KillEntityTrigger

public abstract class EnchantTrigger<T extends org.bukkit.event.Event> extends Object
Represents a trigger for a CustomEnchant which will smartly pass relevant events
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final EnchantTrigger<org.bukkit.event.entity.EntityDamageByEntityEvent>
    Calls activate with an EntityDamageByEntityEvent when a player attacks an entity with an item that has a CustomEnchant with this trigger
    Calls activate with a PlayerChangedArmorEvent when a player equips armor that has a CustomEnchant with this trigger Also calls activate when a player joins wearing armor with this trigger Calls deactivate with a PlayerChangedArmorEvent when a player unequips armor that has a CustomEnchant with this trigger Also calls deactivate when a player leaves wearing armor with this trigger
    protected Map<Class<? extends org.bukkit.event.Event>,Function<org.bukkit.event.Event,EventItems>>
     
    Calls activate with a PlayerChangedHeldItemEvent when a player begins holding an item that has a CustomEnchant with this trigger Also calls activate when a player joins holding an item with this trigger Calls deactivate with a PlayerChangedHeldItemEvent when a player stops holding an item that has a CustomEnchant with this trigger Also calls deactivate when a player leaves holding an item with this trigger
    static final EnchantTrigger<org.bukkit.event.entity.EntityDeathEvent>
    Calls activate with an EntityDeathEvent when a player kills an entity with an item that has a CustomEnchant with this trigger
    static final EnchantTrigger<org.bukkit.event.block.BlockBreakEvent>
    Calls activate with a BlockBreakEvent when a block is broken with an item that has a CustomEnchant with this trigger
    static final EnchantTrigger<org.bukkit.event.entity.ProjectileLaunchEvent>
    Calls activate with a ProjectileLaunchEvent when a player shoots a projectile with an item that has a CustomEnchant with this trigger
    static final EnchantTrigger<org.bukkit.event.entity.EntityDamageEvent>
    Calls activate with an EntityDamageEvent when a player takes damage wearing armor that has a CustomEnchant with this trigger
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected <T extends org.bukkit.event.Event>
    void
    addListener(Class<T> eventClass, Function<T,EventItems> func)
    Registers a listener for this EventTrigger to get the items and event for the specified event
    abstract boolean
    defaultAppliesTo(org.bukkit.Material type)
    Returns whether this EnchantTrigger applies to the given type by default
    Map<Class<? extends org.bukkit.event.Event>,Function<org.bukkit.event.Event,EventItems>>
    Gets the event listeners registered by this EnchantTrigger
    org.bukkit.event.EventPriority
     
    final void
     
    protected abstract void
     
    withPriority(org.bukkit.event.EventPriority priority)
    Creates a copy of this EnchantTrigger with a different EventPriority

    Methods inherited from class java.lang.Object

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

    • MINE_BLOCK

      public static final EnchantTrigger<org.bukkit.event.block.BlockBreakEvent> MINE_BLOCK
      Calls activate with a BlockBreakEvent when a block is broken with an item that has a CustomEnchant with this trigger
    • ATTACK_ENTITY

      public static final EnchantTrigger<org.bukkit.event.entity.EntityDamageByEntityEvent> ATTACK_ENTITY
      Calls activate with an EntityDamageByEntityEvent when a player attacks an entity with an item that has a CustomEnchant with this trigger
    • KILL_ENTITY

      public static final EnchantTrigger<org.bukkit.event.entity.EntityDeathEvent> KILL_ENTITY
      Calls activate with an EntityDeathEvent when a player kills an entity with an item that has a CustomEnchant with this trigger
    • SHOOT_ARROW

      public static final EnchantTrigger<org.bukkit.event.entity.ProjectileLaunchEvent> SHOOT_ARROW
      Calls activate with a ProjectileLaunchEvent when a player shoots a projectile with an item that has a CustomEnchant with this trigger
    • TAKE_DAMAGE

      public static final EnchantTrigger<org.bukkit.event.entity.EntityDamageEvent> TAKE_DAMAGE
      Calls activate with an EntityDamageEvent when a player takes damage wearing armor that has a CustomEnchant with this trigger
    • EQUIP_ARMOR

      public static final EnchantTrigger<PlayerChangedArmorEvent> EQUIP_ARMOR
      Calls activate with a PlayerChangedArmorEvent when a player equips armor that has a CustomEnchant with this trigger Also calls activate when a player joins wearing armor with this trigger Calls deactivate with a PlayerChangedArmorEvent when a player unequips armor that has a CustomEnchant with this trigger Also calls deactivate when a player leaves wearing armor with this trigger
    • HOLD_ITEM

      public static final EnchantTrigger<PlayerChangedHeldItemEvent> HOLD_ITEM
      Calls activate with a PlayerChangedHeldItemEvent when a player begins holding an item that has a CustomEnchant with this trigger Also calls activate when a player joins holding an item with this trigger Calls deactivate with a PlayerChangedHeldItemEvent when a player stops holding an item that has a CustomEnchant with this trigger Also calls deactivate when a player leaves holding an item with this trigger
    • events

      protected Map<Class<? extends org.bukkit.event.Event>,Function<org.bukkit.event.Event,EventItems>> events
  • Constructor Details

    • EnchantTrigger

      public EnchantTrigger()
  • Method Details

    • register

      protected abstract void register()
    • init

      public final void init()
    • addListener

      protected <T extends org.bukkit.event.Event> void addListener(Class<T> eventClass, Function<T,EventItems> func)
      Registers a listener for this EventTrigger to get the items and event for the specified event
      Type Parameters:
      T - The event type
      Parameters:
      eventClass - The class of the event
      func - The function to get the EventItems from the event
    • getEvents

      public Map<Class<? extends org.bukkit.event.Event>,Function<org.bukkit.event.Event,EventItems>> getEvents()
      Gets the event listeners registered by this EnchantTrigger
      Returns:
      The map of events to their functions which will retrieve relevant items
    • getPriority

      public org.bukkit.event.EventPriority getPriority()
      Returns:
      The EventPriority this EnchantTrigger's listeners should be registered with
    • defaultAppliesTo

      public abstract boolean defaultAppliesTo(org.bukkit.Material type)
      Returns whether this EnchantTrigger applies to the given type by default
      Parameters:
      type - The type to check
      Returns:
      Whether this EnchantTrigger applies to the type by default
    • withPriority

      public EnchantTrigger<T> withPriority(org.bukkit.event.EventPriority priority)
      Creates a copy of this EnchantTrigger with a different EventPriority
      Parameters:
      priority - The EventPriority to set on the copy
      Returns:
      A copy of this EnchantTrigger with the given priority