Package org.bukkit.potion

Examples of org.bukkit.potion.PotionEffect


        try {
            effectTime = Integer.parseInt(effectInfo[2]);
        } catch (Exception e) {
            effectTime = 10;
        }
        effect = new PotionEffect(PotionEffectType.getById(effectID), effectTime * 20, effectAmount - 1, true);
        try {
            types = EntityType.getDetected(RegexUtil.EQUALS_PATTERN.split(getLine(2),2)[1]);
        } catch(Exception e) {
            types = new HashSet<EntityType>();
            types.add(EntityType.PLAYER);
View Full Code Here


                        ent.setPassenger(rid);
                    } else if (data[0].equalsIgnoreCase("p") && ent instanceof LivingEntity) {
                        for (int a = 1; a < data.length; a++) {
                            try {
                                String[] potionBits = RegexUtil.SEMICOLON_PATTERN.split(data[a]);
                                PotionEffect effect = new PotionEffect(PotionEffectType.getById(Integer.parseInt(potionBits[0])), Integer.parseInt(potionBits[1]), Integer.parseInt(potionBits[2]));
                                ((LivingEntity) ent).addPotionEffect(effect, true);
                            } catch (Exception ignored) {
                            }
                        }
                    } else if (data[0].equalsIgnoreCase("v")) {
View Full Code Here

    if (ambientElement != null)
    {
      ambient = ambientElement.getAsBoolean();
    }
   
    return new PotionEffect(pet, duration, amplifier, ambient);
  }
View Full Code Here

    List<PotionEffect> ret = new ArrayList<PotionEffect>();
   
    Iterator<JsonElement> iter = array.iterator();
    while(iter.hasNext())
    {
      PotionEffect e = PotionEffectAdapter.fromJson(iter.next());
      if (e == null) continue;
      ret.add(e);
    }
   
    return ret;
View Full Code Here

            GlowPotionEffect type = (GlowPotionEffect) effect.getType();
            type.pulse(this, effect);

            if (effect.getDuration() > 0) {
                // reduce duration and re-add
                addPotionEffect(new PotionEffect(type, effect.getDuration() - 1, effect.getAmplifier(), effect.isAmbient()), true);
            } else {
                // remove
                removePotionEffect(type);
            }
        }
View Full Code Here

                if (compound.isByte("Ambient")) {
                    ambient = compound.getBool("Ambient");
                }
                // bool "ShowParticles"

                entity.addPotionEffect(new PotionEffect(type, duration, amplifier, ambient), true);
            }
        }

        EntityEquipment equip = entity.getEquipment();
        if (compound.isList("Equipment", TagType.COMPOUND)) {
View Full Code Here

                        String[] thepotion = potion.split(",");
                        if(thepotion.length >= 3) {
                            String potionname = thepotion[0];
                            int duration = Integer.parseInt(thepotion[1]);
                            int amplifier = Integer.parseInt(thepotion[2]);
                            PotionEffect effect = new PotionEffect(PotionEffectType.getByName(potionname), duration, amplifier);
                            potioneffects.add(effect);
                        }
                    }
                }
            } else {
View Full Code Here

                for(int i = 0; (data = itemdata.get("P" + String.valueOf(i))) != null; i++) {
                    String[] potion = data.split("\\+");
                    PotionEffectType type = PotionEffectType.getByName(potion[0]);
                    int amplifier = Integer.parseInt(potion[1]);
                    int duration = Integer.parseInt(potion[2]);
                    PotionEffect pe = new PotionEffect(type, duration, amplifier);
                    pmeta.addCustomEffect(pe, true);
                }
            }else if(ismeta instanceof EnchantmentStorageMeta) {
                EnchantmentStorageMeta emeta = (EnchantmentStorageMeta) ismeta;
                for(int i = 0; (data = itemdata.get("E" + String.valueOf(i))) != null; i++) {
                    String[] enchant = data.split("\\+");
                    Enchantment enchantenum = Enchantment.getByName(enchant[0]);
                    if(enchantenum != null) {
                        int value = Integer.parseInt(enchant[1]);
                        emeta.addStoredEnchant(enchantenum, value, true);
                    }
                }
            }else if(ismeta instanceof FireworkMeta) {
                FireworkMeta fmmeta = (FireworkMeta) ismeta;
                for(int i = 0; (data = itemdata.get("F" + String.valueOf(i))) != null; i++) {
                    String[] fedata = data.split("\\+");
                    Type effect = FireworkEffect.Type.valueOf(fedata[0]);
                    Builder ef = FireworkEffect.builder();
                    ef.with(effect);
                    if(effect != null) {
                        String[] colors = fedata[1].split("-");
                        for(String color : colors) {
                            try {
                                ef.withColor(Color.fromRGB(Integer.parseInt(color)));
                            }catch (Exception e) {
                               
                            }
                        }
                        String[] fadecolors = fedata[2].split("-");
                        for(String fadecolor : fadecolors) {
                            try {
                                ef.withFade(Color.fromRGB(Integer.parseInt(fadecolor)));
                            }catch (Exception e) {
                               
                            }
                        }
                        ef.flicker(Boolean.parseBoolean(fedata[3]));
                        ef.trail(Boolean.parseBoolean(fedata[4]));
                        fmmeta.addEffect(ef.build());
                    }
                }
                data = itemdata.get("G");
                try {
                    fmmeta.setPower(Integer.parseInt(data));
                }catch (Exception e) {
                   
                }
            }else if(ismeta instanceof FireworkEffectMeta) {
                data = itemdata.get("F0");
                if(data != null) {
                    String[] fedata = data.split("\\+");
                    Type effect = FireworkEffect.Type.valueOf(fedata[0]);
                    Builder ef = FireworkEffect.builder();
                    ef.with(effect);
                    if(effect != null) {
                        String[] colors = fedata[1].split("-");
                        for(String color : colors) {
                            try {
                                ef.withColor(Color.fromRGB(Integer.parseInt(color)));
                            }catch (Exception e) {
                               
                            }
                        }
                        String[] fadecolors = fedata[2].split("-");
                        for(String fadecolor : fadecolors) {
                            try {
                                ef.withFade(Color.fromRGB(Integer.parseInt(fadecolor)));
                            }catch (Exception e) {
                               
                            }
                        }
                        ef.flicker(Boolean.parseBoolean(fedata[3]));
                        ef.trail(Boolean.parseBoolean(fedata[4]));
                        ((FireworkEffectMeta) ismeta).setEffect(ef.build());
                    }
                }
            }
            if(ismeta instanceof Repairable) {
                data = itemdata.get("R");
                if(data != null) {
                    Repairable rmeta = (Repairable) ismeta;
                    rmeta.setRepairCost(Integer.parseInt(data));
                }
            }
        }else {
            //Old item meta here
            int repairableindex = 2;
            if(msplit.length > 1) {
                if(!msplit[0].equals("")) {
                    ismeta.setDisplayName(base64Decode(msplit[0]));
                }
                if(!msplit[1].equals("")) {
                    ismeta.setLore(decodeLore(msplit[1]));
                }
                if(ismeta instanceof SkullMeta) {
                    if(!msplit[2].isEmpty()) {
                        ((SkullMeta) ismeta).setOwner(msplit[2]);
                    }
                    repairableindex = 3;
                } else if(ismeta instanceof LeatherArmorMeta) {
                    if(!msplit[2].equals("")) {
                        int color = Integer.parseInt(msplit[2]);
                        ((LeatherArmorMeta) ismeta).setColor(Color.fromRGB(color));
                    }
                    repairableindex = 3;
                } else if(ismeta instanceof PotionMeta) {
                    if(msplit.length > repairableindex) {
                        boolean ispotion = true;
                        if(msplit[repairableindex].contains("+")) {
                            PotionMeta pmeta = (PotionMeta) ismeta;
                            for(; repairableindex < msplit.length && ispotion; repairableindex++) {
                                if(msplit[repairableindex].contains("+")) {
                                    String[] potion = msplit[repairableindex].split("\\+");
                                    PotionEffectType type = PotionEffectType.getByName(potion[0]);
                                    int amplifier = Integer.parseInt(potion[1]);
                                    int duration = Integer.parseInt(potion[2]);
                                    PotionEffect pe = new PotionEffect(type, duration, amplifier);
                                    pmeta.addCustomEffect(pe, true);
                                } else {
                                    ispotion = false;
                                    repairableindex--;
                                }
View Full Code Here

  public void applyNightVision()
  {
    if (!isOnline() || this.hasClientMod()) return;
    getPlayer().removePotionEffect(PotionEffectType.NIGHT_VISION);

    PotionEffect nightvis = new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0);
    if (this.nightVision) getPlayer().addPotionEffect(nightvis);
  }
View Full Code Here

        match.broadcast(ChatColor.DARK_GRAY + "[" + apl.getDisplayName() +
          ChatColor.DARK_GRAY + "] Set time to 9pm");
        break;

      case NIGHT_VISION:
        player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 8 * 60 * 20, 1));
        break;

      case CLEAR_POTION_EFFECTS:
        player.sendMessage(ChatColor.GRAY + "-- Potion effects cleared");
        PlayerUtil.removeStatusEffects(player);
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.