Solved Weird Error..

Discussion in 'Spigot Plugin Development' started by DaBombDog, May 17, 2018.

  1. EDIT: Nevermind... Problem was because I was looping until it found the perm that I didn't have but I have *.*




    So I am getting this error that I know is from a bad For loop, but Idk how it is causing anything:
    Code (Text):
    private void sell(Player p) {
            ItemStack[] items = p.getInventory().getContents();
            int multiplier = 1 + multi(p)/10;
            for(ItemStack i : items) {
                if(whiteList.contains(i.getType().toString())) {
                    moneyMade += getConfig().getInt("BlockPrices." + i.getType().toString())*i.getAmount()*multiplier;
                    i.setAmount(0);
                }
            }
            Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "eco give " + p.getName() + " " + moneyMade + "");
        }
    Yes, I know I can hook into essentials or vault to add the money, but it is just easier to do the command and have Vault or essentials handle messaging.

    126 : sell((Player) sender);
    132 :ItemStack[] items = p.getInventory().getContents();
    150 : List<Block> blocks = new ArrayList<Block>();

    What I am really trying to do is loop through every item in someone's inventory.
     
    #1 DaBombDog, May 17, 2018
    Last edited: May 17, 2018
  2. Checks if the item being rotated is null
     
  3. It's solved. EDIT: Nevermind... Problem was because I was looping until it found the perm that I didn't have but I have *.*
     

Share This Page