Removing an item from an Inventory

Discussion in 'Plugin Development' started by WeeSkilz, Aug 23, 2014.

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

    WeeSkilz

    I am trying to make a plugin that removes all books by a certain player for my friend.

    I have registered the events and, using myself as the player for now, have tried to remove a book written by me when I interact with it in my inventory.

    This causes no errors whatsoever but the book does not disappear.

    Here is my code:

    http://paste.thezomg.com/14837/08834122/

    I would be incredibly grateful for any suggestions.
     
  2. Offline

    TheMcScavenger

    Code:
    current.getType() == Material.WRITTEN_BOOK
    Use:
    Code:java
    1. current.getType().equals(Material.WRITTEN_BOOK)
     
  3. Offline

    Zupsub

    This doesn't solve the problem, nor is it good practice.
     
  4. Offline

    LucasEmanuel

    WeeSkilz
    Can we see your plugin.yml file?

    Zupsub
    Please elaborate on why it's bad practice. :)
     
  5. Offline

    TheMcScavenger

    * suggests something *
    It is "good practice."
     
  6. Offline

    Dragonphase

    TheMcScavenger
    LucasEmanuel

    In this case your suggestion will change nothing. Using .equals() for enum members will simply defer to using ==. Using == is actually better in this case as it's faster and null-safe.
     
    LucasEmanuel likes this.
  7. Offline

    WeeSkilz

Thread Status:
Not open for further replies.

Share This Page