本文整理汇总了Java中org.bukkit.potion.PotionEffect.getAmplifier方法的典型用法代码示例。如果您正苦于以下问题:Java PotionEffect.getAmplifier方法的具体用法?Java PotionEffect.getAmplifier怎么用?Java PotionEffect.getAmplifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.potion.PotionEffect
的用法示例。
在下文中一共展示了PotionEffect.getAmplifier方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyEffect
import org.bukkit.potion.PotionEffect; //导入方法依赖的package包/类
public static int applyEffect(VPPlayer player, PotionEffect effect, boolean add) {
List<PotionEffect>current = player.getPotionEffect();
Iterator<PotionEffect>iterator = current.iterator();
while(iterator.hasNext()) {
PotionEffect potionEffect = iterator.next();
if(potionEffect.getType()==effect.getType()){
if(potionEffect.getAmplifier()<effect.getAmplifier()){
iterator.remove();
}else if(potionEffect.getAmplifier() == effect.getAmplifier()){
if(add){
effect = setDuration(effect, (int) (potionEffect.getDuration()+effect.getDuration()));
}else{
if(potionEffect.getDuration()<effect.getDuration())
iterator.remove();
}
}else
return 0;
break;
}
}
current.add(effect);
player.setPotionEffect(current);
return effect.getDuration()/20;
}
示例2: giveSlow
import org.bukkit.potion.PotionEffect; //导入方法依赖的package包/类
public void giveSlow(int durationSeconds, int tier) {
int highestTier = tier;
int remaining = 0;
Player p = getPlayer();
if (p == null)
return;
for (PotionEffect pe : p.getActivePotionEffects()) {
if (pe.getType().equals(PotionEffectType.SLOW)) {
remaining = pe.getDuration();
int temp = pe.getAmplifier();
if (temp > highestTier)
highestTier = temp;
}
}
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, RTicks.seconds(durationSeconds) + (remaining / 2), highestTier), true);
}
示例3: get
import org.bukkit.potion.PotionEffect; //导入方法依赖的package包/类
@Nullable
@Override
protected Number[] get(Event e) {
ItemStack i = item.getSingle(e);
if (i == null) {
return null;
}
if (PotionUtils.isPotionItem(i)) {
PotionMeta meta = (PotionMeta) i.getItemMeta();
PotionEffect eff = PotionUtils.getEffectByEffectType(meta, effectType.getSingle(e));
if (eff == null) {
return null;
}
return new Number[]{eff.getAmplifier()};
}
return null;
}
示例4: getPotionEffectLevel
import org.bukkit.potion.PotionEffect; //导入方法依赖的package包/类
/**
* @param type
* Get the level of a specific PotionEffect on a player.
* @return
*/
public final int getPotionEffectLevel(PotionEffectType type) {
for (PotionEffect effect : getPlayer().getActivePotionEffects()) {
if (effect.getType().equals(type)) {
return effect.getAmplifier();
}
}
return 0;
}
示例5: checkPotionEffect
import org.bukkit.potion.PotionEffect; //导入方法依赖的package包/类
private PotionEffect checkPotionEffect(PotionEffect effect, Node node) throws InvalidXMLException {
if(effect.getType().equals(PotionEffectType.HEALTH_BOOST) && effect.getAmplifier() < 0) {
if(effect.getDuration() != Integer.MAX_VALUE) {
// TODO: enable this check after existing maps are fixed
// throw new InvalidXMLException("Negative health boost effect must have infinite duration (use max-health instead)", node);
}
}
return effect;
}
示例6: getResistanceFactor
import org.bukkit.potion.PotionEffect; //导入方法依赖的package包/类
private static double getResistanceFactor(LivingEntity entity) {
int amplifier = 0;
for(PotionEffect effect : entity.getActivePotionEffects()) {
if(PotionEffectType.DAMAGE_RESISTANCE.equals(effect.getType()) && effect.getAmplifier() > amplifier) {
amplifier = effect.getAmplifier();
}
}
return 1d - (amplifier / 5d);
}
示例7: getBaseMoveSpeed
import org.bukkit.potion.PotionEffect; //导入方法依赖的package包/类
/**
* Return our base move speed.
*
* @param player the player
* @return players move speed
*/
private double getBaseMoveSpeed(Player player) {
double baseSpeed = 0.2873;
for (PotionEffect ef : player.getActivePotionEffects()) {
if (ef.getType().equals(PotionEffectType.SPEED)) {
baseSpeed *= 1.0 + 0.2 * ef.getAmplifier() + 1;
}
}
return baseSpeed;
}
示例8: addPotionEffect
import org.bukkit.potion.PotionEffect; //导入方法依赖的package包/类
public static void addPotionEffect(Player p, PotionEffect pe) {
Packet41MobEffect pm = new Packet41MobEffect();
pm.a = p.getEntityId();
pm.b = (byte)pe.getType().getId();
pm.c = (byte)pe.getAmplifier();
pm.d = (short)pe.getDuration();
((CraftPlayer) p).getHandle().playerConnection.sendPacket(pm);
pm = null;
}
示例9: onPlayerDeath
import org.bukkit.potion.PotionEffect; //导入方法依赖的package包/类
/**
* Drop player's potion effect on his death
*
* @param event Event
*/
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
for (PotionEffect potionEffect : event.getEntity().getActivePotionEffects())
{
if (this.blacklist.contains(potionEffect.getType()))
continue;
if (PotionType.getByEffect(potionEffect.getType()) == null)
continue;
if(potionEffect.getDuration() > 10000)
continue;
Potion potion = new Potion(PotionType.getByEffect(potionEffect.getType()), potionEffect.getAmplifier() + 1);
ItemStack stack = potion.toItemStack(1);
PotionMeta meta = (PotionMeta) stack.getItemMeta();
meta.clearCustomEffects();
meta.addCustomEffect(new PotionEffect(potionEffect.getType(), potionEffect.getDuration(), potionEffect.getAmplifier()), true);
stack.setItemMeta(meta);
event.getDrops().add(stack);
event.getEntity().removePotionEffect(potionEffect.getType());
}
}
示例10: onPotionEffectAdd
import org.bukkit.potion.PotionEffect; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPotionEffectAdd(PotionEffectAddEvent event) {
LivingEntity entity = event.getEntity();
if (entity instanceof Player && event.getCause() == PotionEffectAddEvent.EffectCause.BEACON) {
PotionEffect effect = event.getEffect();
if (effect.getAmplifier() > 1 && effect.getType().equals(PotionEffectType.INCREASE_DAMAGE)) {
entity.addPotionEffect(new PotionEffect(effect.getType(), effect.getDuration(), 0, effect.isAmbient()));
event.setCancelled(true);
}
}
}
示例11: onUnequip
import org.bukkit.potion.PotionEffect; //导入方法依赖的package包/类
/**
* Method called when a {@link Player} unequips a {@link PvpClass}.
*
* @param player
* the unequipping {@link Player}
*/
public void onUnequip(Player player) {
for (PotionEffect effect : passiveEffects) {
for (PotionEffect active : player.getActivePotionEffects()) {
if (active.getDuration() > DEFAULT_MAX_DURATION && active.getType().equals(effect.getType()) && active.getAmplifier() == effect.getAmplifier()) {
player.removePotionEffect(effect.getType());
break;
}
}
}
player.sendMessage(ChatColor.RED + name + " has been deactivated.");
}
示例12: setRestoreEffect
import org.bukkit.potion.PotionEffect; //导入方法依赖的package包/类
public void setRestoreEffect(Player player, PotionEffect effect) {
boolean shouldCancel = true;
Collection<PotionEffect> activeList = player.getActivePotionEffects();
for (PotionEffect active : activeList) {
if (!active.getType().equals(effect.getType()))
continue;
// If the current potion effect has a higher amplifier, ignore this one.
if (effect.getAmplifier() < active.getAmplifier()) {
return;
} else if (effect.getAmplifier() == active.getAmplifier()) {
// If the current potion effect has a longer duration, ignore this one.
if (effect.getDuration() < active.getDuration()) {
return;
}
}
restores.put(player.getUniqueId(), active.getType(), active);
shouldCancel = false;
break;
}
// Cancel the previous restore.
player.addPotionEffect(effect, true);
if (shouldCancel && effect.getDuration() > BardClass.HELD_EFFECT_DURATION_TICKS && effect.getDuration() < BardClass.DEFAULT_MAX_DURATION) {
restores.remove(player.getUniqueId(), effect.getType());
}
}
示例13: onUnequip
import org.bukkit.potion.PotionEffect; //导入方法依赖的package包/类
/**
* Method called when a {@link Player} unequips a {@link PvpClass}.
*
* @param player
* the unequipping {@link Player}
*/
public void onUnequip(Player player) {
for (PotionEffect effect : passiveEffects) {
for (PotionEffect active : player.getActivePotionEffects()) {
if (active.getDuration() > DEFAULT_MAX_DURATION && active.getType().equals(effect.getType()) && active.getAmplifier() == effect.getAmplifier()) {
player.removePotionEffect(effect.getType());
break;
}
}
}
player.sendMessage(ChatColor.RED + name + " has been desactivated.");
}
示例14: convert
import org.bukkit.potion.PotionEffect; //导入方法依赖的package包/类
@Override
public Number convert(PotionEffect potionEffect) {
return potionEffect.getAmplifier();
}
示例15: PotionEffects
import org.bukkit.potion.PotionEffect; //导入方法依赖的package包/类
public PotionEffects(PotionEffect ef){
this.type = ef.getType().getId();
this.lv = ef.getAmplifier();
this.duration = ef.getDuration();
}