Java Code Examples for org.bukkit.potion.PotionEffect
The following examples show how to use
org.bukkit.potion.PotionEffect.
These examples are extracted from open source projects.
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 Project: CardinalPGM Author: twizmwazin File: FriendlyFire.java License: MIT License | 6 votes |
@EventHandler public void onPotionSplash(PotionSplashEvent event) { boolean proceed = false; for (PotionEffect effect : event.getPotion().getEffects()) { if (effect.getType().equals(PotionEffectType.POISON) || effect.getType().equals(PotionEffectType.BLINDNESS) || effect.getType().equals(PotionEffectType.CONFUSION) || effect.getType().equals(PotionEffectType.HARM) || effect.getType().equals(PotionEffectType.HUNGER) || effect.getType().equals(PotionEffectType.SLOW) || effect.getType().equals(PotionEffectType.SLOW_DIGGING) || effect.getType().equals(PotionEffectType.WITHER) || effect.getType().equals(PotionEffectType.WEAKNESS)) { proceed = true; } } if (proceed && event.getPotion().getShooter() instanceof Player && Teams.getTeamByPlayer((Player) event.getPotion().getShooter()) != null) { Optional<TeamModule> team = Teams.getTeamByPlayer((Player) event.getPotion().getShooter()); for (LivingEntity affected : event.getAffectedEntities()) { if (affected instanceof Player && Teams.getTeamByPlayer((Player) affected) != null && Teams.getTeamByPlayer((Player) affected).equals(team) && !affected.equals(event.getPotion().getShooter())) { event.setIntensity(affected, 0); } } } }
Example #2
Source Project: UhcCore Author: Mezy File: TeleportPlayersThread.java License: GNU General Public License v3.0 | 6 votes |
@Override public void run() { for(UhcPlayer uhcPlayer : team.getMembers()){ Player player; try { player = uhcPlayer.getPlayer(); }catch (UhcPlayerNotOnlineException ex){ continue; } Bukkit.getLogger().info("[UhcCore] Teleporting "+player.getName()); for(PotionEffect effect : GameManager.getGameManager().getConfiguration().getPotionEffectOnStart()){ player.addPotionEffect(effect); } uhcPlayer.freezePlayer(team.getStartingLocation()); player.teleport(team.getStartingLocation()); player.removePotionEffect(PotionEffectType.BLINDNESS); player.removePotionEffect(PotionEffectType.SLOW_DIGGING); player.setFireTicks(0); uhcPlayer.setHasBeenTeleportedToLocation(true); } }
Example #3
Source Project: PGM Author: PGMDev File: XMLUtils.java License: GNU Affero General Public License v3.0 | 6 votes |
public static PotionEffect parseCompactPotionEffect(Node node, String text) throws InvalidXMLException { String[] parts = text.split(":"); if (parts.length == 0) throw new InvalidXMLException("Missing potion effect type", node); PotionEffectType type = parsePotionEffectType(node, parts[0]); Duration duration = TimeUtils.INFINITE_DURATION; int amplifier = 0; boolean ambient = false; if (parts.length >= 2) { duration = parseTickDuration(node, parts[1]); if (parts.length >= 3) { amplifier = parseNumber(node, parts[2], Integer.class); if (parts.length >= 4) { ambient = parseBoolean(node, parts[3]); } } } return createPotionEffect(type, duration, amplifier, ambient); }
Example #4
Source Project: Thermos Author: CyberdyneCC File: CraftMetaPotion.java License: GNU General Public License v3.0 | 6 votes |
public boolean addCustomEffect(PotionEffect effect, boolean overwrite) { Validate.notNull(effect, "Potion effect must not be null"); int index = indexOfEffect(effect.getType()); if (index != -1) { if (overwrite) { PotionEffect old = customEffects.get(index); if (old.getAmplifier() == effect.getAmplifier() && old.getDuration() == effect.getDuration() && old.isAmbient() == effect.isAmbient()) { return false; } customEffects.set(index, effect); return true; } else { return false; } } else { if (customEffects == null) { customEffects = new ArrayList<PotionEffect>(); } customEffects.add(effect); return true; } }
Example #5
Source Project: PGM Author: PGMDev File: KitParser.java License: GNU Affero General Public License v3.0 | 6 votes |
public List<PotionEffect> parsePotions(Element el) throws InvalidXMLException { List<PotionEffect> effects = new ArrayList<>(); Node attr = Node.fromAttr(el, "potion", "potions", "effect", "effects"); if (attr != null) { for (String piece : attr.getValue().split(";")) { effects.add(XMLUtils.parseCompactPotionEffect(attr, piece)); } } for (Node elPotion : Node.fromChildren(el, "potion", "effect")) { effects.add(XMLUtils.parsePotionEffect(elPotion.getElement())); } return effects; }
Example #6
Source Project: MineTinker Author: Flo56958 File: Withered.java License: GNU General Public License v3.0 | 6 votes |
public PotionEffect getPotionEffect(@Nullable Event event, @Nullable Entity entity, @NotNull Player player, @NotNull ItemStack tool) { int level = modManager.getModLevel(tool, this); int duration = (int) (this.duration * Math.pow(this.durationMultiplier, (level - 1))); int amplifier = this.effectAmplifier * (level - 1); if (entity == null) { ChatWriter.logModifier(player, event, this, tool, "Duration(" + duration + ")", "Amplifier(" + amplifier + ")"); } else { ChatWriter.logModifier(player, event, this, tool, "Duration(" + duration + ")", "Amplifier(" + amplifier + ")", "Entity(" + entity.getType().toString() + ")"); } return new PotionEffect(PotionEffectType.WITHER, duration, amplifier, false, false); }
Example #7
Source Project: MineTinker Author: Flo56958 File: Shulking.java License: GNU General Public License v3.0 | 6 votes |
public PotionEffect getPotionEffect(@Nullable Event event, @Nullable Entity entity, @NotNull Player player, @NotNull ItemStack tool) { int level = modManager.getModLevel(tool, this); int amplifier = this.effectAmplifier * (level - 1); if (entity == null) { ChatWriter.logModifier(player, event, this, tool, "Duration(" + duration + ")", "Amplifier(" + amplifier + ")"); } else { ChatWriter.logModifier(player, event, this, tool, "Duration(" + duration + ")", "Amplifier(" + amplifier + ")", "Entity(" + entity.getType().toString() + ")"); } return new PotionEffect(PotionEffectType.LEVITATION, this.duration, amplifier, false, false); }
Example #8
Source Project: MineTinker Author: Flo56958 File: Webbed.java License: GNU General Public License v3.0 | 6 votes |
public PotionEffect getPotionEffect(@Nullable Event event, @Nullable Entity entity, @NotNull Player player, @NotNull ItemStack tool) { int level = modManager.getModLevel(tool, this); int duration = (int) (this.duration * Math.pow(this.durationMultiplier, (level - 1))); int amplifier = this.effectAmplifier * (level - 1); if (entity == null) { ChatWriter.logModifier(player, event, this, tool, "Duration(" + duration + ")", "Amplifier(" + amplifier + ")"); } else { ChatWriter.logModifier(player, event, this, tool, "Duration(" + duration + ")", "Amplifier(" + amplifier + ")", "Entity(" + entity.getType().toString() + ")"); } return new PotionEffect(PotionEffectType.SLOW, duration, amplifier, false, false); }
Example #9
Source Project: MineTinker Author: Flo56958 File: Poisonous.java License: GNU General Public License v3.0 | 6 votes |
public PotionEffect getPotionEffect(@Nullable Event event, @Nullable Entity entity, @NotNull Player player, @NotNull ItemStack tool) { int level = modManager.getModLevel(tool, this); int duration = (int) (this.duration * Math.pow(this.durationMultiplier, (level - 1))); int amplifier = this.effectAmplifier * (level - 1); if (entity == null) { ChatWriter.logModifier(player, event, this, tool, "Duration(" + duration + ")", "Amplifier(" + amplifier + ")"); } else { ChatWriter.logModifier(player, event, this, tool, "Duration(" + duration + ")", "Amplifier(" + amplifier + ")", "Entity(" + entity.getType().toString() + ")"); } return new PotionEffect(PotionEffectType.POISON, duration, amplifier, false, false); }
Example #10
Source Project: Thermos Author: CyberdyneCC File: CraftMetaPotion.java License: GNU General Public License v3.0 | 6 votes |
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 (effect.getType() == type) { iterator.remove(); changed = true; } } return changed; }
Example #11
Source Project: PerWorldInventory Author: EbonJaeger File: PotionEffectSerializer.java License: GNU General Public License v3.0 | 6 votes |
/** * Serialize a Collection of PotionEffects into a JsonArray of JsonObjects. Each * JsonObject contains the type, amplifier, duration and color of a potion effect. * The color is saved in the RGB format. * * @param effects The PotionEffects to serialize * @return A JsonArray of JsonObjects of serialized PotionEffects. */ public static JsonArray serialize(Collection<PotionEffect> effects) { JsonArray all = new JsonArray(); for (PotionEffect effect : effects) { JsonObject pot = new JsonObject(); pot.addProperty("type", effect.getType().getName()); pot.addProperty("amp", effect.getAmplifier()); pot.addProperty("duration", effect.getDuration()); pot.addProperty("ambient", effect.isAmbient()); pot.addProperty("particles", effect.hasParticles()); // TODO: Figure out what version of Spigot this method was added. /*if (effect.getColor() != null) { pot.addProperty("color", effect.getColor().asRGB()); }*/ all.add(pot); } return all; }
Example #12
Source Project: Slimefun4 Author: TheBusyBiscuit File: ArmorTask.java License: GNU General Public License v3.0 | 6 votes |
private void handleSlimefunArmor(Player p, ItemStack[] armor, HashedArmorpiece[] cachedArmor) { for (int slot = 0; slot < 4; slot++) { ItemStack item = armor[slot]; HashedArmorpiece armorpiece = cachedArmor[slot]; if (armorpiece.hasDiverged(item)) { SlimefunItem sfItem = SlimefunItem.getByItem(item); if (!(sfItem instanceof SlimefunArmorPiece) || !Slimefun.hasUnlocked(p, sfItem, true)) { sfItem = null; } armorpiece.update(item, sfItem); } if (item != null && armorpiece.getItem().isPresent()) { Slimefun.runSync(() -> { for (PotionEffect effect : armorpiece.getItem().get().getPotionEffects()) { p.removePotionEffect(effect.getType()); p.addPotionEffect(effect); } }); } } }
Example #13
Source Project: Slimefun4 Author: TheBusyBiscuit File: Bandage.java License: GNU General Public License v3.0 | 6 votes |
@Override public ItemUseHandler getItemHandler() { return e -> { Player p = e.getPlayer(); // Player is neither burning nor injured if (p.getFireTicks() <= 0 && p.getHealth() >= p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) { return; } if (p.getGameMode() != GameMode.CREATIVE) { ItemUtils.consumeItem(e.getItem(), false); } p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, Material.WHITE_WOOL); p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 1)); p.setFireTicks(0); e.cancel(); }; }
Example #14
Source Project: Skript Author: SkriptLang File: EffPoison.java License: GNU General Public License v3.0 | 6 votes |
@Override protected void execute(final Event e) { for (final LivingEntity le : entites.getArray(e)) { if (!cure) { Timespan dur; int d = (int) (duration != null && (dur = duration.getSingle(e)) != null ? (dur.getTicks_i() >= Integer.MAX_VALUE ? Integer.MAX_VALUE : dur.getTicks_i()) : DEFAULT_DURATION); if (le.hasPotionEffect(PotionEffectType.POISON)) { for (final PotionEffect pe : le.getActivePotionEffects()) { if (pe.getType() != PotionEffectType.POISON) continue; d += pe.getDuration(); } } le.addPotionEffect(new PotionEffect(PotionEffectType.POISON, d, 0), true); } else { le.removePotionEffect(PotionEffectType.POISON); } } }
Example #15
Source Project: Kettle Author: KettleFoundation File: CraftMetaPotion.java License: GNU General Public License v3.0 | 6 votes |
@Override void applyToItem(NBTTagCompound tag) { super.applyToItem(tag); tag.setString(DEFAULT_POTION.NBT, (this.type.getType() == PotionType.UNCRAFTABLE && emptyType != null) ? emptyType : CraftPotionUtil.fromBukkit(type)); if (hasColor()) { tag.setInteger(POTION_COLOR.NBT, color.asRGB()); } if (customEffects != null) { NBTTagList effectList = new NBTTagList(); tag.setTag(POTION_EFFECTS.NBT, effectList); for (PotionEffect effect : customEffects) { NBTTagCompound effectData = new NBTTagCompound(); effectData.setByte(ID.NBT, (byte) effect.getType().getId()); effectData.setByte(AMPLIFIER.NBT, (byte) effect.getAmplifier()); effectData.setInteger(DURATION.NBT, effect.getDuration()); effectData.setBoolean(AMBIENT.NBT, effect.isAmbient()); effectData.setBoolean(SHOW_PARTICLES.NBT, effect.hasParticles()); effectList.appendTag(effectData); } } }
Example #16
Source Project: BedWars Author: ScreamingSandals File: GamePlayer.java License: GNU Lesser General Public License v3.0 | 5 votes |
public void restoreInv() { isTeleportingFromGame_justForInventoryPlugins = true; if (!Main.getConfigurator().config.getBoolean("mainlobby.enabled")) { teleport(oldInventory.leftLocation); } player.getInventory().setContents(oldInventory.inventory); player.getInventory().setArmorContents(oldInventory.armor); player.addPotionEffects(oldInventory.effects); player.setLevel(oldInventory.level); player.setExp(oldInventory.xp); player.setFoodLevel(oldInventory.foodLevel); for (PotionEffect e : player.getActivePotionEffects()) player.removePotionEffect(e.getType()); player.addPotionEffects(oldInventory.effects); player.setPlayerListName(oldInventory.listName); player.setDisplayName(oldInventory.displayName); player.setGameMode(oldInventory.mode); if (oldInventory.mode == GameMode.CREATIVE) player.setAllowFlight(true); else player.setAllowFlight(false); player.updateInventory(); player.resetPlayerTime(); player.resetPlayerWeather(); }
Example #17
Source Project: WorldGuardExtraFlagsPlugin Author: isokissa3 File: GiveEffectsFlagHandler.java License: MIT License | 5 votes |
public void drinkPotion(Player player, Collection<PotionEffect> effects) { for(PotionEffect effect : effects) { this.removedEffects.put(effect.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect.getAmplifier(), effect.isAmbient(), SupportedFeatures.isPotionEffectParticles() ? effect.hasParticles() : true)); } this.check(player, WorldGuardUtils.getCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation())); }
Example #18
Source Project: RedProtect Author: FabioZumbi12 File: EntityListener.java License: GNU General Public License v3.0 | 5 votes |
@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 #19
Source Project: Thermos Author: CyberdyneCC File: CraftMetaPotion.java License: GNU General Public License v3.0 | 5 votes |
CraftMetaPotion(CraftMetaItem meta) { super(meta); if (!(meta instanceof CraftMetaPotion)) { return; } CraftMetaPotion potionMeta = (CraftMetaPotion) meta; if (potionMeta.hasCustomEffects()) { this.customEffects = new ArrayList<PotionEffect>(potionMeta.customEffects); } }
Example #20
Source Project: PGM Author: PGMDev File: Alive.java License: GNU Affero General Public License v3.0 | 5 votes |
private void playDeathEffect(@Nullable ParticipantState killer) { playDeathSound(killer); // negative health boost potions sometimes change max health for (PotionEffect effect : bukkit.getActivePotionEffects()) { // Keep speed and NV for visual continuity if (effect.getType() != null && !PotionEffectType.NIGHT_VISION.equals(effect.getType()) && !PotionEffectType.SPEED.equals(effect.getType())) { bukkit.removePotionEffect(effect.getType()); } } // Flash/wobble the screen. If we don't delay this then the client glitches out // when the player dies from a potion effect. I have no idea why it happens, // but this fixes it. We could investigate a better fix at some point. smm.getMatch() .getExecutor(MatchScope.LOADED) .execute( () -> { if (bukkit.isOnline()) { bukkit.addPotionEffect( new PotionEffect( PotionEffectType.BLINDNESS, options.blackout ? Integer.MAX_VALUE : 21, 0, true, false), true); bukkit.addPotionEffect( new PotionEffect(PotionEffectType.CONFUSION, 100, 0, true, false), true); } }); }
Example #21
Source Project: ce Author: Taiterio File: AssassinsBlade.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean effect(Event event, final Player player) { if(event instanceof PlayerInteractEvent) { if(!player.hasMetadata("ce.assassin")) if(player.isSneaking()) player.setMetadata("ce.assassin", new FixedMetadataValue(main, null)); player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, InvisibilityDuration, 0, true), true); player.sendMessage(ChatColor.GRAY + "" + ChatColor.ITALIC + "You hide in the shadows."); new BukkitRunnable() { @Override public void run() { if(player.hasMetadata("ce.assassin")) { player.removeMetadata("ce.assassin", main); player.sendMessage(ChatColor.GRAY + "" + ChatColor.ITALIC + "You are no longer hidden!"); } } }.runTaskLater(main, InvisibilityDuration); return true; } if(event instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent e = ((EntityDamageByEntityEvent) event); if(e.getDamager() == player && player.hasMetadata("ce.assassin")) { e.setDamage(e.getDamage() * AmbushDmgMultiplier); player.removeMetadata("ce.assassin", main); player.removePotionEffect(PotionEffectType.INVISIBILITY); EffectManager.playSound(e.getEntity().getLocation(), "BLOCK_PISTON_EXTEND", 0.4f, 0.1f); player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, WeaknessLength, WeaknessLevel, false), true); player.sendMessage(ChatColor.GRAY + "" + ChatColor.ITALIC + "You are no longer hidden!"); } } return false; }
Example #22
Source Project: EliteMobs Author: MagmaGuy File: MoonWalk.java License: GNU General Public License v3.0 | 5 votes |
@Override public void applyPowers(Entity entity) { new BukkitRunnable() { @Override public void run() { ((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 100000, 3)); } }.runTaskLater(MetadataHandler.PLUGIN, 1); }
Example #23
Source Project: SkyWarsReloaded Author: walrusone File: Util.java License: GNU General Public License v3.0 | 5 votes |
public void clear(final Player player) { player.getInventory().clear(); player.getInventory().setArmorContents((ItemStack[])null); for (final PotionEffect a1 : player.getActivePotionEffects()) { player.removePotionEffect(a1.getType()); } }
Example #24
Source Project: AnnihilationPro Author: MrLittleKitty File: Swapper.java License: MIT License | 5 votes |
@Override protected boolean performSpecialAction(Player player, AnniPlayer p) { if(p.getTeam() != null) { Player e = instance.getPlayerInSightTest(player, 15); if(e != null) { AnniPlayer pl = AnniPlayer.getPlayer(e.getUniqueId()); if(pl != null && !pl.getTeam().equals(p.getTeam())) { Location playerLoc = player.getLocation().clone(); Location entityLoc = e.getLocation().clone(); Vector playerLook = playerLoc.getDirection(); Vector playerVec = playerLoc.toVector(); Vector entityVec = entityLoc.toVector(); Vector toVec = playerVec.subtract(entityVec).normalize(); e.teleport(playerLoc.setDirection(playerLook.normalize())); player.teleport(entityLoc.setDirection(toVec)); e.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 3, 1)); return true; } } } return false; }
Example #25
Source Project: EliteMobs Author: MagmaGuy File: NPCEntity.java License: GNU General Public License v3.0 | 5 votes |
/** * Sets the NPCEntity's ability to move * * @param canMove Sets if the NPCEntity can move */ public void setCanMove(boolean canMove) { this.canMove = canMove; this.villager.setAI(canMove); if (!canMove) villager.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 3)); }
Example #26
Source Project: CardinalPGM Author: twizmwazin File: Parser.java License: MIT License | 5 votes |
public static PotionEffect getPotion(Element potion) { PotionEffectType type = PotionEffectType.getByName(Strings.getTechnicalName(potion.getText())); if (type == null) type = new CraftPotionEffectType(MobEffectList.getByName(potion.getText().toLowerCase().replace(" ","_"))); int duration = (int) (Strings.timeStringToExactSeconds(potion.getAttributeValue("duration")) * 20); int amplifier = 0; boolean ambient = false; if (potion.getAttributeValue("amplifier") != null) amplifier = Numbers.parseInt(potion.getAttributeValue("amplifier")) - 1; if (potion.getAttributeValue("ambient") != null) ambient = Boolean.parseBoolean(potion.getAttributeValue("ambient").toUpperCase()); return new PotionEffect(type, duration, amplifier, ambient); }
Example #27
Source Project: PerWorldInventory Author: EbonJaeger File: PotionEffectSerializer.java License: GNU General Public License v3.0 | 5 votes |
/** * Remove any PotionEffects the entity currently has, then apply the new effects. * * @param effects The PotionEffects to apply. * @param entity The entity to apply the effects to. */ public static void setPotionEffects(JsonArray effects, LivingEntity entity) { if (entity.getActivePotionEffects() != null && !entity.getActivePotionEffects().isEmpty()) { for (PotionEffect effect : entity.getActivePotionEffects()) { entity.removePotionEffect(effect.getType()); } } addPotionEffects(effects, entity); }
Example #28
Source Project: askyblock Author: tastybento File: AcidEffect.java License: GNU General Public License v2.0 | 5 votes |
/** * Check if player is safe from rain * @param player * @return true if they are safe */ private boolean isSafeFromRain(Player player) { if (DEBUG) plugin.getLogger().info("DEBUG: safe from acid rain"); if (!player.getWorld().equals(ASkyBlock.getIslandWorld())) { if (DEBUG) plugin.getLogger().info("DEBUG: wrong world"); return true; } // Check if player has a helmet on and helmet protection is true if (Settings.helmetProtection && (player.getInventory().getHelmet() != null && player.getInventory().getHelmet().getType().name().contains("HELMET"))) { if (DEBUG) plugin.getLogger().info("DEBUG: wearing helmet."); return true; } // Check potions Collection<PotionEffect> activePotions = player.getActivePotionEffects(); for (PotionEffect s : activePotions) { if (s.getType().equals(PotionEffectType.WATER_BREATHING)) { // Safe! if (DEBUG) plugin.getLogger().info("DEBUG: potion"); return true; } } // Check if all air above player for (int y = player.getLocation().getBlockY() + 2; y < player.getLocation().getWorld().getMaxHeight(); y++) { if (!player.getLocation().getWorld().getBlockAt(player.getLocation().getBlockX(), y, player.getLocation().getBlockZ()).getType().equals(Material.AIR)) { if (DEBUG) plugin.getLogger().info("DEBUG: something other than air above player"); return true; } } if (DEBUG) plugin.getLogger().info("DEBUG: acid rain damage"); return false; }
Example #29
Source Project: CardinalPGM Author: twizmwazin File: Players.java License: MIT License | 5 votes |
public static void resetPlayer(Player player, boolean heal) { if (heal) player.setHealth(player.getMaxHealth()); player.setFoodLevel(20); player.setSaturation(20); player.getInventory().clear(); player.getInventory().setArmorContents(new ItemStack[]{new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR)}); for (PotionEffect effect : player.getActivePotionEffects()) { try { player.removePotionEffect(effect.getType()); } catch (NullPointerException ignored) { } } player.setTotalExperience(0); player.setExp(0); player.setLevel(0); player.setPotionParticles(false); player.setWalkSpeed(0.2F); player.setFlySpeed(0.1F); player.setKnockbackReduction(0); player.setArrowsStuck(0); player.hideTitle(); player.setFastNaturalRegeneration(false); for (Attribute attribute : Attribute.values()) { if (player.getAttribute(attribute) == null) continue; for (AttributeModifier modifier : player.getAttribute(attribute).getModifiers()) { player.getAttribute(attribute).removeModifier(modifier); } } player.getAttribute(Attribute.GENERIC_ATTACK_SPEED).addModifier(new AttributeModifier(UUID.randomUUID(), "generic.attackSpeed", 4.001D, AttributeModifier.Operation.ADD_SCALAR)); player.getAttribute(Attribute.ARROW_ACCURACY).addModifier(new AttributeModifier(UUID.randomUUID(), "sportbukkit.arrowAccuracy", -1D, AttributeModifier.Operation.ADD_NUMBER)); player.getAttribute(Attribute.ARROW_VELOCITY_TRANSFER).addModifier(new AttributeModifier(UUID.randomUUID(), "sportbukkit.arrowVelocityTransfer", -1D, AttributeModifier.Operation.ADD_NUMBER)); }
Example #30
Source Project: CS-CoreLib Author: TheBusyBiscuit File: CustomPotion.java License: GNU General Public License v3.0 | 5 votes |
public CustomPotion(String name, PotionType type, PotionEffect effect, String... lore) { super(Material.POTION, name, lore); PotionMeta meta = (PotionMeta) getItemMeta(); meta.setBasePotionData(new PotionData(type)); meta.addCustomEffect(effect, true); setItemMeta(meta); }