[SPIGOT-862] OfflinePlayer#hasPlayedBefore is not accurate. Created: 04/May/15 Updated: 21/May/15 Resolved: 21/May/15 |
|
Status: | Closed |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Major |
Reporter: | jjm_223 | Assignee: | Unassigned |
Resolution: | Invalid | Votes: | 0 |
Labels: | 1.8.3, bug, bukkit | ||
Environment: |
|
Attachments: |
![]() ![]() |
Description |
In the attached image, it shows two logins and a command ran upon entry both times. The first time, as shown, the plugin returns that the player has not played before. The second time, done after reconnecting, shows that the player has played before. This is a major issue in some cases, as many plugins use this to decide whether or not to save a file. An example is shown in a plugin called "EasyChests." It does not save a new player's chest, as hasPlayedBefore() returns false on them. |
Comments |
Comment by jjm_223 [ 21/May/15 ] |
Well in my case I was working on a voting listener. I used the method thinking it would say if an offline player has ever been on the server. My goal was to filter out usernames that were entered wrong, so essentials didn't create useless player files when the non-existent people were awarded money. Now that I am aware of what the method does, I've realized it is working correctly. |
Comment by Joshua Küpper [ 21/May/15 ] |
I'd guess the thing he was talking about is that hasPlayedBefore() should return true, from the moment on, the player connects from the first time the player connects and not from the first time a player disconnects. To clarify it even more, here's a sequence of events: ? - Player xy hasn't played before. My personal opinion on this: |
Comment by md_5 [ 21/May/15 ] |
What result are you looking for? hasPlayedBefore() will return false only once, the first time the player logs in. Is that different from what you are seeing? |
Comment by jjm_223 [ 21/May/15 ] |
Well, okay. Now that I think about it, that makes sense. I suppose I can just couple that with isOnline to get the result I'm looking for. Thanks for your time. It's a shame that my first report is invalid. |
Comment by md_5 [ 21/May/15 ] |
Yes, that is what the method is meant to do. |
Comment by jjm_223 [ 21/May/15 ] |
New players, as in players that recently joined the server for the first time, are not considered to have played before by the method. My screenshot shows this. When I join for the first time, it states I haven't played before. If I reconnect, it is accurate. |
Comment by md_5 [ 21/May/15 ] |
I don't understand, perhaps explain better. In your screenshot it looks like no issue. |