Package org.bukkit.enchantments

Examples of org.bukkit.enchantments.Enchantment


                    try {
                        level = Integer.parseInt(parts[1]);
                    } catch (NumberFormatException ignore) {}
                }

                Enchantment ench = null;
                final String testName = enchStr.toLowerCase().replaceAll("[_\\-]", "");
                for (Enchantment possible : Enchantment.values()) {
                    if (possible.getName().toLowerCase().replaceAll("[_\\-]", "").equals(testName)) {
                        ench = possible;
                        break;
View Full Code Here


            }
        } else if(!"0".equals(enchantmentString)) {
            String[] enchantments = enchantmentString.split("#");
            for(String enchantment : enchantments) {
                String[] parts = enchantment.split("-");
                Enchantment e;
                try {
                  e = Enchantment.getById(Integer.parseInt(parts[0]));
                }catch(NumberFormatException ex) {
                  e = Enchantment.getByName(parts[0]);
                }
View Full Code Here

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

      if (sEnchantments != null) {
        enchantments = new HashMap<Enchantment, Integer>();
       
        String ench[]    = sEnchantments.split(",");
        for (String string : ench) {
          Enchantment  enchantment  = Utilities.getEnchantmentFromString    (string);
          int      level    = Utilities.getEnchantmentLevelFromString  (string);
         
          if (enchantment != null) {
            enchantments.put(enchantment, level);
          }
View Full Code Here

//    }
   
    @Deprecated
    public static Enchantment getEnchantmentFromString(String e){
       
        Enchantment ench = null;
       
        String args[] = new String[2];
        if (e.contains(":"))
                args = e.split(":");
        else {
View Full Code Here

  public static void addParsedEnchantment(ItemStack item, Element element)
  {
    assert "enchant".equalsIgnoreCase(element.getName());
    String etype = element.getAttributeValue("type");
    Enchantment enchantment = Enchantment.getByName(etype);

    if (enchantment == null)
      try { enchantment = Enchantment.getById(Integer.parseInt(etype)); }
      catch (NumberFormatException e) {  }
View Full Code Here

        if (i != enchs.size() - 1)
          b.append(", ");
        else
          b.append(" " + GeneralWords.and + " ");
      }
      final Enchantment ench = e.getKey();
      if (ench == null)
        continue;
      b.append(EnchantmentType.toString(ench));
      b.append(" ");
      b.append(e.getValue());
View Full Code Here

 
  @SuppressWarnings("null")
  @Nullable
  public static EnchantmentType parse(final String s) {
    if (pattern.matcher(s).matches()) {
      final Enchantment ench = parseEnchantment(s.substring(0, s.lastIndexOf(' ')));
      if (ench == null)
        return null;
      return new EnchantmentType(ench, Utils.parseInt(s.substring(s.lastIndexOf(' ') + 1)));
    }
    final Enchantment ench = parseEnchantment(s);
    if (ench == null)
      return null;
    return new EnchantmentType(ench, -1);
  }
View Full Code Here

  }
 
  @Override
  @Nullable
  protected Integer[] get(final Event e, final ItemType[] source) {
    final Enchantment ench = enchantment.getSingle(e);
    if (ench == null)
      return new Integer[0];
    return get(source, new Converter<ItemType, Integer>() {
      @Override
      @Nullable
View Full Code Here

TOP

Related Classes of org.bukkit.enchantments.Enchantment

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.