Very odd NPE

Discussion in 'Spigot Plugin Development' started by JordanOsterberg, May 12, 2015.

  1. Hello Spigot, today I found a very, very odd NPE.
    It is occurring here:
    PHP:
    if (z.getCustomName().contains("Leather")){
    and the odd thing is, this doesn't happen on another server using this plugin.
    PHP:
    java.lang.NullPointerException
    Core.java:226
     
    Thank you!
     
  2. @TheTrollzJ the zombie doesn't have a custom name.
     
  3. So I should add:
    PHP:
    if (z.getCustomName().equals(null){
    return;
    }
     
  4. Use == instead .equals to compare with null
     
  5. Thank you!
     
  6. hasCustomName() exists for this reason ;).
     
    • Winner Winner x 1