Weird problem getting Items from a Chest

Discussion in 'Spigot Plugin Development' started by tarpers, Feb 9, 2018.

  1. Hey,

    Pretty much I have an area where I iterate through the blocks in, then if block == material.chest > check if empty, if not empty, add to a list.

    Although whenever I use any inventory(dot) methods, the server just does nothing. No error, it just pretends like none of the code exists - It doesn't halt the server either, it just breaks out the method with no errors.

    This is the image of my code below, I have noted where it causes this problem:

    Where ever you see the '//cause issue' , if this code is executed it causes no error although does this problem of not executing the rest of the code.

    EDIT: It's not the for loop that causes the issue, it's the item.getType() straight after that does it.

    The only thing I can imagine causing this issue is that I am calling this method, that loops through all blocks, from a Synchronized Scheduler - Although no clue why this would cause that..

    Any solutions would be appreciated :) Been stuck on this for a while as I have been trying to do this different ways, but always have come to the same problem
    #1 tarpers, Feb 9, 2018
    Last edited: Feb 9, 2018
  2. First of all, don't screenshot your code. It's just annoying people wanting to help you. And no, your code is not so important that you have to be afraid of people copying it.

    So, please, what are you doing. Why do you cast a World into a Chest? Even worse, why do you expect it to work. Even worse, it likely throws a ClassCastException, which is not an 'issue' but rather an exception. If there is another issue, please descibe.

    Also, if you can't copy-paste your code to pastebin or into a code block, at least don't use jpeg so we can actually read it.

    Furthermore, you have one short if statement executed in the inner loop. But then you put all the logic in the else part and just skip the if part. Why??? Just why? You can rework it and absolutely nothing will change, except it becomes more readable.

    So finally, debug your code. You know how this works, since you know Java qua forum rules.
  3. are you iterate through all blocks in an area?? Souldn't you just iterate through tileentity??

Share This Page