Hi there,
I am trying to create a plugin and I need to use both PlayerLoginEvent and PlayerQuitEvent.
With the first I intend to teleport a player to the spawn each time he/she logs in. The problem seems to be that this event is triggered before the player is an entity in a world, so trying to teleport an nonexistent entity would only return an error. Is there any other way to teleport a player when he/she logs in?
With the second one I intend to remove the player that logs out from a HashMap i have in a custom class using their UUID (so the HashMap is composed of a UUID and a BewomUser which contains a Player object, so I need the UUID of the player that disconnects to remove it from the HashMap). The problem is that there are three functions that can return Player in PlayerQuitEvent ( getUser(), getEntity() and getSource() ) but it seems that all three return a null object. Is that a bug in the API or is it just me?
Thanks.
PlayerJoinEvent
has a setLocation
method
It shouldn’t do. Are you testing on SpongeForge or SpongeVanilla? Also make sure you have the latest version.
Okay, I didn’t see the setLocation method in PlayerJoinEvent. It seems like it is now solved.
As of the other one (PlayerQuitEvent) i am testing on vanilla i think it’s build 523 or 524 because a couple of days ago I got the latest one as of then and it didn’t run, so I had to take a step back to the previous build. I will try doing so in the latest and bring you more info.
I am using the latest build (525) by running it with command “java -jar sponge.jar run” and the NullPointerException with PlayerQuitEvent is still there. Still giving me a null object when I ask for the player that disconnected.
Output the results of:
@Subscribe public void onPlayerQuit(PlayerQuitEvent event) {
logger.info("User: " + event.getUser());
logger.info("Source: " + event.getSource());
logger.info("Entity: " + event.getEntity());
}
Obviously, replace logger
with whatever method you wish.
EDIT: Not sure why my code is being wrapped like that, but whatever. xD
Here is the code and the result (i used System.out.println()):
Code: http://prntscr.com/7xqso6 (UserEventsHandler.java)
Error: http://prntscr.com/7xqt22
That’s not an NPE, it’s an AbstractMethodError
This PR will fix that
https://github.com/SpongePowered/Sponge/pull/152
Oh, yes, I see. I didn’t realize I got a different error. I normally get a NullPointerException and it seemed like the player i was getting was simply a null object, but i think I fixed it. Thanks for your help.
Also I am waiting for #88 to be fixed. Does anyone have any idea how long it takes normally to solve an issue like this?