More like
.getPlayerOnline()
More like
.getPlayerOnline()
For what purpose exactly should they do that?
I also think having only one player class is better. Like lrock23 said. It would just be easier for everyone to use only one class.
You need an interface for defining player data which is accessible regardless of online status, and an interface for defining player data which is only relevant while connected.
Bukkitâs solution (contrary to some of what jacklin wrote) was for an OfflinePlayer which represented the data available at all times, and a Player (extends OfflinePlayer) for the rest.
Player extends HumanEntity, Conversable, CommandSender, OfflinePlayer, PluginMessageRecipient
Meaning that the Player object (online player) is the only one thatâs an entity, and it also can send commands, receive messages, etc.
The only other solution I see that isnât cringe-worthy you could have is some sort of PlayerData class that holds what OfflinePlayer used to, and a Player object has a getPlayerData()
method for acquiring/setting that info. If you just force all Player-related stuff into one class, youâre doing something horrid like throwing exceptions when theyâre offline and you want their IP or want to have them send a message.
getOfflinePlayerData() on a Player object with an async API would be ideal.
Once we can figure out a scheduler, I want to work on a version of my Control Flow library to be used as a basis for an async API on API methods.
getOfflinePlayerData() on a Player object with an async API would be ideal
Sort of wondering how that would work out. The player is offline but Iâd have a player object with a teleport function? What would happen if I called the teleport of the Player object (that represents an offline player)?
I think ânothingâ is ok. Or a âPlayerOfflineExceptionâ. Even better would be moving the offline players location, but i think thats not possible. (?)
Remember the naming conventions:
.isOnline()
That is possible by changing playerâs .dat file.
Or you could just add their name to a hash map and teleport them on join.
Would require persisting/managing that state. If that is going to be done might as well update the DAT file.
Hmf
Actually, what can you do with online player you cannot do with the offlline one? The only thing that comes in mind to me is recieving and sending chat messages and commands.
I think everything is possible, but its the effort that matters ^^
Include one Player class for everything. And if a user tries to invoke methods that are only available to online players, while the target player is offline, throw a PlayerOfflineException
Which methods would that be?
.damage()
.getAddress()
.getEyeHeight()
.getLocation()
.getFallDistance()
.getFireTicks()
just to name a few.
.getLocation() would work if it returns the location where the player disconnected.
True. Didnât think of that one.
Anyways, you see thereâs many methods that could throw such an exception.
All of those could be taken from the player DAT except the .getAddress()