Package de.Keyle.MyPet.api.behavior
Class PetBehaviorHelpers
java.lang.Object
de.Keyle.MyPet.api.behavior.PetBehaviorHelpers
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 Summary
Modifier and TypeMethodDescriptionstatic PetBehavior<EntityBlockFormEvent> onPetBlockForm(String petType, PetEventHandler<EntityBlockFormEvent> handler) Pet entity is forming a block (EntityBlockFormEvent).static PetBehavior<EntityBlockFormEvent> onPetBlockForm(String petType, EventPriority priority, boolean ignoreCancelled, PetEventHandler<EntityBlockFormEvent> handler) onPetBlockForm(String, PetEventHandler)with explicit priority + ignoreCancelled.static PetBehavior<CreeperPowerEvent> onPetCreeperPower(String petType, PetEventHandler<CreeperPowerEvent> handler) Creeper pet entity is becoming powered/unpowered (CreeperPowerEvent).static PetBehavior<CreeperPowerEvent> onPetCreeperPower(String petType, EventPriority priority, boolean ignoreCancelled, PetEventHandler<CreeperPowerEvent> handler) onPetCreeperPower(String, PetEventHandler)with explicit priority + ignoreCancelled.static PetBehavior<EntityDamageEvent> onPetDamaged(String petType, PetEventHandler<EntityDamageEvent> handler) Pet entity is the victim of damage (EntityDamageEvent).static PetBehavior<EntityDamageEvent> onPetDamaged(String petType, EventPriority priority, boolean ignoreCancelled, PetEventHandler<EntityDamageEvent> handler) onPetDamaged(String, PetEventHandler)with explicit priority + ignoreCancelled.static PetBehavior<EntityDamageByEntityEvent> onPetDamages(String petType, PetEventHandler<EntityDamageByEntityEvent> handler) Pet entity is the damager of an entity-on-entity attack (EntityDamageByEntityEvent).static PetBehavior<EntityDamageByEntityEvent> onPetDamages(String petType, EventPriority priority, boolean ignoreCancelled, PetEventHandler<EntityDamageByEntityEvent> handler) onPetDamages(String, PetEventHandler)with explicit priority + ignoreCancelled.static PetBehavior<EntityExplodeEvent> onPetExplodes(String petType, PetEventHandler<EntityExplodeEvent> handler) Pet entity is the source of an explosion (EntityExplodeEvent).static PetBehavior<EntityExplodeEvent> onPetExplodes(String petType, EventPriority priority, boolean ignoreCancelled, PetEventHandler<EntityExplodeEvent> handler) onPetExplodes(String, PetEventHandler)with explicit priority + ignoreCancelled.static PetBehavior<PlayerInteractEntityEvent> onPetInteract(String petType, PetEventHandler<PlayerInteractEntityEvent> handler) Right-click on a pet entity.static PetBehavior<PlayerInteractEntityEvent> onPetInteract(String petType, EventPriority priority, boolean ignoreCancelled, PetEventHandler<PlayerInteractEntityEvent> handler) onPetInteract(String, PetEventHandler)with explicit priority + ignoreCancelled.static PetBehavior<EntityTransformEvent> onPetLightningTransform(String petType, PetEventHandler<EntityTransformEvent> handler) Pet entity is being transformed into a different entity type (EntityTransformEvent).static PetBehavior<EntityTransformEvent> onPetLightningTransform(String petType, EventPriority priority, boolean ignoreCancelled, PetEventHandler<EntityTransformEvent> handler) onPetLightningTransform(String, PetEventHandler)with explicit priority + ignoreCancelled.onPetPushes(String petType, EventPriority priority, boolean ignoreCancelled, PetEventHandler<EntityPushedByEntityAttackEvent> handler) Pet entity is the source of a push (EntityPushedByEntityAttackEvent), fired byEntity#push(x, y, z, source)before any damage is dealt.
-
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.LOWwithignoreCancelled— matches the existingPetInteractionGateListenerpriority so cancellations land before vanilla'smobInteract.- Parameters:
petType- the pet type this behavior fires forhandler- run when the event fires on a matching pet- Returns:
- the registered behavior, for assignment to a
static finalfield
-
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 forpriority- the Bukkit event priority to listen atignoreCancelled-trueto skip events another plugin has cancelledhandler- run when the event fires on a matching pet- Returns:
- the registered behavior, for assignment to a
static finalfield
-
onPetExplodes
public static PetBehavior<EntityExplodeEvent> onPetExplodes(String petType, PetEventHandler<EntityExplodeEvent> handler) Pet entity is the source of an explosion (EntityExplodeEvent). Defaults toEventPriority.NORMALwithignoreCancelled = false.- Parameters:
petType- the pet type this behavior fires forhandler- run when the event fires on a matching pet- Returns:
- the registered behavior, for assignment to a
static finalfield
-
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 forpriority- the Bukkit event priority to listen atignoreCancelled-trueto skip events another plugin has cancelledhandler- run when the event fires on a matching pet- Returns:
- the registered behavior, for assignment to a
static finalfield
-
onPetDamaged
public static PetBehavior<EntityDamageEvent> onPetDamaged(String petType, PetEventHandler<EntityDamageEvent> handler) Pet entity is the victim of damage (EntityDamageEvent). Defaults toEventPriority.NORMALwithignoreCancelled = false.- Parameters:
petType- the pet type this behavior fires forhandler- run when the event fires on a matching pet- Returns:
- the registered behavior, for assignment to a
static finalfield
-
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 forpriority- the Bukkit event priority to listen atignoreCancelled-trueto skip events another plugin has cancelledhandler- run when the event fires on a matching pet- Returns:
- the registered behavior, for assignment to a
static finalfield
-
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'smobargument is the damaging pet;event.getEntity()is the victim. Defaults toEventPriority.NORMALwithignoreCancelled = false.- Parameters:
petType- the pet type this behavior fires forhandler- run when the event fires on a matching pet- Returns:
- the registered behavior, for assignment to a
static finalfield
-
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 forpriority- the Bukkit event priority to listen atignoreCancelled-trueto skip events another plugin has cancelledhandler- run when the event fires on a matching pet- Returns:
- the registered behavior, for assignment to a
static finalfield
-
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 byEntity#push(x, y, z, source)before any damage is dealt. The handler'smobargument is the pushing pet;event.getEntity()is the pushed entity.- Parameters:
petType- the pet type this behavior fires forpriority- the Bukkit event priority to listen atignoreCancelled-trueto skip events another plugin has cancelledhandler- run when the event fires on a matching pet- Returns:
- the registered behavior, for assignment to a
static finalfield
-
onPetCreeperPower
public static PetBehavior<CreeperPowerEvent> onPetCreeperPower(String petType, PetEventHandler<CreeperPowerEvent> handler) Creeper pet entity is becoming powered/unpowered (CreeperPowerEvent). Defaults toEventPriority.NORMALwithignoreCancelled = false.- Parameters:
petType- the pet type this behavior fires forhandler- run when the event fires on a matching pet- Returns:
- the registered behavior, for assignment to a
static finalfield
-
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 forpriority- the Bukkit event priority to listen atignoreCancelled-trueto skip events another plugin has cancelledhandler- run when the event fires on a matching pet- Returns:
- the registered behavior, for assignment to a
static finalfield
-
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 toEventPriority.NORMALwithignoreCancelled = false.- Parameters:
petType- the pet type this behavior fires forhandler- run when the event fires on a matching pet- Returns:
- the registered behavior, for assignment to a
static finalfield
-
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 forpriority- the Bukkit event priority to listen atignoreCancelled-trueto skip events another plugin has cancelledhandler- run when the event fires on a matching pet- Returns:
- the registered behavior, for assignment to a
static finalfield
-
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 toEventPriority.NORMALwithignoreCancelled = true.- Parameters:
petType- the pet type this behavior fires forhandler- run when the event fires on a matching pet- Returns:
- the registered behavior, for assignment to a
static finalfield
-
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 forpriority- the Bukkit event priority to listen atignoreCancelled-trueto skip events another plugin has cancelledhandler- run when the event fires on a matching pet- Returns:
- the registered behavior, for assignment to a
static finalfield
-