Revxrsal / Lamp

A powerful, extendable, flexible yet simple to use commands annotation framework.
MIT License
171 stars 33 forks source link

OfflinePlayer resolver #54

Closed SrBlecaute01 closed 1 year ago

SrBlecaute01 commented 1 year ago

Currently, in the OfflinePlayer resolver, a check is made to see if the player has played before. However, for new players who have just registered, the method returns false and it turns out that the command tends not to work for these new players.

Revxrsal commented 1 year ago

I think checking if the player is online fixes your issue but causes many other issues at the same time. If you want to require an online player, just use Player. OfflinePlayer only acts as a thin wrapper so that the command sender knows that the argument is a player name that may or may not be online, and therefore provide flexibility in parsing, completion, etc.

If that also doesn't fit you, you can always use a raw String and bind completions to it, or your own wrapper WrappedPlayer type that contains all the logic you'd like to do.

SrBlecaute01 commented 1 year ago

Maybe I expressed myself badly. I really just wanted to check the player's name, but at the same time know if that player has ever joined the server. The hasPlayedBefore is applicable for this, however for players who entered for the first time, only the first time, and who are still online the command would not work, as the method returns false since the files for it have not been saved yet. Thus, I performed the verification if he is online. I don't necessarily need it to be online so I didn't use the Player. Of course I could make a new resolver, the code is very flexible and that's why I like it, but the OfflinePlayer is the default and I thought I could apply it in general.

Revxrsal commented 1 year ago

I'm sorry, I haven't given the code a comprehensive look, and thought that it required OfflinePlayers to be online. I see no problem in the code, so I'll merge it. Thanks!