Search in sources :

Example 31 with PotionEffect

use of org.bukkit.potion.PotionEffect in project MyPet by xXKeyleXx.

the class Slow method slowTarget.

public void slowTarget(LivingEntity target) {
    PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, getDuration() * 20, 1, false);
    target.addPotionEffect(effect);
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect)

Example 32 with PotionEffect

use of org.bukkit.potion.PotionEffect in project MyPet by xXKeyleXx.

the class Wither method witherTarget.

public void witherTarget(LivingEntity target) {
    PotionEffect effect = new PotionEffect(PotionEffectType.WITHER, getDuration() * 20, 1, false);
    target.addPotionEffect(effect);
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect)

Example 33 with PotionEffect

use of org.bukkit.potion.PotionEffect in project Sentinel by mcmonkey4eva.

the class SentinelTrait method fireArrow.

public void fireArrow(ItemStack type, Location target, Vector lead) {
    HashMap.SimpleEntry<Location, Vector> start = getLaunchDetail(target, lead);
    if (start == null || start.getKey() == null) {
        return;
    }
    stats_arrowsFired++;
    Entity arrow;
    if (SentinelTarget.v1_9) {
        arrow = start.getKey().getWorld().spawnEntity(start.getKey(), type.getType() == Material.SPECTRAL_ARROW ? EntityType.SPECTRAL_ARROW : (type.getType() == Material.TIPPED_ARROW ? EntityType.TIPPED_ARROW : EntityType.ARROW));
        ((Projectile) arrow).setShooter(getLivingEntity());
        if (arrow instanceof TippedArrow) {
            PotionData data = ((PotionMeta) type.getItemMeta()).getBasePotionData();
            if (data.getType() == null || data.getType() == PotionType.UNCRAFTABLE) {
            // TODO: Perhaps a **single** warning?
            } else {
                ((TippedArrow) arrow).setBasePotionData(data);
                for (PotionEffect effect : ((PotionMeta) type.getItemMeta()).getCustomEffects()) {
                    ((TippedArrow) arrow).addCustomEffect(effect, true);
                }
            }
        }
    } else {
        arrow = start.getKey().getWorld().spawnEntity(start.getKey(), EntityType.ARROW);
        ((Projectile) arrow).setShooter(getLivingEntity());
    }
    arrow.setVelocity(fixForAcc(start.getValue()));
    if (npc.getTrait(Inventory.class).getContents()[0].containsEnchantment(Enchantment.ARROW_FIRE)) {
        arrow.setFireTicks(10000);
    }
    useItem();
}
Also used : PotionData(org.bukkit.potion.PotionData) PotionEffect(org.bukkit.potion.PotionEffect) PotionMeta(org.bukkit.inventory.meta.PotionMeta) Vector(org.bukkit.util.Vector) Inventory(net.citizensnpcs.api.trait.trait.Inventory)

Example 34 with PotionEffect

use of org.bukkit.potion.PotionEffect in project PyrCore by PYRRH4.

the class PlayerData method restore.

// ------------------------------------------------------------
// Restore the data
// ------------------------------------------------------------
public static void restore(final Player player) {
    if (Core.instance().getPlayerDataInstance().lastInventory.containsKey(player.getUniqueId())) {
        player.getInventory().setContents(Core.instance().getPlayerDataInstance().lastInventory.get(player.getUniqueId()));
    }
    if (Core.instance().getPlayerDataInstance().lastArmor.containsKey(player.getUniqueId())) {
        player.getInventory().setArmorContents(Core.instance().getPlayerDataInstance().lastArmor.get(player.getUniqueId()));
    }
    player.updateInventory();
    if (Core.instance().getPlayerDataInstance().lastScoreboard.containsKey(player.getUniqueId())) {
        Scoreboard scoreboard = Core.instance().getPlayerDataInstance().lastScoreboard.get(player.getUniqueId());
        if (scoreboard == null) {
            scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
        }
        player.setScoreboard(Core.instance().getPlayerDataInstance().lastScoreboard.get(player.getUniqueId()));
    } else {
        player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
    }
    // PotionEffects
    Utils.resetEffects(player);
    if (Core.instance().getPlayerDataInstance().lastPotionEffects.containsKey(player.getUniqueId())) {
        for (PotionEffect effect : Core.instance().getPlayerDataInstance().lastPotionEffects.get(player.getUniqueId())) player.addPotionEffect(effect);
    }
    // Other
    Utils.resetWalkSpeed(player);
    Utils.resetGameMode(player);
    Utils.showToAll(player);
    if (Core.instance().getPlayerDataInstance().allowFly.containsKey(player.getUniqueId())) {
        Utils.allowFly(player, Core.instance().getPlayerDataInstance().allowFly.get(player.getUniqueId()));
    }
    if (Core.instance().getPlayerDataInstance().gamemodes.containsKey(player.getUniqueId())) {
        player.setGameMode(Core.instance().getPlayerDataInstance().gamemodes.get(player.getUniqueId()));
    }
    Core.instance().getPlayerDataInstance().lastInventory.remove(player.getUniqueId());
    Core.instance().getPlayerDataInstance().lastArmor.remove(player.getUniqueId());
    Core.instance().getPlayerDataInstance().lastScoreboard.remove(player.getUniqueId());
    Core.instance().getPlayerDataInstance().lastPotionEffects.remove(player.getUniqueId());
    Core.instance().getPlayerDataInstance().allowFly.remove(player.getUniqueId());
    Core.instance().getPlayerDataInstance().gamemodes.remove(player.getUniqueId());
}
Also used : Scoreboard(org.bukkit.scoreboard.Scoreboard) PotionEffect(org.bukkit.potion.PotionEffect)

Example 35 with PotionEffect

use of org.bukkit.potion.PotionEffect in project CommandHelper by EngineHub.

the class BukkitMCPotionMeta method addCustomEffect.

@Override
public boolean addCustomEffect(int potionID, int strength, int ticks, boolean ambient, boolean overwrite, Target t) {
    int maxID = PotionEffectType.values().length;
    if (potionID < 1 || potionID > maxID) {
        throw new CRERangeException("Invalid effect ID, must be from 1-" + maxID, t);
    }
    PotionEffect pe = new PotionEffect(PotionEffectType.getById(potionID), ticks, strength, ambient);
    return pm.addCustomEffect(pe, overwrite);
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect) CRERangeException(com.laytonsmith.core.exceptions.CRE.CRERangeException)

Aggregations

PotionEffect (org.bukkit.potion.PotionEffect)224 Player (org.bukkit.entity.Player)61 PotionEffectType (org.bukkit.potion.PotionEffectType)39 Location (org.bukkit.Location)37 LivingEntity (org.bukkit.entity.LivingEntity)37 EventHandler (org.bukkit.event.EventHandler)36 ItemStack (org.bukkit.inventory.ItemStack)34 ArrayList (java.util.ArrayList)31 Entity (org.bukkit.entity.Entity)23 PotionMeta (org.bukkit.inventory.meta.PotionMeta)18 Vector (org.bukkit.util.Vector)16 Random (java.util.Random)14 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)11 ItemMeta (org.bukkit.inventory.meta.ItemMeta)10 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)9 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)9 Material (org.bukkit.Material)7 Enchantment (org.bukkit.enchantments.Enchantment)7 Projectile (org.bukkit.entity.Projectile)7 PotionData (org.bukkit.potion.PotionData)7