PlayerUtils
Player Teleportation
In version 1.10 BaseIO contains multiple teleport implementations. If you encounter issues regarding teleportations, try switching the implementation in BaseIO's config file
PlayerUtils.teleportPlayerUnsafe(EntityPlayerMP player, Position position)
teleports a player to the specified position forcibly. If you want to be sure the player doesn't teleport into blocks, use PlayerUtils.teleportPlayer(EntityPlayerMP player, Position position, boolean noisy)
. When the destination is an unsafe block this method won't teleport the player, returning false and (with noisy = true) printing a message to the player specifying the problem. For convenience teleportPlayer is overloaded with a ICommandSender instead of EntityPlayerMP (other senders than EntityPlayerMP will be discarded).
Identifier conversion
You might want to search a player by it's name quite often. For such cases (and many more "conversions") PlayerUtils provides a full set of conversion methods:
↓ From | To → | UUID | Name | GameProfile | EntityPlayer | ICommandSender |
UUID | PlayerUtils:getName | PlayerUtils:getGameProfile | PlayerUtils:getPlayer | PlayerUtils:getPlayer | |
Name | PlayerUtils:getUUID | PlayerUtils:getGameProfile | PlayerUtils:getPlayer | PlayerUtils:getPlayer | |
GameProfile | GameProfile:getId | GameProfile:getName | PlayerUtils:getPlayer | PlayerUtils:getPlayer | |
EntityPlayer | EntityPlayer:getUniqueId | ICommandSender:getName | EntityPlayer:getProfile | typecast | |
ICommandSender | PlayerUtils:getUUID | ICommandSender:getName | (only via typecast) | typecast |
If no player is found null
will be returned.
In 1.7, ICommandSender:getName was named ICommandSender:getCommandSenderName
PlayerUtils is capable to convert any ICommandSender to an UUID, including console and command blocks. This UUID might not be a valid UUID of Minecraft but it can be used to identify it and additionally PlayerUtils:getName supports these UUIDs. Every Command Sender of one class has the same UUID.
Ranges
All conversion methods have a range parameter that determines how broad the search should be.
Range | Inclusion | Full search area |
ONLINE | Includes online players | online players |
FAKE | Includes fake players | online (fake)players |
SERVER | Includes offline players | online/offline (fake)players |
ALL | Includes players that have never been on the server | all minecraft players |