I am having issues when using Player.hasAttribute() early in the plug-in execution. For instance, this simplified example plug-in calls that method in several player event handlers:
This generates the following exception in the onPlayerConnect() when a player logs into the server:
This exception is apparently caught somewhere in the call chain, as it does not crash the server.
In this sample plug-in, the same Player.hasAttribute() method called in other event handlers does not raise any exception.
HOWEVER, in other plug-ins with more complex (and presumably lengthy) player initialisation (on connect or on spawn), I get an exception in the PlayerChangePositionEvent handler, which is apparently called before the PlayerSpawnEvent handler. This exception DOES crash the server.
Uses of that method in or after the PlayerSpawnEvent handler has been called seem to work correctly.
In all these cases, if I replace the offending call to Player.hasAttribute() with if (player.getAttribute(key_testAttr) == null) (semantically equivalent) no exception is raised.
This may be a work-around, but it seems like something strange is happening.