Java Code Examples for org.bukkit.event.entity.PotionSplashEvent#getPotion()

The following examples show how to use org.bukkit.event.entity.PotionSplashEvent#getPotion() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DamageMatchModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPotionSplash(final PotionSplashEvent event) {
  ThrownPotion potion = event.getPotion();
  if (!PotionClassifier.isHarmful(potion)) return;

  for (LivingEntity entity : event.getAffectedEntities()) {
    ParticipantState victim = match.getParticipantState(entity);
    DamageInfo damageInfo =
        tracker().resolveDamage(EntityDamageEvent.DamageCause.MAGIC, entity, potion);

    if (victim != null && queryDamage(event, victim, damageInfo).isDenied()) {
      event.setIntensity(entity, 0);
    }
  }
}
 
Example 2
Source File: DamageMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPotionSplash(final PotionSplashEvent event) {
    final ThrownPotion potion = event.getPotion();
    if(PotionClassification.classify(potion) != PotionClassification.HARMFUL) return;

    for(LivingEntity victim : event.getAffectedEntities()) {
        final ParticipantState victimState = getMatch().getParticipantState(victim);
        final DamageInfo damageInfo = damageResolver.resolveDamage(EntityDamageEvent.DamageCause.MAGIC, victim, potion);

        if(victimState != null && queryDamage(event, victimState, damageInfo).isDenied()) {
            event.setIntensity(victim, 0);
        }
    }
}
 
Example 3
Source File: EntityListener.java    From Guilds with MIT License 5 votes vote down vote up
/**
 * Handles splash potions+
 *
 * @param event
 */
@EventHandler
public void onSplash(PotionSplashEvent event) {
    boolean isHarming = false;
    for (PotionEffect effect : event.getPotion().getEffects()) {
        if (bad.contains(effect.getType())) {
            isHarming = true;
            break;
        }
    }

    if (!isHarming)
        return;

    ThrownPotion potion = event.getPotion();

    if (!(potion.getShooter() instanceof Player))
        return;

    Player shooter = (Player) potion.getShooter();

    for (LivingEntity entity : event.getAffectedEntities()) {
        if (entity instanceof Player) {
            Player player = (Player) entity;
            if (guildHandler.isSameGuild(shooter, player) && potion.getShooter() != player) {
                event.setCancelled(!settingsManager.getProperty(GuildSettings.GUILD_DAMAGE));
                return;
            }
            if (guildHandler.isAlly(shooter, player)) {
                event.setCancelled(!settingsManager.getProperty(GuildSettings.ALLY_DAMAGE));
            }
        }
    }

}