Solved Check if a Slot Number Contains an Item Already

Discussion in 'Spigot Plugin Development' started by Joedon, May 14, 2016.

  1. Hi there in my plugin I am trying to check if a slot number in my custom inventory already contains an item. I tried using an arraylist and adding to it, but that's not working. Thanks for any help.

    Tried this:
    Code (Text):
                        Random slot = new Random();
                       
                        int slotn = slot.nextInt(27);
                       
                    ArrayList<Integer> s = new ArrayList<Integer>(27);

                    if(s.get(slotn) == null){
                        loot.setItem(slot.nextInt(27), i);
                        s.add(slotn);
                    }else{
                        loot.addItem(i);
                        s.add(slotn);
                    }
                }
     
  2. Of course s.get(slotn) will always return null. You instantiate the ArrayList but never actually fill it with values
     
  3. Lol I was filling it in the wrong place thanks