Examples of PotionEffectType


Examples of org.bukkit.potion.PotionEffectType

   */
  public PotionEffect getPotionEffect(String serializedEffect) {
    String[] arr = serializedEffect.split(";");
    if (arr.length != 3) return null;
    try {
      PotionEffectType type = PotionEffectType.getByName(arr[0]);
      int duration = Integer.parseInt(arr[1]);
      int amplification = Integer.parseInt(arr[2]);
      return new PotionEffect(type, duration, amplification);
    } catch (RuntimeException ex) {
      return null;
View Full Code Here

Examples of org.bukkit.potion.PotionEffectType

        if (potion.getShooter() instanceof Player) {
            // Check for PvP stuff if the shooter is a player
            if (!pvpEnabled) {
                // If a potion has harmful effects, remove all players.
                for (PotionEffect effect : potion.getEffects()) {
                    PotionEffectType type = effect.getType();
                    if (type.equals(PotionEffectType.HARM) || type.equals(PotionEffectType.POISON)) {
                        for (LivingEntity le : event.getAffectedEntities()) {
                            if (le instanceof Player) {
                                event.setIntensity(le, 0.0);
                            }
                        }
                        break;
                    }
                }
            }
        } else if (!monsterInfight) {
            // Otherwise, check for monster infighting
            for (PotionEffect effect : potion.getEffects()) {
                PotionEffectType type = effect.getType();
                if (type.equals(PotionEffectType.HARM) || type.equals(PotionEffectType.POISON)) {
                    for (LivingEntity le : event.getAffectedEntities()) {
                        if (!(le instanceof Player)) {
                            event.setIntensity(le, 0.0);
                        }
                    }
View Full Code Here

Examples of org.bukkit.potion.PotionEffectType

    @SuppressWarnings("unchecked")
    @Override
    public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
        // Fetch objects
        List<dEntity> entities = (List<dEntity>) scriptEntry.getObject("entities");
        PotionEffectType effect = (PotionEffectType) scriptEntry.getObject("effect");
        int amplifier = scriptEntry.getElement("amplifier").asInt();
        Duration duration = (Duration) scriptEntry.getObject("duration");
        boolean remove = scriptEntry.getElement("remove").asBoolean();

        // Report to dB
        dB.report(scriptEntry, getName(),
                aH.debugObj("Target(s)", entities.toString())
                        + aH.debugObj("Effect", effect.getName())
                        + aH.debugObj("Amplifier", amplifier)
                        + duration.debug());

        // Apply the PotionEffect to the targets!
        for (dEntity entity : entities) {
View Full Code Here

Examples of org.bukkit.potion.PotionEffectType

            List<PotionEffect> effects = new ArrayList<PotionEffect>();
            if (potion_section.contains("Effects")) {
                for (String effect : potion_section.getStringList("Effects")) {
                    String[] parts = effect.split(" ");

                    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));
View Full Code Here

Examples of org.bukkit.potion.PotionEffectType

            }
            sender.sendMessage(String.format("Took all effects from %s", args[0]));
            return true;
        }

        PotionEffectType effect = PotionEffectType.getByName(args[1]);

        if (effect == null) {
            effect = PotionEffectType.getById(getInteger(sender, args[1], 0));
        }

        if (effect == null) {
            sender.sendMessage(ChatColor.RED + String.format("Effect, %s, not found", args[1]));
            return true;
        }

        int duration = 600;
        int duration_temp = 30;
        int amplification = 0;

        if (args.length >= 3) {
            duration_temp = getInteger(sender, args[2], 0, 1000000);
            if (effect.isInstant()) {
                duration = duration_temp;
            } else {
                duration = duration_temp * 20;
            }
        } else if (effect.isInstant()) {
            duration = 1;
        }

        if (args.length >= 4) {
            amplification = getInteger(sender, args[3], 0, 255);
        }

        if (duration_temp == 0) {
            if (!player.hasPotionEffect(effect)) {
                sender.sendMessage(String.format("Couldn't take %s from %s as they do not have the effect", effect.getName(), args[0]));
                return true;
            }

            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));
        }

        return true;
    }
View Full Code Here

Examples of org.bukkit.potion.PotionEffectType

    if (jsonElement == null) return null;
    if ( ! jsonElement.isJsonObject()) return null;
   
    JsonObject json = jsonElement.getAsJsonObject();
   
    PotionEffectType pet = PotionEffectType.getById(json.get(POTION_EFFECT_ID).getAsInt());
   
    int duration = POTION_DURATION_DEFAULT;
    JsonElement durationElement = json.get(POTION_DURATION);
    if (durationElement != null)
    {
View Full Code Here

Examples of org.bukkit.potion.PotionEffectType

                // should really always have every field, but be forgiving if possible
                if (!effect.isByte("Id") || !effect.isInt("Duration")) {
                    continue;
                }

                PotionEffectType type = PotionEffectType.getById(effect.getByte("Id"));
                int duration = effect.getInt("Duration");
                if (type == null || duration < 0) {
                    continue;
                }
                int amplifier = 0;
View Full Code Here

Examples of org.bukkit.potion.PotionEffectType

                }
            } else if(ismeta instanceof PotionMeta) {
                PotionMeta pmeta = (PotionMeta) ismeta;
                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 {
View Full Code Here

Examples of org.bukkit.potion.PotionEffectType

   * Generates a human-readable string for the status effect.
   */
  public static String getStatusEffectName(PotionEffect effect)
  {
    int time = effect.getDuration() / 20;
    PotionEffectType type = effect.getType();
    int amp = effect.getAmplifier();

    String name = statusNames.containsKey(type) ? statusNames.get(type) :
      WordUtils.capitalizeFully(type.getName().toLowerCase().replace('_', ' '));
    if (amp >= 0) name += " " + (amp < roman.length ? roman[amp] : (1 + amp));

    return String.format("%s (%d:%02d)", name, time/60, time%60);
  }
View Full Code Here

Examples of org.bukkit.potion.PotionEffectType

    try { return PotionEffectType.getById(Integer.parseInt(type)); }
    catch (NumberFormatException e) {  }

    type = type.toLowerCase();

    int bscore = Integer.MAX_VALUE; PotionEffectType best = null;
    for (Map.Entry<String, PotionEffectType> e : potionTypes.entrySet())
    {
      int score = StringUtils.getLevenshteinDistance(type, e.getKey());
      if (score < bscore) { bscore = score; best = e.getValue(); }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.