Package org.bukkit.potion

Examples of org.bukkit.potion.PotionEffect


            switch (Action.valueOf(state.asString().toUpperCase())) {
                case FALSE:
                    target.getLivingEntity().removePotionEffect(PotionEffectType.INVISIBILITY);
                    break;
                case TRUE:
                    new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1).apply(target.getLivingEntity());
                    break;
                case TOGGLE:
                    if (target.getLivingEntity().hasPotionEffect(PotionEffectType.INVISIBILITY))
                        target.getLivingEntity().removePotionEffect(PotionEffectType.INVISIBILITY);
                    else
                        new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1).apply(target.getLivingEntity());
                    break;
            }
        }
    }
View Full Code Here


          mobEffectModifier = new StructureModifier<Object>(MinecraftReflection.getMobEffectClass(), false);
        }
        StructureModifier<Integer> ints = mobEffectModifier.withTarget(generic).withType(int.class);
        StructureModifier<Boolean> bools = mobEffectModifier.withTarget(generic).withType(boolean.class);
       
        return new PotionEffect(
          PotionEffectType.getById(ints.read(0)),   /* effectId */
          ints.read(1),                  /* duration */
          ints.read(2),                 /* amplification */
          bools.read(1)                /* ambient */
        );
 
View Full Code Here

  }

  @SuppressWarnings("deprecation")
  @Test
  public void testPotionEffect() {
    PotionEffect effect = new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 20 * 60, 1);
   
    // The constructor we want to call
    PacketConstructor creator = PacketConstructor.DEFAULT.withPacket(
        PacketType.Play.Server.ENTITY_EFFECT, new Class<?>[] { int.class, PotionEffect.class });
    PacketContainer packet = creator.createPacket(1, effect);
   
    assertEquals(1, (int) packet.getIntegers().read(0));
    assertEquals(effect.getType().getId(), (byte) packet.getBytes().read(0));
    assertEquals(effect.getAmplifier(), (byte) packet.getBytes().read(1));
    assertEquals(effect.getDuration(), (short) packet.getShorts().read(0));
  }
View Full Code Here

            for (int i = 0; i < list.size(); i++) {
                NBTTagCompound effect = (NBTTagCompound)list.get(i);
                byte amp = effect.getByte("Amplifier");
                byte id = effect.getByte("Id");
                int time = effect.getInt("Duration");
                effects.add(new PotionEffect(PotionEffectType.getById(id), time, amp));
            }
        }
        return effects;
    }
View Full Code Here

                    PotionEffectType type = parts.length > 0 ? PotionEffectType.getByName(parts[0]) : null;
                    int amplifier = parts.length > 1 ? Integer.parseInt(parts[1]) : 0;
                    int duration = parts.length > 2 ? Integer.parseInt(parts[2]) : 0;

                    if (type != null) {
                        effects.add(new PotionEffect(type, duration, amplifier));
                    }
                    else {
                        mcMMO.p.getLogger().warning("Failed to parse effect for potion " + name + ": " + effect);
                    }
                }
View Full Code Here

        Location dazedLocation = defender.getLocation();
        dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181));

        defender.teleport(dazedLocation);
        defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10));

        if (UserManager.getPlayer(defender).useChatNotifications()) {
            defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
        }

View Full Code Here

                return;
            }

            for (LivingEntity entity : event.getAffectedEntities()) {
                int duration = (int) (effect.getDuration() * event.getIntensity(entity));
                entity.addPotionEffect(new PotionEffect(effect.getType(), duration, effect.getAmplifier(), effect.isAmbient()));
            }
        }
    }
View Full Code Here

            McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
            SkillType skill = mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER) ? SkillType.MINING : SkillType.EXCAVATION;
            int ticks = PerksUtils.handleActivationPerks(player, 2 + (mcMMOPlayer.getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), skill.getAbility().getMaxLength()) * Misc.TICK_CONVERSION_FACTOR;

            PotionEffect abilityBuff = new PotionEffect(PotionEffectType.FAST_DIGGING, duration + ticks, amplifier + 10);
            player.addPotionEffect(abilityBuff, true);
        }
    }
View Full Code Here

            }

            player.removePotionEffect(effect);
            broadcastCommandMessage(sender, String.format("Took %s from %s", effect.getName(), args[0]));
        } else {
            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));
        }

View Full Code Here

        if (event.getTo().getBlock().getType() == Material.SNOW) {

            if(slowdown) {
                if(event.getTo().getBlock().getData() > 4)
                    event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20, 2), true);
                else if(event.getTo().getBlock().getData() > 0)
                    event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20, 1), true);
            }

            if (!player.hasPermission("craftbook.mech.snow.trample")) return;

            if (jumpTrample && !(event.getFrom().getY() - event.getTo().getY() >= 0.1D))
View Full Code Here

TOP

Related Classes of org.bukkit.potion.PotionEffect

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.