Plugin Help Help with NillPoint

Discussion in 'Plugin Help/Development/Requests' started by Lukas12137, Jun 30, 2015.

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

    Lukas12137

    Code:
     @SuppressWarnings("deprecation")
        public void Poison(Player p) {
                 ItemStack ph = p.getItemInHand();
                 ItemMeta pim = ph.getItemMeta();
             
             
             if( ph.getType()==Material.DIAMOND_AXE || ph.getType()==Material.IRON_AXE || ph.getType()==Material.GOLD_AXE || ph.getType()==Material.STONE_AXE || ph.getType()==Material.WOOD_AXE ) {         
    
             
                 EconomyResponse r = econ.withdrawPlayer(p.getName(), 5000);
                 EconomyResponse r1 = econ.withdrawPlayer(p.getName(), 15000);
                 EconomyResponse r2 = econ.withdrawPlayer(p.getName(), 35000);
                 EconomyResponse r3 = econ.withdrawPlayer(p.getName(), 50000);
                 List<String> lore = pim.getLore();
                 
                 if(!lore.contains("§7Poison I")) {
                     //ERROR HERE ^^^^^^^^^^^^^^^^^^
                     if(r.transactionSuccess()) {
                        lore.add("§7Poison I");
                        pim.setLore(lore);
                        ph.setItemMeta(pim);
                        p.sendMessage("§d§oYou have enchanted your axe!");
                     }else{
                         p.sendMessage("§c§oYou do not have enough money to buy this enchant!");
                     }
                 }
                 
                 if(lore.contains("§7Poison I")) {
                     if(r2.transactionSuccess()){
                         lore.remove("§7Poison I");
                         lore.add("§7Poison II");
                         pim.setLore(lore);
                         ph.setItemMeta(pim);
                     }else{
                         p.sendMessage("§c§oYou do not have enough money to buy this enchant!");
                     }
                 }
                 if(lore.contains("§7Poison II")) {
                     if(r1.transactionSuccess()){
                         lore.remove("§7Poison II");
                         lore.add("§7Poison III");
                         pim.setLore(lore);
                         ph.setItemMeta(pim);
                     }else{
                         p.sendMessage("§c§oYou do not have enough money to buy this enchant!");
                     }
                 }
                 if(lore.contains("§7Poison III")) {
                     if(r3.transactionSuccess()){
                         lore.remove("§7Poison III");
                         lore.add("§7Poison IV");
                         pim.setLore(lore);
                         ph.setItemMeta(pim);
                     }else{
                         p.sendMessage("§c§oYou do not have enough money to buy this enchant!");
                     }
                 }
             }else{
                 return;
             }
         }
            
    
    Here is my code and each time i try to run a command it throws a NullPoint error any one help
    ?
     
    Last edited: Jun 30, 2015
  2. Offline

    BizarrePlatinum

    @Lukas12137 try testing if the lore is null before testing if it contains something.
     
Thread Status:
Not open for further replies.

Share This Page