use of org.bukkit.block.Beacon 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);
}
}
});
}
use of org.bukkit.block.Beacon in project Glowstone by GlowstoneMC.
the class GlowBeaconInventory method setActiveEffects.
public void setActiveEffects(int primaryId, int secondaryId) {
if (!ALLOWED_MATERIALS.contains(getItem().getType())) {
return;
}
PotionEffectType primaryType = PotionEffectType.getById(primaryId);
if (primaryType != null) {
((Beacon) getHolder()).setPrimaryEffect(primaryType);
}
PotionEffectType secondaryType = PotionEffectType.getById(secondaryId);
if (secondaryType != null) {
((Beacon) getHolder()).setSecondaryEffect(secondaryType);
}
getItem().add(-1);
}
Aggregations