Player

Abstract class with abstract packet-related functions. It's implemented as another class by every version of Minecraft.

abstract
class Player : Human , WorldCommandSender {}

Constructors

this
this(PlayerInfo info, World world, EntityPosition position)
Undocumented in source.

Members

Aliases

lang
deprecated alias lang = language
Undocumented in source.
op
alias op = operator
Undocumented in source.
ping
deprecated alias ping = latency

Gets the player's latency (in milliseconds), calculated adding the latency from the client to the hub and the latency from the hub and the current node. For pocket edition players it's calculated through an UDP protocol and may not be accurate.

resetTitle
alias resetTitle = clearTitle

Removes the title displayed with the title property.

tip
alias tip = sendTip

Sends a tip message that will be displayed above the hotbar for two seconds before fading out.

Classes

Compression
class Compression
Undocumented in source.

Functions

attackImpl
void attackImpl(EntityDamageEvent event)
Undocumented in source. Be warned that the author may not have intended to support it.
broadcastMetadata
void broadcastMetadata()
Undocumented in source. Be warned that the author may not have intended to support it.
callCommand
void callCommand(string command)

Calls a command from a string.

callDeathEvent
EntityDeathEvent callDeathEvent(EntityDamageEvent last)
Undocumented in source. Be warned that the author may not have intended to support it.
clearTitle
void clearTitle()

Removes the title displayed with the title property.

close
void close()
Undocumented in source. Be warned that the author may not have intended to support it.
closeContainer
void closeContainer()
Undocumented in source. Be warned that the author may not have intended to support it.
compress
void compress(ubyte[] payload)
Undocumented in source. Be warned that the author may not have intended to support it.
consumeItemInHand
bool consumeItemInHand()
Undocumented in source. Be warned that the author may not have intended to support it.
die
void die()
Undocumented in source. Be warned that the author may not have intended to support it.
disconnect
void disconnect(string reason)

Disconnects the player from the server (from both the node and the hub). The reason can be a Translation.

disconnect
void disconnect(Translation reason)

Disconnects the player from the server (from both the node and the hub). The reason can be a Translation.

disconnectImpl
void disconnectImpl(Translation )
Undocumented in source.
experienceUpdated
void experienceUpdated()
Undocumented in source.
firstspawn
void firstspawn()
Undocumented in source. Be warned that the author may not have intended to support it.
flush
void flush()
Undocumented in source.
grantPermission
bool grantPermission(string permission)

Grants a permission.

handle
void handle(ubyte id, ubyte[] data)
Undocumented in source.
handleAbortBlockBreaking
void handleAbortBlockBreaking()
Undocumented in source. Be warned that the author may not have intended to support it.
handleArmSwing
void handleArmSwing()
Undocumented in source. Be warned that the author may not have intended to support it.
handleAttack
void handleAttack(Entity entity)
Undocumented in source. Be warned that the author may not have intended to support it.
handleAttack
void handleAttack(uint entity)
Undocumented in source. Be warned that the author may not have intended to support it.
handleBlockBreaking
bool handleBlockBreaking()
Undocumented in source. Be warned that the author may not have intended to support it.
handleBlockPlacing
void handleBlockPlacing(BlockPosition tpos, uint tface)
Undocumented in source. Be warned that the author may not have intended to support it.
handleChangeDimension
void handleChangeDimension()
Undocumented in source. Be warned that the author may not have intended to support it.
handleCompleteMessage
void handleCompleteMessage(string message, bool assumeCommand)

Completes the command args (or the command itself) if the arg type is an enum or a player (the ones in the world's list are sent), even if they are not spawned or visible to the player.

handleDrop
bool handleDrop(Slot slot)
Undocumented in source. Be warned that the author may not have intended to support it.
handleInteract
void handleInteract(Entity entity)
Undocumented in source. Be warned that the author may not have intended to support it.
handleInteract
void handleInteract(uint entity)
Undocumented in source. Be warned that the author may not have intended to support it.
handleJump
void handleJump()
Undocumented in source. Be warned that the author may not have intended to support it.
handleMapRequest
void handleMapRequest(ushort mapId)
Undocumented in source. Be warned that the author may not have intended to support it.
handleMovementPacket
void handleMovementPacket(EntityPosition position, float yaw, float bodyYaw, float pitch)
Undocumented in source. Be warned that the author may not have intended to support it.
handleReleaseItem
void handleReleaseItem()
Undocumented in source. Be warned that the author may not have intended to support it.
handleRespawn
void handleRespawn()
Undocumented in source. Be warned that the author may not have intended to support it.
handleRightClick
void handleRightClick(BlockPosition tpos, uint tface)
Undocumented in source. Be warned that the author may not have intended to support it.
handleSneaking
void handleSneaking(bool sneak)
Undocumented in source. Be warned that the author may not have intended to support it.
handleSprinting
void handleSprinting(bool sprint)
Undocumented in source. Be warned that the author may not have intended to support it.
handleStartBlockBreaking
bool handleStartBlockBreaking(BlockPosition position)
Undocumented in source. Be warned that the author may not have intended to support it.
handleStopSleeping
void handleStopSleeping()
Undocumented in source. Be warned that the author may not have intended to support it.
handleTextMessage
void handleTextMessage(string message)
Undocumented in source. Be warned that the author may not have intended to support it.
hasPermission
bool hasPermission(string permission)

Indicates whether the player has the given permission.

hide
bool hide(Entity entity)
Undocumented in source. Be warned that the author may not have intended to support it.
hideTitle
void hideTitle()

Hides the title displayed with the title property without resetting it.

onCollect
bool onCollect(Collectable collectable)
Undocumented in source. Be warned that the author may not have intended to support it.
openContainer
void openContainer(Container container, BlockPosition position)
Undocumented in source. Be warned that the author may not have intended to support it.
position
EntityPosition position()
Undocumented in source. Be warned that the author may not have intended to support it.
registerCommand
Command registerCommand(Command _command)

Adds a new command using a command-container class.

respawn
void respawn()
Undocumented in source. Be warned that the author may not have intended to support it.
revokePermission
bool revokePermission(string permission)

Revokes a permission.

sendAddList
void sendAddList(Player[] players)
Undocumented in source.
sendAnimation
void sendAnimation(Entity entity)
Undocumented in source.
sendArmorEquipment
void sendArmorEquipment(Player player)
Undocumented in source.
sendBlock
void sendBlock(PlacedBlock block)
Undocumented in source. Be warned that the author may not have intended to support it.
sendBlocks
void sendBlocks(PlacedBlock[] block)
Undocumented in source.
sendChangeDimension
void sendChangeDimension(Dimension from, Dimension to)
Undocumented in source.
sendChunk
void sendChunk(Chunk chunk)
Undocumented in source.
sendCompletedMessages
void sendCompletedMessages(string[] messages)
Undocumented in source.
sendDeathAnimation
void sendDeathAnimation(Entity entity)
Undocumented in source.
sendDeathSequence
void sendDeathSequence()
Undocumented in source.
sendDespawnEntity
void sendDespawnEntity(Entity entity)
Undocumented in source.
sendDifficulty
void sendDifficulty(Difficulty )
Undocumented in source.
sendDoDaylightCycle
void sendDoDaylightCycle(bool )
Undocumented in source.
sendEntityEquipment
void sendEntityEquipment(Player player)
Undocumented in source.
sendExplosion
void sendExplosion(EntityPosition position, float radius, Vector3!byte[] updates)
Undocumented in source.
sendGamemode
void sendGamemode()
Undocumented in source.
sendHeld
void sendHeld()
Undocumented in source.
sendHideTitles
void sendHideTitles()
Undocumented in source.
sendHurtAnimation
void sendHurtAnimation(Entity entity)
Undocumented in source.
sendInventory
void sendInventory(ubyte flag, bool[] slots)
Undocumented in source.
sendJoinPacket
void sendJoinPacket()
Undocumented in source.
sendLightning
void sendLightning(Lightning lightning)
Undocumented in source.
sendMap
void sendMap(Map map)
Undocumented in source.
sendMessageImpl
void sendMessageImpl(Message[] messages)
Undocumented in source.
sendMetadata
void sendMetadata(Entity entity)
Undocumented in source.
sendMotion
void sendMotion(EntityPosition motion)
Undocumented in source.
sendMotionUpdates
void sendMotionUpdates(Entity[] entities)
Undocumented in source.
sendMovementUpdates
void sendMovementUpdates(Entity[] entities)
Undocumented in source.
sendMovements
void sendMovements()
Undocumented in source. Be warned that the author may not have intended to support it.
sendMusic
void sendMusic(EntityPosition position, ubyte instrument, uint pitch)
Undocumented in source.
sendOpenContainer
void sendOpenContainer(ubyte type, ushort slots, BlockPosition position)
Undocumented in source.
sendPacketPayload
void sendPacketPayload(ubyte[] payload)
Undocumented in source. Be warned that the author may not have intended to support it.
sendPassenger
void sendPassenger(ubyte mode, uint passenger, uint vehicle)
Undocumented in source.
sendPermissionLevel
void sendPermissionLevel(PermissionLevel )
Undocumented in source.
sendPickupItem
void sendPickupItem(Entity picker, Entity picked)
Undocumented in source.
sendPosition
void sendPosition()
Undocumented in source.
sendRemoveList
void sendRemoveList(Player[] players)
Undocumented in source.
sendResetTitles
void sendResetTitles()
Undocumented in source.
sendResourcePack
void sendResourcePack()
Undocumented in source.
sendRespawnPacket
void sendRespawnPacket()
Undocumented in source.
sendSettingsPacket
void sendSettingsPacket()
Undocumented in source.
sendSpawnEntity
void sendSpawnEntity(Entity entity)
Undocumented in source.
sendSpawnPosition
void sendSpawnPosition()
Undocumented in source.
sendTile
void sendTile(Tile tiles, bool translatable)
Undocumented in source.
sendTime
void sendTime(uint )
Undocumented in source.
sendTip
void sendTip(E args)

Sends a tip message that will be displayed above the hotbar for two seconds before fading out.

sendTipImpl
void sendTipImpl(Message[] messages)
Undocumented in source.
sendTitle
void sendTitle(string title, string subtitle, uint fadeIn, uint stay, uint fadeOut)
void sendTitle(Title title, uint fadeIn, uint stay, uint fadeOut)

Sends a title message that will be displayed at the centre of the screen. The Title struct can be used to control the title message, the subtitle and the timing for the animations (fade in, stay and fade out).

sendTitle
void sendTitle(Title title, Subtitle subtitle, uint fadeIn, uint stay, uint fadeOut)

Sends a title message that will be displayed at the centre of the screen. The Title struct can be used to control the title message, the subtitle and the timing for the animations (fade in, stay and fade out).

sendTitleImpl
void sendTitleImpl(Title title, Subtitle subtitle, uint fadeIn, uint stay, uint fadeOut)
Undocumented in source.
sendUpdateLatency
void sendUpdateLatency(Player[] players)
Undocumented in source.
sendWeather
void sendWeather(bool , bool , uint , uint )
Undocumented in source.
sendWorldGamemode
void sendWorldGamemode(Gamemode )
Undocumented in source.
setAsReadyToSpawn
void setAsReadyToSpawn()
Undocumented in source.
show
bool show(Entity entity)
Undocumented in source. Be warned that the author may not have intended to support it.
spawnToItself
void spawnToItself()
Undocumented in source.
startCompression
void startCompression(uint hubId)
Undocumented in source. Be warned that the author may not have intended to support it.
stopCompression
void stopCompression()
Undocumented in source. Be warned that the author may not have intended to support it.
teleport
void teleport(EntityPosition position)
Undocumented in source. Be warned that the author may not have intended to support it.
teleport
void teleport(World world, EntityPosition position)
Undocumented in source. Be warned that the author may not have intended to support it.
tick
void tick()
Undocumented in source. Be warned that the author may not have intended to support it.
transfer
void transfer(Node node)

Transfers the player in another node. The target node should be in server.nodes, otherwise the player will be disconnected by the hub with "End of Stream" message.

transfer
void transfer(string ip, ushort port)

Transfers a player to given server and port if the client has the functionality to do so. Calling this method will not disconnect the player immediately.

unloadChunk
void unloadChunk(ChunkPosition pos)
Undocumented in source.
unregisterCommand
bool unregisterCommand(Command command)
bool unregisterCommand(string command)

Removes a command using the command class given in registerCommand.

updateAvailableCommands
void updateAvailableCommands()
Undocumented in source. Be warned that the author may not have intended to support it.
visibleEntities
Entity[] visibleEntities()
Undocumented in source. Be warned that the author may not have intended to support it.
visiblePlayers
Player[] visiblePlayers()
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

address
Address address [@property getter]

Gets the player's connection informations.

adventure
bool adventure [@property getter]

Gets the player's gamemode.

adventure
bool adventure [@property setter]

Sets the player's gamemode.

availableCommands
Command[string] availableCommands [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
consumeTools
bool consumeTools [@property getter]

Boolean values indicating whether or not the player's tools should be consumed when used.

container
Container container [@property getter]

Returns the the current container the player is viewing.

creative
bool creative [@property getter]

Gets the player's gamemode.

creative
bool creative [@property setter]

Sets the player's gamemode.

displayName
string displayName [@property setter]

Edits the player's displayed name, as it appears in the server's players list (it can be coloured). It can be edited on PlayerPreLoginEvent.

displayName
string displayName [@property getter]

Edits the player's displayed name, as it appears in the server's players list (it can be coloured). It can be edited on PlayerPreLoginEvent.

edu
bool edu [@property getter]

Indicates whether or not the player is using Minecraft: Education Edition.

game
string game [@property getter]

Gets the player's game.

gameName
string gameName [@property getter]

Gets the player's game name.

gameVersion
string gameVersion [@property getter]

Gets the player's game version.

gamemode
ubyte gamemode [@property getter]

Gets the player's gamemode.

gamemode
ubyte gamemode [@property setter]

Sets the player's gamemode.

hubId
uint hubId [@property getter]

Gets the player's hub id. It will always be the same for the same player even when it is transferred to another world or another node without leaving the server.

inputMode
InputMode inputMode [@property getter]

Gets the player's input mode.

ip
string ip [@property getter]

Gets the player's connection informations.

language
string language [@property getter]

Gets the language of the player. The string will be in the Settings.ACCEPTED_LANGUAGES array, as indicated in the hub's configuration file.

latency
uint latency [@property getter]

Gets the player's latency (in milliseconds), calculated adding the latency from the client to the hub and the latency from the hub and the current node. For pocket edition players it's calculated through an UDP protocol and may not be accurate.

lname
string lname [@property getter]

Gets the player's username converted to lowercase.

localDisplayName
string localDisplayName [@property setter]

Updates the display name but only for the current world and children/parents. When the player is transferred to another node or to another group of world the display name is resetted.

motion
EntityPosition motion [@property setter]

Sets the motion and let the client do its physic actions.

name
string name [@property getter]

Gets the player's raw name conserving the original upper-lowercase format.

online
bool online [@property getter]

Indicates whether or not the player is still connected to the node.

operator
bool operator [@property setter]

If the player has a permission level or 0 (user), sets it to 1 (operator).

operator
bool operator [@property getter]

Indicates whether the player has a permission level higher or equals than 1 (operator).

packetLoss
float packetLoss [@property getter]

Gets the player's packet loss, if the client is connected through and UDP protocol.

permissionLevel
PermissionLevel permissionLevel [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
permissionLevel
PermissionLevel permissionLevel [@property getter]

Gets the player's permission level.

permissions
string[] permissions [@property getter]

Gets a list of the player's permissions.

port
ushort port [@property getter]

Gets the player's connection informations.

protocol
uint protocol [@property getter]

Gets the player's game protocol.

server
shared(NodeServer) server [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
spawn
BlockPosition spawn [@property setter]

Sets the player's spawn point.

spawn
EntityPosition spawn [@property setter]

Sets the player's spawn point.

spectator
bool spectator [@property setter]

Sets the player's gamemode.

spectator
bool spectator [@property getter]

Gets the player's gamemode.

survival
bool survival [@property setter]

Sets the player's gamemode.

survival
bool survival [@property getter]

Gets the player's gamemode.

usedIp
string usedIp [@property getter]
usedPort
ushort usedPort [@property getter]

Gets the ip and the port the player has used to join the server.

world
World world [@property setter]

Teleports the player to another world.

world
World world [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

breaking
BlockPosition breaking;
Undocumented in source.
chatName
string chatName;
Undocumented in source.
chunksUntilSpawn
size_t chunksUntilSpawn;
Undocumented in source.
connectedSameMachine
bool connectedSameMachine;
connectedSameNetwork
bool connectedSameNetwork;
Undocumented in source.
gameId
ubyte gameId;
Undocumented in source.
hasResourcePack
bool hasResourcePack;
Undocumented in source.
info
PlayerInfo info;
Undocumented in source.
is_breaking
bool is_breaking;
Undocumented in source.
joined
bool joined;
Undocumented in source.
last_chunk_position
ChunkPosition last_chunk_position;
Undocumented in source.
last_chunk_update
tick_t last_chunk_update;
Undocumented in source.
loaded_chunks
ChunkPosition[] loaded_chunks;
Undocumented in source.
order
uint order;
Undocumented in source.
updateArmorToViewers
bool updateArmorToViewers;
Undocumented in source.
updateInventoryToViewers
bool updateInventoryToViewers;
Undocumented in source.
viewDistance
size_t viewDistance;
Undocumented in source.

Inherited Members

From Human

WIDTH
auto WIDTH;
Undocumented in source.
HEIGHT
auto HEIGHT;
Undocumented in source.
m_hunger
Hunger m_hunger;
Undocumented in source.
m_spawn
EntityPosition m_spawn;
Undocumented in source.
skin
Skin skin;
Undocumented in source.
inventory
PlayerInventory inventory;
Undocumented in source.
type
string type [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
tick
void tick()
Undocumented in source. Be warned that the author may not have intended to support it.
spawned
bool spawned [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
spawn
EntityPosition spawn [@property getter]

Get the spawn point

spawn
EntityPosition spawn [@property setter]
BlockPosition spawn [@property setter]

Set the spawn point

die
void die()
Undocumented in source. Be warned that the author may not have intended to support it.
despawnAfter
tick_t despawnAfter [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
despawn
void despawn()
Undocumented in source. Be warned that the author may not have intended to support it.
respawn
void respawn()
Undocumented in source. Be warned that the author may not have intended to support it.
firstspawn
void firstspawn()
Undocumented in source. Be warned that the author may not have intended to support it.
canAttack
bool canAttack [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
attackImpl
void attackImpl(EntityDamageEvent event)
Undocumented in source. Be warned that the author may not have intended to support it.
hunger
uint hunger [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
hunger
uint hunger [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
exhaust
void exhaust(float amount)
Undocumented in source. Be warned that the author may not have intended to support it.
saturate
void saturate(float amount)
Undocumented in source. Be warned that the author may not have intended to support it.
saturation
float saturation [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
experience
float experience [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
experience
float experience [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
level
uint level [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
level
uint level [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
hungerUpdated
void hungerUpdated()
Undocumented in source. Be warned that the author may not have intended to support it.
healthUpdated
void healthUpdated()
Undocumented in source. Be warned that the author may not have intended to support it.
experienceUpdated
void experienceUpdated()
Undocumented in source. Be warned that the author may not have intended to support it.
onCollect
bool onCollect(Collectable collectable)
Undocumented in source. Be warned that the author may not have intended to support it.

Meta