Solved check an item in all inventory

Discussion in 'Plugin Development' started by Alex022, Dec 16, 2017.

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

    Alex022

    hi, my plugin checks only the first free slot, but I don't understand why, I want it the plugin check all the slots, I want that in any slot the item is put this is detected.
     
    Last edited: Dec 18, 2017
  2. Offline

    Drkmaster83

    I'm pretty sure YAML doesn't like spaces on the left side, but I could be wrong.
    There shouldn't be any reason that it should only check the first free slot.
     
  3. Offline

    Alex022

    what spaces on the left side?

    please can someone help me?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Dec 17, 2017
  4. Offline

    AdamDev

    @Drkmaster83 you were close but indeed the config doesn't like spaces. If you would like to add spaces you would have to make a separate path with a "." in the middle. Such as "Item.key".

    @Alex022
    For the inventory problem, it's not just searching for the empty spot. It's because there could be problems with the config. I do suggest testing if the item equals null or the item type is air. If so continue the loop. Because the loop is searching through the contents of the inventory. You might not see it but it's going through all the items.

    Solutions that should be done:
    • Try changing your config so that it doesn't have spaces such as "Item key", "Withering I". Put them together like "Itemkey" and "WitheringI".
    • Things that you could try to see which slot it could be searching through. Try sending the slot # to you to see which slots it is displaying. A player inventory has 40 slots in 1.8 or under if you're in 1.9 it would be 41 since of the extra hand slot. Try making a hashmap and store it like "HashMap<Integer, ItemStack>" to get the slot and the ItemStack of it.
    • If the problem persists, try without doing an entity or make a test plugin that searches through inventory to test to see what code works and what doesn't. Then try and import that code into the current code you have.
    If this doesn't help try redoing that specific part of the class.

    Hope it helps,
    ~ HypixelAdam_
     
    Alex022 likes this.
Thread Status:
Not open for further replies.

Share This Page