New problem with fortunecookie

Discussion in 'Plugin Development' started by Dark-Panther, Apr 11, 2011.

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

    Dark-Panther

    Well, I'm new to java, so I can't read the error-messages...
    I've got this one:
    The source code: here!
    The Plugin gives you a text message out, when you eat a cookie - that works, but the messages are strange and anoying...


    Any suggestions what to do? :S
     
  2. Offline

    Evenprime

    About reading error messages: The first line of the stack trace is usually the most useful, because it is the line of code that caused the Exception. The error therefore seems to be in the file Cookieevents.java at line 92.

    The line is
    Code:
    if (event.getItem().getType()==Material.COOKIE) {
    
    the error is a NullpointerException, therefore the only reason (in this case) for the error can be that event.getItem() returned null.
    To fix it you'd have to first check if event.getItem() does give you something other than null, before calling getType() on what you get from it.
    Code:
    if (event.getItem() != null && event.getItem().getType()==Material.COOKIE) {
    
    will therefore most likely fix your problem.
     
  3. Offline

    Dark-Panther

    Okay, thanks :D
    Add you to my plugin
     
  4. Offline

    Deathly

    There is alos a function called

    Code:
    event.hasItem()
    which will return true / false :)
     
Thread Status:
Not open for further replies.

Share This Page