Java Code Examples for org.bukkit.entity.LivingEntity#addPotionEffects()

The following examples show how to use org.bukkit.entity.LivingEntity#addPotionEffects() . 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: ProjectileMatchModule.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onProjectileHurtEvent(EntityDamageByEntityEvent event) {
  if (!(event.getEntity() instanceof LivingEntity)) return;
  LivingEntity damagedEntity = (LivingEntity) event.getEntity();

  ProjectileDefinition projectileDefinition =
      ProjectileMatchModule.getProjectileDefinition(event.getDamager());

  if (projectileDefinition != null) {
    if (!projectileDefinition.potion.isEmpty()) {
      damagedEntity.addPotionEffects(projectileDefinition.potion);
    }

    if (projectileDefinition.damage != null) {
      event.setDamage(projectileDefinition.damage);
    }
  }
}
 
Example 2
Source File: ProjectileMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onProjectileHurtEvent(EntityDamageByEntityEvent event) {
    if(!(event.getEntity() instanceof LivingEntity)) return;
    final LivingEntity damagedEntity = (LivingEntity) event.getEntity();

    final ProjectileDefinition projectileDefinition = Projectiles.getProjectileDefinition(event.getDamager());
    if(projectileDefinition == null) return;

    if(!projectileDefinition.potion().isEmpty()) {
        damagedEntity.addPotionEffects(projectileDefinition.potion());
    }

    if(projectileDefinition.damage() != null) {
        event.setDamage(projectileDefinition.damage());
    }
}
 
Example 3
Source File: Potion.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Applies the effects that would be applied by this potion to the given
 * {@link LivingEntity}.
 *
 * @param to The entity to apply the effects to
 * @see LivingEntity#addPotionEffects(Collection)
 */
public void apply(LivingEntity to) {
    Validate.notNull(to, "entity cannot be null");
    to.addPotionEffects(getEffects());
}
 
Example 4
Source File: PotionEffectSerializer.java    From PerWorldInventory with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Add the given PotionEffects to a LivingEntity.
 *
 * @param code   The PotionEffects to add.
 * @param entity The entity to add the PotionEffects.
 *
 * @deprecated Magic numbers.
 */
@Deprecated
public static void addPotionEffects(String code, LivingEntity entity) {
    entity.addPotionEffects(deserialize(code));
}
 
Example 5
Source File: PotionEffectSerializer.java    From PerWorldInventory with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Deserialize the given PotionEffects and apply them to a LivingEntity.
 *
 * @param effects The PotionEffects to add.
 * @param entity The entity to apply the effects to.
 */
public static void addPotionEffects(JsonArray effects, LivingEntity entity) {
    entity.addPotionEffects(deserialize(effects));
}
 
Example 6
Source File: PotionEffectSerializer.java    From PerWorldInventory with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Add the given PotionEffects to a LivingEntity.
 *
 * @param code   The PotionEffects to add.
 * @param entity The entity to add the PotionEffects.
 *
 * @deprecated Magic numbers.
 */
@Deprecated
public static void addPotionEffects(String code, LivingEntity entity) {
    entity.addPotionEffects(deserialize(code));
}
 
Example 7
Source File: PotionEffectSerializer.java    From PerWorldInventory with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Deserialize the given PotionEffects and apply them to a LivingEntity.
 *
 * @param effects The PotionEffects to add.
 * @param entity The entity to apply the effects to.
 */
public static void addPotionEffects(JsonArray effects, LivingEntity entity) {
    entity.addPotionEffects(deserialize(effects));
}