Check if chest is not completely empty

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

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

    StellarFX

    Hello,

    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 :
    Code:
    chest.getInventory().getContents().length >= 26
     
  2. Offline

    timtower Administrator Administrator 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

    StellarFX

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

    timtower Administrator Administrator Moderator

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

    KarimAKL

  6. Offline

    StellarFX

    @timtower Oh okay sorry I misinterpreted what you said.
     
Thread Status:
Not open for further replies.

Share This Page