Check if the inv is full

Discussion in 'Plugin Development' started by q8minecraft, Dec 16, 2014.

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

    JordyPwner

    It works so he i dont see the problem
     
  2. Offline

    leon3001

    @JordyPwner Gnggghh … *facepalm*

    Yes, it works but only for one particular case. In his case, mrCookie's solution would be the best (for his needs).
     
    Last edited: Dec 21, 2014
  3. Offline

    mrCookieSlime

    e.getBlock().getDrops() is a collection not an ItemStack. You probably want to check if it not empty and then get the first Element in the Collection.

    And just ignore what
    @JordyPwner said...


    @JordyPwner
    Please don't confuse people that much.
    He already has a working method, he is just stuck on getting the Drops. There is no need to rewrite everything.
    Also, your Code isn't as efficient as the previously Code posted. And as it was said above: It doesn't work. You are just checking whether there is an empty Slot in the Inventory. This is extremely inefficient since I could fill up my Inventory with Stacks of a single Cobblestone and it would think my inventory was full...
     
    leon3001 likes this.
  4. Offline

    JordyPwner

    then you should try it first out before posting..
     
  5. Offline

    leon3001

    Maybe you should …? ;)
     
    mrCookieSlime likes this.
  6. Offline

    mrCookieSlime

    @JordyPwner
    I am using that method in a couple of my Plugins. All work without any problems. However when using your method, you still run into the problem explained above...
     
  7. Offline

    JordyPwner

    it works for me how it should be. so and the problem that @mrCookieSlime said isnt there so maybe try before posting
     
  8. Offline

    mrCookieSlime

    @JordyPwner
    ...
    You will always run into this Problem... Let's go through your Code:

    Code:
    public boolean inventoryCheck(Player player){
      
        boolean isFull = true;
      // You are looping through every Item in the Player's Inventory, so far so good.
       for (ItemStack item : player.getInventory().getContents()) {
    // But what's this? A null-check! So every Item that is NOT null wont trigger it. So lets say there is 1 cobblestone in my inventory and i pickup 1 cobblestone, it thinks my Inventory is full since 1 cobblestone is not null.
         if (item == null) {
            isFull = false;
         }
       }
       if (isFull) {
           //do something
              
             }else{
                 //do something
       }
       return isFull;
    }
    }
     
    timtower and leon3001 like this.
Thread Status:
Not open for further replies.

Share This Page