final PotionEffect applyEffect = new PotionEffect(effect, duration, amplification); player.addPotionEffect(applyEffect, true); broadcastCommandMessage(sender, String.format("Given %s (ID %d) * %d to %s for %d seconds", effect.getName(), effect.getId(), amplification, args[0], duration_temp));
@Override public boolean giveTo(Player player) { return player.addPotionEffect(effect, true); }
private void updatePlayerSlowness(Player player, double temperature) { if (temperature >= temperatureThreshold) { PotionEffect potionEffect = new PotionEffect(PotionEffectType.SLOW, duration, 1); player.addPotionEffect(potionEffect); } }
private void addPotionEffects() { final int duration = 70; if (this.regenEnabled) { this.player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, duration, this.regenPower)); } if (this.speedEnabled) { this.player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, duration, this.speedPower)); } if (this.resistanceEnabled) { this.player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, duration, this.resistancePower)); } if (this.fireResistanceEnabled) { this.player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, duration, this.fireResistancePower)); } }
bleed = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { public void run() { // Two percent chance you will bleed if (e instanceof Player) { Player player = (Player) e; player.damage(1.0D); player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 200, 2)); player.sendMessage(ChatColor.RED + "You are bleeding, find a bandage and heal yourself"); } } }, 20, 400);
int playersBleed = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { public void run() { // Two percent chance you will bleed if (e instanceof Player) { Player player = (Player) e; player.damage(1.0D); player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 200, 2)); player.sendMessage(ChatColor.RED + "You are bleeding, find a bandage and heal yourself"); } } }, 20, 400); bleed.put(player.getUniqueId(), new Integer(playersBleed));
public void applyBlindness(final Entity entity) { if (entity instanceof Player) { if (Commands.invincible.contains(((Player) entity).getName())) { return; } else if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation())) { return; } final Player p = (Player) entity; p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, this.duration * 20, 2)); BLINDED_TIMES.put(p.getName(), System.currentTimeMillis()); BLINDED_TO_ABILITY.put(p.getName(), this); } }
@Override public void progress() { if (!this.bPlayer.canBendIgnoreBinds(this) || !this.bPlayer.hasElement(Element.CHI)) { this.remove(); return; } if (!this.player.hasPotionEffect(PotionEffectType.SPEED)) { this.player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 60, this.speed, true)); } if (!this.player.hasPotionEffect(PotionEffectType.JUMP)) { this.player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60, this.jump, true)); } }
@Override public void progress() { if (!this.bPlayer.canBendIgnoreBinds(this) || !this.bPlayer.hasElement(Element.CHI)) { this.remove(); return; } if (!this.player.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE)) { this.player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 60, this.resistance, true)); } if (!this.player.hasPotionEffect(PotionEffectType.INCREASE_DAMAGE)) { this.player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 60, this.strength, true)); } }
@Override public void onPickup(Player player) { // Play an effect. player.playEffect(hologram.getLocation(), Effect.MOBSPAWNER_FLAMES, null); // 30 seconds of speed II. player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 30 * 20, 1), true); // Delete the hologram. hologram.delete(); } });
@Override public void run(String playerID) throws QuestRuntimeException { PlayerConverter.getPlayer(playerID).addPotionEffect( new PotionEffect(effect, duration.getInt(playerID) * 20, amplifier.getInt(playerID) - 1, ambient)); }
@Override public PowerResult<Void> tick(Player player, ItemStack stack) { Pair<Long, Double> pair = energys.getIfPresent(player.getUniqueId()); if (pair == null) return PowerResult.noop(); long currentTimeMillis = System.currentTimeMillis(); double energy = pair.getValue() - (currentTimeMillis - pair.getKey()) * energyDecay / 1000; if (energy <= 0) return PowerResult.noop(); int level = (int) (energy / energyPerLevel); player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 5, level)); return PowerResult.ok(); } }
private void applyHealing(final Player player) { if (!GeneralMethods.isRegionProtectedFromBuild(player, "HealingWaters", player.getLocation())) { player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, this.potDuration, this.power)); AirAbility.breakBreathbendingHold(player); this.healing = true; this.healingSelf = true; } }
public void addPerceptionFilter(Player player) { perceptionFilter.addEntry(player.getName()); plugin.getServer().getOnlinePlayers().forEach((olp) -> addPlayer(olp)); player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 15)); }
@Override public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) { if (SlimefunManager.isItemSimiliar(item, SlimefunItems.SPLINT, true)) { PlayerInventory.consumeItemInHand(p); p.getWorld().playSound(p.getLocation(), Sound.ENTITY_SKELETON_HURT, 1, 1); p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0)); return true; } else return false; } });
@Override public PowerResult<Void> fire(Player player, ItemStack stack) { if (!checkCooldown(this, player, cooldown, true, true)) return PowerResult.cd(); if (!getItem().consumeDurability(stack, cost)) return PowerResult.cost(); player.addPotionEffect(new PotionEffect(type, duration, amplifier), true); return PowerResult.ok(); }
@Override public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) { if (SlimefunManager.isItemSimiliar(item, SlimefunItems.MAGIC_SUGAR, true)) { PlayerInventory.consumeItemInHand(p); p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EAT, 1, 1); p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 600, (Integer) Slimefun.getItemValue("MAGIC_SUGAR", "effects.SPEED"))); return true; } else return false; } });
@Override public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) { if (SlimefunManager.isItemSimiliar(item, SlimefunItems.RAG, true)) { PlayerInventory.consumeItemInHand(p); p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, Material.WHITE_WOOL); p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0)); p.setFireTicks(0); return true; } else return false; } });
@Override public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) { if (SlimefunManager.isItemSimiliar(item, SlimefunItems.BANDAGE, true)) { PlayerInventory.consumeItemInHand(p); p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, Material.WHITE_WOOL); p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 1)); p.setFireTicks(0); return true; } else return false; } });
@Override public PowerResult<Void> fire(Player player, ItemStack stack) { if (!checkCooldown(this, player, cooldown, true, true)) return PowerResult.cd(); if (!getItem().consumeDurability(stack, cost)) return PowerResult.cost(); PotionEffect effect = new PotionEffect(type, duration, amplifier - 1); if (selfapplication) { player.addPotionEffect(effect); } player.getWorld().playEffect(player.getLocation(), Effect.POTION_BREAK, type.getColor().asRGB()); for (Entity ent : getNearbyEntities(this, player.getLocation(), player, range)) { if (ent instanceof LivingEntity && !player.equals(ent)) { ((LivingEntity) ent).addPotionEffect(effect); } } return PowerResult.ok(); }