org.bukkit.block.banner.Pattern#org.bukkit.potion.PotionEffect源码实例Demo

下面列出了org.bukkit.block.banner.Pattern#org.bukkit.potion.PotionEffect 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: CardinalPGM   文件: FriendlyFire.java
@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);
            }
        }
    }
}
 
源代码2 项目: UhcCore   文件: TeleportPlayersThread.java
@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);
	}
}
 
源代码3 项目: PGM   文件: XMLUtils.java
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);
}
 
源代码4 项目: Thermos   文件: CraftMetaPotion.java
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;
    }
}
 
源代码5 项目: PGM   文件: KitParser.java
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;
}
 
源代码6 项目: MineTinker   文件: Withered.java
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);
}
 
源代码7 项目: MineTinker   文件: Shulking.java
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);
}
 
源代码8 项目: MineTinker   文件: Webbed.java
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);
}
 
源代码9 项目: MineTinker   文件: Poisonous.java
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);
}
 
源代码10 项目: Thermos   文件: CraftMetaPotion.java
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;
}
 
源代码11 项目: PerWorldInventory   文件: PotionEffectSerializer.java
/**
 * 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;
}
 
源代码12 项目: Slimefun4   文件: ArmorTask.java
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);
                }
            });
        }
    }
}
 
源代码13 项目: Slimefun4   文件: Bandage.java
@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();
    };
}
 
源代码14 项目: Skript   文件: EffPoison.java
@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);
		}
	}
}
 
源代码15 项目: Kettle   文件: CraftMetaPotion.java
@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);
        }
    }
}
 
源代码16 项目: BedWars   文件: GamePlayer.java
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();
}
 
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()));
}
 
源代码18 项目: RedProtect   文件: EntityListener.java
@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;
            }
        }
    }
}
 
源代码19 项目: Thermos   文件: CraftMetaPotion.java
CraftMetaPotion(CraftMetaItem meta) {
    super(meta);
    if (!(meta instanceof CraftMetaPotion)) {
        return;
    }
    CraftMetaPotion potionMeta = (CraftMetaPotion) meta;
    if (potionMeta.hasCustomEffects()) {
        this.customEffects = new ArrayList<PotionEffect>(potionMeta.customEffects);
    }
}
 
源代码20 项目: PGM   文件: Alive.java
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);
            }
          });
}
 
源代码21 项目: ce   文件: AssassinsBlade.java
@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;
}
 
源代码22 项目: EliteMobs   文件: MoonWalk.java
@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);

}
 
源代码23 项目: SkyWarsReloaded   文件: Util.java
public void clear(final Player player) {
    player.getInventory().clear();
    player.getInventory().setArmorContents((ItemStack[])null);
    for (final PotionEffect a1 : player.getActivePotionEffects()) {
    	player.removePotionEffect(a1.getType());
    }
}
 
源代码24 项目: AnnihilationPro   文件: Swapper.java
@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;
}
 
源代码25 项目: EliteMobs   文件: NPCEntity.java
/**
 * 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));
}
 
源代码26 项目: CardinalPGM   文件: Parser.java
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);
}
 
源代码27 项目: PerWorldInventory   文件: PotionEffectSerializer.java
/**
 * 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);
}
 
源代码28 项目: askyblock   文件: AcidEffect.java
/**
 * 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;
}
 
源代码29 项目: CardinalPGM   文件: Players.java
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));
}
 
源代码30 项目: CS-CoreLib   文件: CustomPotion.java
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);
}