Class PetBehaviorHelpers

java.lang.Object
de.Keyle.MyPet.api.behavior.PetBehaviorHelpers

public final class PetBehaviorHelpers extends Object
Factory methods for PetBehavior, one per common Bukkit event shape. Each helper bakes in the right entity-extractor for its event type so the dispatcher doesn't need a per-event switch.

New helpers are added as real migrations need them, not speculatively. Each comes with a defaults overload (most common priority + ignoreCancelled values) plus an explicit overload for handlers that need to interpose at a specific point in the chain.

  • Method Details

    • onPetInteract

      public static PetBehavior<PlayerInteractEntityEvent> onPetInteract(String petType, PetEventHandler<PlayerInteractEntityEvent> handler)
      Right-click on a pet entity. Fires for the common "player interacts with this specific pet" pattern: flint-and-steel on a Creeper, bucket on a Cow, shears on a Sheep, etc.

      Defaults to EventPriority.LOW with ignoreCancelled — matches the existing PetInteractionGateListener priority so cancellations land before vanilla's mobInteract.

      Parameters:
      petType - the pet type this behavior fires for
      handler - run when the event fires on a matching pet
      Returns:
      the registered behavior, for assignment to a static final field
    • onPetInteract

      public static PetBehavior<PlayerInteractEntityEvent> onPetInteract(String petType, EventPriority priority, boolean ignoreCancelled, PetEventHandler<PlayerInteractEntityEvent> handler)
      onPetInteract(String, PetEventHandler) with explicit priority + ignoreCancelled.
      Parameters:
      petType - the pet type this behavior fires for
      priority - the Bukkit event priority to listen at
      ignoreCancelled - true to skip events another plugin has cancelled
      handler - run when the event fires on a matching pet
      Returns:
      the registered behavior, for assignment to a static final field
    • onPetExplodes

      public static PetBehavior<EntityExplodeEvent> onPetExplodes(String petType, PetEventHandler<EntityExplodeEvent> handler)
      Pet entity is the source of an explosion (EntityExplodeEvent). Defaults to EventPriority.NORMAL with ignoreCancelled = false.
      Parameters:
      petType - the pet type this behavior fires for
      handler - run when the event fires on a matching pet
      Returns:
      the registered behavior, for assignment to a static final field
    • onPetExplodes

      public static PetBehavior<EntityExplodeEvent> onPetExplodes(String petType, EventPriority priority, boolean ignoreCancelled, PetEventHandler<EntityExplodeEvent> handler)
      onPetExplodes(String, PetEventHandler) with explicit priority + ignoreCancelled.
      Parameters:
      petType - the pet type this behavior fires for
      priority - the Bukkit event priority to listen at
      ignoreCancelled - true to skip events another plugin has cancelled
      handler - run when the event fires on a matching pet
      Returns:
      the registered behavior, for assignment to a static final field
    • onPetDamaged

      public static PetBehavior<EntityDamageEvent> onPetDamaged(String petType, PetEventHandler<EntityDamageEvent> handler)
      Pet entity is the victim of damage (EntityDamageEvent). Defaults to EventPriority.NORMAL with ignoreCancelled = false.
      Parameters:
      petType - the pet type this behavior fires for
      handler - run when the event fires on a matching pet
      Returns:
      the registered behavior, for assignment to a static final field
    • onPetDamaged

      public static PetBehavior<EntityDamageEvent> onPetDamaged(String petType, EventPriority priority, boolean ignoreCancelled, PetEventHandler<EntityDamageEvent> handler)
      onPetDamaged(String, PetEventHandler) with explicit priority + ignoreCancelled.
      Parameters:
      petType - the pet type this behavior fires for
      priority - the Bukkit event priority to listen at
      ignoreCancelled - true to skip events another plugin has cancelled
      handler - run when the event fires on a matching pet
      Returns:
      the registered behavior, for assignment to a static final field
    • onPetDamages

      public static PetBehavior<EntityDamageByEntityEvent> onPetDamages(String petType, PetEventHandler<EntityDamageByEntityEvent> handler)
      Pet entity is the damager of an entity-on-entity attack (EntityDamageByEntityEvent). The handler's mob argument is the damaging pet; event.getEntity() is the victim. Defaults to EventPriority.NORMAL with ignoreCancelled = false.
      Parameters:
      petType - the pet type this behavior fires for
      handler - run when the event fires on a matching pet
      Returns:
      the registered behavior, for assignment to a static final field
    • onPetDamages

      public static PetBehavior<EntityDamageByEntityEvent> onPetDamages(String petType, EventPriority priority, boolean ignoreCancelled, PetEventHandler<EntityDamageByEntityEvent> handler)
      onPetDamages(String, PetEventHandler) with explicit priority + ignoreCancelled.
      Parameters:
      petType - the pet type this behavior fires for
      priority - the Bukkit event priority to listen at
      ignoreCancelled - true to skip events another plugin has cancelled
      handler - run when the event fires on a matching pet
      Returns:
      the registered behavior, for assignment to a static final field
    • onPetPushes

      public static PetBehavior<EntityPushedByEntityAttackEvent> onPetPushes(String petType, EventPriority priority, boolean ignoreCancelled, PetEventHandler<EntityPushedByEntityAttackEvent> handler)
      Pet entity is the source of a push (EntityPushedByEntityAttackEvent), fired by Entity#push(x, y, z, source) before any damage is dealt. The handler's mob argument is the pushing pet; event.getEntity() is the pushed entity.
      Parameters:
      petType - the pet type this behavior fires for
      priority - the Bukkit event priority to listen at
      ignoreCancelled - true to skip events another plugin has cancelled
      handler - run when the event fires on a matching pet
      Returns:
      the registered behavior, for assignment to a static final field
    • onPetCreeperPower

      public static PetBehavior<CreeperPowerEvent> onPetCreeperPower(String petType, PetEventHandler<CreeperPowerEvent> handler)
      Creeper pet entity is becoming powered/unpowered (CreeperPowerEvent). Defaults to EventPriority.NORMAL with ignoreCancelled = false.
      Parameters:
      petType - the pet type this behavior fires for
      handler - run when the event fires on a matching pet
      Returns:
      the registered behavior, for assignment to a static final field
    • onPetCreeperPower

      public static PetBehavior<CreeperPowerEvent> onPetCreeperPower(String petType, EventPriority priority, boolean ignoreCancelled, PetEventHandler<CreeperPowerEvent> handler)
      onPetCreeperPower(String, PetEventHandler) with explicit priority + ignoreCancelled.
      Parameters:
      petType - the pet type this behavior fires for
      priority - the Bukkit event priority to listen at
      ignoreCancelled - true to skip events another plugin has cancelled
      handler - run when the event fires on a matching pet
      Returns:
      the registered behavior, for assignment to a static final field
    • onPetLightningTransform

      public static PetBehavior<EntityTransformEvent> onPetLightningTransform(String petType, PetEventHandler<EntityTransformEvent> handler)
      Pet entity is being transformed into a different entity type (EntityTransformEvent). Common for lightning conversions and mooshroom variant flips. Defaults to EventPriority.NORMAL with ignoreCancelled = false.
      Parameters:
      petType - the pet type this behavior fires for
      handler - run when the event fires on a matching pet
      Returns:
      the registered behavior, for assignment to a static final field
    • onPetLightningTransform

      public static PetBehavior<EntityTransformEvent> onPetLightningTransform(String petType, EventPriority priority, boolean ignoreCancelled, PetEventHandler<EntityTransformEvent> handler)
      onPetLightningTransform(String, PetEventHandler) with explicit priority + ignoreCancelled.
      Parameters:
      petType - the pet type this behavior fires for
      priority - the Bukkit event priority to listen at
      ignoreCancelled - true to skip events another plugin has cancelled
      handler - run when the event fires on a matching pet
      Returns:
      the registered behavior, for assignment to a static final field
    • onPetBlockForm

      public static PetBehavior<EntityBlockFormEvent> onPetBlockForm(String petType, PetEventHandler<EntityBlockFormEvent> handler)
      Pet entity is forming a block (EntityBlockFormEvent). Currently only SnowGolem fires this vanilla-wise (snow-track placement). Defaults to EventPriority.NORMAL with ignoreCancelled = true.
      Parameters:
      petType - the pet type this behavior fires for
      handler - run when the event fires on a matching pet
      Returns:
      the registered behavior, for assignment to a static final field
    • onPetBlockForm

      public static PetBehavior<EntityBlockFormEvent> onPetBlockForm(String petType, EventPriority priority, boolean ignoreCancelled, PetEventHandler<EntityBlockFormEvent> handler)
      onPetBlockForm(String, PetEventHandler) with explicit priority + ignoreCancelled.
      Parameters:
      petType - the pet type this behavior fires for
      priority - the Bukkit event priority to listen at
      ignoreCancelled - true to skip events another plugin has cancelled
      handler - run when the event fires on a matching pet
      Returns:
      the registered behavior, for assignment to a static final field