use of com.destroystokyo.paper.event.block.BeaconEffectEvent in project Glowstone by GlowstoneMC.
the class BeaconEntity method applyPotionEffects.
private void applyPotionEffects() {
Beacon beacon = (Beacon) getBlock().getState();
beacon.getEntitiesInRange().forEach(livingEntity -> {
for (BeaconEffectPriority priority : BeaconEffectPriority.values()) {
PotionEffect effect = this.getEffect(priority);
if (effect == null) {
continue;
}
BeaconEffectEvent event = new BeaconEffectEvent(block, effect, (Player) livingEntity, priority == BeaconEffectPriority.PRIMARY);
if (!EventFactory.getInstance().callEvent(event).isCancelled()) {
livingEntity.addPotionEffect(event.getEffect(), true);
}
}
});
}
Aggregations