Solved Odd NPE

Discussion in 'Plugin Development' started by Squawkers13, May 13, 2014.

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

    Squawkers13

    For some reason this throws a NullPointerException when used in a listener for a PlayerQuitEvent.
    Unsure why.
    The stacktrace points to this and nothing else.
    Code:java
    1. for (Player player : plugin.getServer().getOnlinePlayers()) {
    2. //Code here
    3. }
     
  2. Offline

    Gater12

    Squawkers13
    It could be plugin that is null.

    Or a quick fix, use Bukkit which is like getServer() but static.
     
  3. Offline

    number1_Master

    I would guess that either the plugin is null or there are no players online.
     
  4. Offline

    Squawkers13

    plugin was null. :p
     
Thread Status:
Not open for further replies.

Share This Page