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);
}
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);
}
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();
}
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());
}
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);
}
Aggregations