Package org.bukkit.enchantments

Examples of org.bukkit.enchantments.Enchantment


          Commands.showCommandHelpAndUsage(sender, "cex_enchant", alias);
          return true;
        }
       
        List<Enchantment> matches = ClosestMatches.enchantments(args[1]);
        Enchantment ench;
       
        if (matches.size() > 0){
          ench = matches.get(0);
        } else {
          LogHelper.showInfo("enchantNotFound", sender, ChatColor.RED);
          return true;
        }
       
        if (!inHand.containsEnchantment(ench)){
          LogHelper.showInfo("enchantRemoveNotFound#####[" + ChatColor.GOLD + Utils.userFriendlyNames(inHand.getType().name()), sender);
          return true;
        }
       
        inHand.removeEnchantment(ench);
        LogHelper.showInfo("enchantRemoveSuccess#####[ " + ChatColor.GOLD + Utils.userFriendlyNames(ench.getName()) + ChatColor.AQUA + "#####from#####[ " + Utils.userFriendlyNames(inHand.getType().name()), sender);
      }
     
      return true;
    }
   
    List<Enchantment> matches = ClosestMatches.enchantments(args[0]);
    Enchantment ench = null;
   
    if (args[0].equalsIgnoreCase("all")){
      if (Permissions.checkPerms(sender, "cex.enchant.all")){
        if (matches.size() > 0){
          ench = matches.get(0);
        } else {
          LogHelper.showInfo("enchantNotFound", sender, ChatColor.RED);
          return true;
        }
       
        if (args.length > 3){
          Commands.showCommandHelpAndUsage(sender, "cex_enchant", alias);
          return true;
        }

        if (args.length == 3){
          if (args[1].matches(CommandsEX.intRegex)){
            Integer.valueOf(args[1]);
          } else {
            LogHelper.showInfo("valueNotNumeric", sender, ChatColor.RED);
            return true;
          }
         
          if (args[2].equalsIgnoreCase("-u") || args[2].equalsIgnoreCase("unsafe")){
            unSafe = true;
          }
        } else if (args.length == 2){
          if (args[1].equalsIgnoreCase("-u") || args[1].equalsIgnoreCase("unsafe")){
            unSafe = true;
          }
        }

        int count = 0;
       
        if (inHand.getType().equals(Material.AIR)){
          LogHelper.showInfo("enchantFist", sender, ChatColor.RED);
          return true;
        }
       
        for (Enchantment en : Enchantment.values()){
          if (player.hasPermission("cex.enchant." + en.getName().toLowerCase().replaceAll("_", ""))){
            int enchantLevel = level;
           
            if (level == -1 || enchantLevel > en.getMaxLevel()){
              enchantLevel = en.getMaxLevel();
            }
           
            if (en.canEnchantItem(inHand)){
              inHand.addEnchantment(en, enchantLevel);
              count++;
            } else {
              if (unSafe){
                inHand.addUnsafeEnchantment(en, enchantLevel);
                count++;
              }
            }
          }
        }
       
        LogHelper.showInfo("enchantAddedAll#####[" + ChatColor.GOLD + count + ChatColor.AQUA + " #####enchantEnchantments", sender);
      }
      return true;
    }
   
    if (matches.size() > 0){
      ench = matches.get(0);
    } else {
      LogHelper.showInfo("enchantNotFound", sender, ChatColor.RED);
      return true;
    }
   
    if (!player.hasPermission("cex.enchant." + ench.getName().toLowerCase().replaceAll("_", ""))){
      LogHelper.showInfo("enchantEnchantmentNoPerm", sender, ChatColor.RED);
      return true;
    }
   
    boolean nonNumeric = false;
   
    if (args.length == 2){
      if (args[1].equalsIgnoreCase("-u") || args[1].equalsIgnoreCase("unsafe")){
        unSafe = true;
      } else if (args[1].matches(CommandsEX.intRegex)){
        level = Integer.valueOf(args[1]);
      } else {
        nonNumeric = true;
      }
    }
   
    if (args.length == 3){
      if (args[2].equalsIgnoreCase("-u") || args[2].equalsIgnoreCase("unsafe")){
        unSafe = true;
      } else if (args[1].matches(CommandsEX.intRegex)){
        level = Integer.valueOf(args[1]);
      } else {
        nonNumeric = true;
      }
    }
   
    if (inHand.getType().equals(Material.AIR)){
      LogHelper.showInfo("enchantFist", sender, ChatColor.RED);
      return true;
    }
   
    if (!ench.canEnchantItem(inHand) && !unSafe){
      LogHelper.showInfo("enchantNotSafe", sender, ChatColor.RED);
      return true;
    }
   
    if (nonNumeric){
      LogHelper.showInfo("valueNotNumeric", sender, ChatColor.RED);
      return true;
    }
   
    if (level == -1 || level > ench.getMaxLevel()){
      level = ench.getMaxLevel();
    }
   
    if (unSafe){
      inHand.addUnsafeEnchantment(ench, level);
    } else {
      inHand.addEnchantment(ench, level);
    }
   
    LogHelper.showInfo("enchantAdded#####[" + ChatColor.GOLD + Utils.userFriendlyNames(ench.getName())
        + ChatColor.AQUA + " (" + ChatColor.GOLD + ench.getId() + ChatColor.AQUA + ") #####enchantAddedLevel#####["
        + ChatColor.GOLD + level, sender);
    return true;
  }
View Full Code Here


          int i = 1;
          try {
            i = Integer.parseInt(args[4]);
          } catch (NumberFormatException nfe) {
          }
          Enchantment ech = Enchantment.getByName(args[3]
              .toUpperCase());
          if (ech != null) {
            try {
              int l = Integer.parseInt(args[3]);
              ech = Enchantment.getById(l);
View Full Code Here

          .nextInt(l + 1);
      int size = eStack.size();
      if (size < 1) {
        continue;
      }
      Enchantment ench = eStack.get(DiabloDrops.getInstance()
          .getSingleRandom().nextInt(size));
      if ((lvl != 0) && (ench != null)
          && !tier.getColor().equals(ChatColor.MAGIC))
        if (safe) {
          if ((lvl >= ench.getStartLevel())
              && (lvl <= ench.getMaxLevel())) {
            try {
              this.addEnchantment(ench, lvl);
            } catch (Exception e1) {
              if (DiabloDrops.getInstance().getDebug()) {
                DiabloDrops.getInstance().log.warning(e1
View Full Code Here

      int lvl = plugin.getSingleRandom().nextInt(l + 1);
      int size = eStack.size();
      if (size < 1) {
        continue;
      }
      Enchantment ench = eStack.get(plugin.getSingleRandom()
          .nextInt(size));
      if (!ci.containsEnchantment(ench))
        if ((lvl != 0) && (ench != null)
            && !tier.getColor().equals(ChatColor.MAGIC))
          if (safe) {
            if ((lvl >= ench.getStartLevel())
                && (lvl <= ench.getMaxLevel())) {
              try {
                ci.addEnchantment(ench, lvl);
              } catch (Exception e1) {
                if (plugin.getDebug()) {
                  plugin.log.warning(e1.getMessage());
View Full Code Here

      int lvl = plugin.getSingleRandom().nextInt(l + 1);
      int size = eStack.size();
      if (size < 1) {
        continue;
      }
      Enchantment ench = eStack.get(plugin.getSingleRandom()
          .nextInt(size));
      if (!tool.containsEnchantment(ench))
        if ((lvl != 0) && (ench != null)
            && !tier.getColor().equals(ChatColor.MAGIC))
          if (safe) {
            if ((lvl >= ench.getStartLevel())
                && (lvl <= ench.getMaxLevel())) {
              try {
                tool.addEnchantment(ench, lvl);
              } catch (Exception e1) {
                if (plugin.getDebug()) {
                  plugin.log.warning(e1.getMessage());
View Full Code Here

      int lvl = plugin.getSingleRandom().nextInt(l + 1);
      int size = eStack.size();
      if (size < 1) {
        continue;
      }
      Enchantment ench = eStack.get(plugin.getSingleRandom()
          .nextInt(size));
      if (!tool.containsEnchantment(ench))
        if ((lvl != 0) && (ench != null)
            && !tier.getColor().equals(ChatColor.MAGIC))
          if (safe) {
            if ((lvl >= ench.getStartLevel())
                && (lvl <= ench.getMaxLevel())) {
              try {
                tool.addEnchantment(ench, lvl);
              } catch (Exception e1) {
                if (plugin.getDebug()) {
                  plugin.log.warning(e1.getMessage());
View Full Code Here

      int lvl = plugin.getSingleRandom().nextInt(l + 1);
      int size = eStack.size();
      if (size < 1) {
        continue;
      }
      Enchantment ench = eStack.get(plugin.getSingleRandom()
          .nextInt(size));
      if (!tool.containsEnchantment(ench))
        if ((lvl != 0) && (ench != null)
            && !tier.getColor().equals(ChatColor.MAGIC))
          if (safe) {
            if ((lvl >= ench.getStartLevel())
                && (lvl <= ench.getMaxLevel())) {
              try {
                tool.addEnchantment(ench, lvl);
              } catch (Exception e1) {
                if (plugin.getDebug()) {
                  plugin.log.warning(e1.getMessage());
View Full Code Here

      int lvl = plugin.getSingleRandom().nextInt(l + 1);
      int size = eStack.size();
      if (size < 1) {
        continue;
      }
      Enchantment ench = eStack.get(plugin.getSingleRandom()
          .nextInt(size));
      if (!tool.containsEnchantment(ench))
        if ((lvl != 0) && (ench != null)
            && !tier.getColor().equals(ChatColor.MAGIC))
          if (safe) {
            if ((lvl >= ench.getStartLevel())
                && (lvl <= ench.getMaxLevel())) {
              try {
                tool.addEnchantment(ench, lvl);
              } catch (Exception e1) {
                if (plugin.getDebug()) {
                  plugin.log.warning(e1.getMessage());
View Full Code Here

      }
      ConfigurationSection cs1 = cs
          .getConfigurationSection("Enchantments");
      if (cs1 != null) {
        for (String ench : cs1.getKeys(false)) {
          Enchantment encha = Enchantment.getByName(ench
              .toUpperCase());
          if (encha == null)
            continue;
          tool.addUnsafeEnchantment(encha, cs1.getInt(ench));
        }
View Full Code Here

        }
       
        int id  = Integer.parseInt(parts[0]);
        int lvl = Integer.parseInt(parts[1]);
       
        Enchantment e = Enchantment.getById(id);
        if (e == null) {// || !e.canEnchantItem(stack) || lvl > e.getMaxLevel() || lvl < e.getStartLevel()) {
            return;
        }
       
        if (stack.getType() == Material.ENCHANTED_BOOK) {
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.