Java Code Examples for org.bukkit.potion.PotionEffectType#equals()

The following examples show how to use org.bukkit.potion.PotionEffectType#equals() . 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: CraftMetaPotion.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public boolean removeCustomEffect(PotionEffectType type) {
    Validate.notNull(type, "Potion effect type must not be null");

    if (!hasCustomEffects()) {
        return false;
    }

    boolean changed = false;
    Iterator<PotionEffect> iterator = customEffects.iterator();
    while (iterator.hasNext()) {
        PotionEffect effect = iterator.next();
        if (type.equals(effect.getType())) {
            iterator.remove();
            changed = true;
        }
    }
    if (customEffects.isEmpty()) {
        customEffects = null;
    }
    return changed;
}
 
Example 2
Source File: ItemBuilder.java    From Crazy-Crates with MIT License 5 votes vote down vote up
private PotionType getPotionType(PotionEffectType type) {
    if (type != null) {
        if (type.equals(PotionEffectType.FIRE_RESISTANCE)) {
            return PotionType.FIRE_RESISTANCE;
        } else if (type.equals(PotionEffectType.HARM)) {
            return PotionType.INSTANT_DAMAGE;
        } else if (type.equals(PotionEffectType.HEAL)) {
            return PotionType.INSTANT_HEAL;
        } else if (type.equals(PotionEffectType.INVISIBILITY)) {
            return PotionType.INVISIBILITY;
        } else if (type.equals(PotionEffectType.JUMP)) {
            return PotionType.JUMP;
        } else if (type.equals(PotionEffectType.getByName("LUCK"))) {
            return PotionType.valueOf("LUCK");
        } else if (type.equals(PotionEffectType.NIGHT_VISION)) {
            return PotionType.NIGHT_VISION;
        } else if (type.equals(PotionEffectType.POISON)) {
            return PotionType.POISON;
        } else if (type.equals(PotionEffectType.REGENERATION)) {
            return PotionType.REGEN;
        } else if (type.equals(PotionEffectType.SLOW)) {
            return PotionType.SLOWNESS;
        } else if (type.equals(PotionEffectType.SPEED)) {
            return PotionType.SPEED;
        } else if (type.equals(PotionEffectType.INCREASE_DAMAGE)) {
            return PotionType.STRENGTH;
        } else if (type.equals(PotionEffectType.WATER_BREATHING)) {
            return PotionType.WATER_BREATHING;
        } else if (type.equals(PotionEffectType.WEAKNESS)) {
            return PotionType.WEAKNESS;
        }
    }
    return null;
}
 
Example 3
Source File: PotionEffectApplier.java    From EliteMobs with GNU General Public License v3.0 5 votes vote down vote up
private PotionEffect continuousPotionEffect(PotionEffectType potionEffectType, int potionEffectMagnitude) {

        if (potionEffectType.equals(PotionEffectType.NIGHT_VISION)) {
            return new PotionEffect(potionEffectType, 15 * 20, potionEffectMagnitude);
        }
        if (potionEffectType.equals(PotionEffectType.SATURATION)) {
            return new PotionEffect(potionEffectType, 1, potionEffectMagnitude);
        }
        return new PotionEffect(potionEffectType, 5 * 20, potionEffectMagnitude);

    }
 
Example 4
Source File: EntityListener.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPotionSplash(PotionSplashEvent event) {
    RedProtect.get().logger.debug(LogLevel.ENTITY, "EntityListener - Is PotionSplashEvent");

    ProjectileSource thrower = event.getPotion().getShooter();
    for (PotionEffect e : event.getPotion().getEffects()) {
        PotionEffectType t = e.getType();
        if (!t.equals(PotionEffectType.BLINDNESS) && !t.equals(PotionEffectType.CONFUSION) && !t.equals(PotionEffectType.HARM) && !t.equals(PotionEffectType.HUNGER) && !t.equals(PotionEffectType.POISON) && !t.equals(PotionEffectType.SLOW) && !t.equals(PotionEffectType.SLOW_DIGGING) && !t.equals(PotionEffectType.WEAKNESS) && !t.equals(PotionEffectType.WITHER)) {
            return;
        }
    }
    Player shooter;
    if (thrower instanceof Player) {
        shooter = (Player) thrower;
    } else {
        return;
    }
    for (Entity e2 : event.getAffectedEntities()) {
        Region r = RedProtect.get().rm.getTopRegion(e2.getLocation());
        if (event.getEntity() instanceof Player) {
            if (r != null && r.flagExists("pvp") && !r.canPVP((Player) event.getEntity(), shooter)) {
                event.setCancelled(true);
                return;
            }
        } else {
            if (r != null && !r.canInteractPassives(shooter)) {
                event.setCancelled(true);
                return;
            }
        }
    }
}
 
Example 5
Source File: CraftPotionUtil.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static boolean equals(Potion mobEffect, PotionEffectType type) {
    PotionEffectType typeV = PotionEffectType.getById(Potion.getIdFromPotion(mobEffect));
    return typeV.equals(type);
}