Search in sources :

Example 1 with BeaconEffectEvent

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);
            }
        }
    });
}
Also used : BeaconEffectEvent(com.destroystokyo.paper.event.block.BeaconEffectEvent) PotionEffect(org.bukkit.potion.PotionEffect) Beacon(org.bukkit.block.Beacon) GlowBeacon(net.glowstone.block.entity.state.GlowBeacon)

Aggregations

BeaconEffectEvent (com.destroystokyo.paper.event.block.BeaconEffectEvent)1 GlowBeacon (net.glowstone.block.entity.state.GlowBeacon)1 Beacon (org.bukkit.block.Beacon)1 PotionEffect (org.bukkit.potion.PotionEffect)1