Solved NullPointerException

Discussion in 'Spigot Plugin Development' started by cayote20, Jun 18, 2020.

Thread Status:
Not open for further replies.
  1. If you want, add me on discord for easily helping you : HegSiS#7664
  2. Sent you a friend request
  3. drives_a_ford


    If this is the line you have an NPE on:
    Then simply add this right before:
    Code (Java):
    One of those will be null.
  4. Output:
    Code (Java):
    [15:55:58 INFO]: md.sintez.cloudfactions.system.units.Faction@2475ea8b
    [15:55:58 INFO]: null
    [15:55:58 INFO]: CraftPlayer{name=EstrangedFury}
    I know that this method returns a null value, I want to know why it happens
  5. drives_a_ford


    It's null because
    a) You never call the method that initializes the field
    b) There simply isn't a configuration section to get the string from. ConfigurationSection#getString returns null in such a situation

    If you want someone to help you, you'd be better off sharing the entire class.
  6. Solved. Special thanks to HegSiS.
    • Friendly Friendly x 1
Thread Status:
Not open for further replies.