Solved Leaving lower enchantments out

Discussion in 'Plugin Development' started by MordorKing78, Nov 22, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    MordorKing78

    EDIT: Nevermind, I solved it, I shouldn't of called a break.

    I'm trying to leave every enchantment level that is lower then a player currently has on it's tool out, now what the code does it just completely removes everything.

    Let's say my sword has Sharpness 3, now I want the code to leave out 1 and 2 and only show 4.
    Currently it just leaves Sharpness, 1,2,3 & 4 out.

    Code:
    PHP:
    for (Enchantment key enchantments.keySet()) {
                  
                    for(
    int m=1m<key.getMaxLevel(); m++){
                      
                        if(
    item.containsEnchantment(key)){
                            
    int enchantLvl item.getEnchantmentLevel(key);
                                              
                            if(
    enchantLvl m){
                                
    i.addItem(Blacksmith.Enchantments(ChatColor.YELLOW key.getName().toString().toLowerCase(), keym));                                          
                            }else{
                                break;
                            }                  
                        }else{
                            
    i.addItem(Blacksmith.Enchantments(ChatColor.YELLOW key.getName().toString().toLowerCase(), keym));                                          
                        }
                    }
                  
                }    
     
Thread Status:
Not open for further replies.

Share This Page