Solved Getting item meta from item in a slot

Discussion in 'Plugin Development' started by plisov, Jan 15, 2017.

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

    Zombie_Striker

    @plisov
    After looping through all the inventories contents, for loop though all the values of 'array'. If any of the values are false, then you know that you do not have all the items.
     
  2. Offline

    plisov

    Thanks for your help. I think I found a different way of doing it. Have a look. Everything seems to be working fine :)
    Code:
    
    
     
    Last edited: Jan 16, 2017
  3. Offline

    Zombie_Striker

    Don't blindly cast. How do you know the sender will always be a player? You don't. Check if the sender is an instanceof player first before casting.

    You have to null check first, since if the player is not on line the target will be null, but the online players can contain that null value.

    Also, if you are worried about a player being online, get the offline player instance and use .isOnline()

    You have a lot of copied and pasted code. Instead of this, create a for loop and and every time a number changes (in this case, 5), replace that number with the 1. That should reduce 50+ lines.
     
  4. Offline

    plisov

    Oops. I posted the wrong code. Thanks for the advice. Here is the actual traderGUI
    Code:
    
    
     
    Last edited: Jan 16, 2017
Thread Status:
Not open for further replies.

Share This Page