Check if chest is not completely empty

Discussion in 'Plugin Development' started by StellarFX, May 1, 2019.

  1. Offline



    I just can't figure out how to check if a chest is not completely empty, like if there's already one or two slots taken in it.
    Please help !

    PS : I think this is something like this but it doesn't work :
    chest.getInventory().getContents().length >= 26
  2. Online

    timtower Ninja on the waves Moderator

    @StellarFX That just checks how big the inventory is.
    You need to loop over the content and check if anything is not null
    KarimAKL likes this.
  3. Offline


    @timtower Can you make me an example please ?
  4. Online

    timtower Ninja on the waves Moderator

    I won't make an example for a for loop with a null check
  5. Offline


  6. Offline


    @timtower Oh okay sorry I misinterpreted what you said.

Share This Page