.equals ItemStack Method problem

Discussion in 'Plugin Development' started by HeavyMine13, Jan 17, 2016.

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

    HeavyMine13

    Hey! So I made an ItemStack Method. Then I tried to check if p.getItemInHand() == item(), it did not work, but when I used p.getItemInHand().isSimilarTo(item()), it worked. Why did this happen? Thanks!
     
  2. Offline

    Javlin

    You can't use "==" to compare objects, only primitive types.
     
  3. Offline

    Zombie_Striker

    @HeavyMine13
    This is a basic java problem. "==" compares memory space. ".equals()" compares all of the object's values. ".isSimular()" compares some of the object's values.
     
  4. Offline

    Caedus

    Think you're looking for:

    p.getItemInHand().getType() == Material.ITEM
     
    Zombie_Striker likes this.
Thread Status:
Not open for further replies.

Share This Page