|
Phpcraft
|


Public Member Functions | |
| __construct ($stream, ?Server &$server=null) | |
| handleInitialPacket () | |
| disconnect ($reason=[]) | |
| startPacket ($packet) | |
| getHost () | |
| sendEncryptionRequest ($private_key) | |
| handleEncryptionResponse ($private_key) | |
| isAuthenticationPending () | |
| handleAuthentication () | |
| finishLogin (UUID $uuid, Counter $eidCounter, int $compression_threshold=256) | |
| teleport (Point3D $pos, ?float $yaw=null, ?float $pitch=null) | |
| rotate (int $yaw, int $pitch) | |
| getEyePosition () | |
| getUnitVector () | |
| sendAdminBroadcast ($message, string $permission="everything") | |
| sendMessage ($message, int $position=ChatPosition::SYSTEM) | |
| getServer () | |
| hasPermission (string $permission) | |
| setGamemode (int $gamemode) | |
| sendAbilities () | |
| setAbilitiesFromGamemode (int $gamemode) | |
| getName () | |
| hasPosition () | |
| getPosition () | |
Public Member Functions inherited from Phpcraft\Connection | |
| __construct (int $protocol_version=-1, $stream=null) | |
| isOpen () | |
| setReadBuffer (string $buffer) | |
| getRemainingData () | |
| writeChat ($value) | |
| writeString (string $value) | |
| writeRaw (string $value) | |
| writeFloat (float $value) | |
| writePosition (Point3D $pos) | |
| writeLong ($value) | |
| writePrecisePosition (Point3D $pos) | |
| writeDouble (float $value) | |
| writeFixedPointPosition (Point3D $pos) | |
| writeInt ($value) | |
| writeSlot (Slot $slot) | |
| writeBoolean (bool $value) | |
| writeShort ($value) | |
| writeVarInt ($value) | |
| writeByte (int $value) | |
| writeUnsignedShort ($value) | |
| writeUnsignedByte (int $value) | |
| writeAngle (float $value) | |
| writeUUID (UUID $uuid) | |
| send (bool $raw=false) | |
| close () | |
| readRawPacket (float $timeout=3.000, int $bytes=0) | |
| getRemoteAddress () | |
| readPacket (float $timeout=3.000) | |
| readVarInt () | |
| readUnsignedByte () | |
| readAngle () | |
| readByte () | |
| readChat () | |
| readString (int $maxLength=32767, int $minLength=-1) | |
| readPosition () | |
| readPrecisePosition () | |
| readDouble () | |
| readFixedPointPosition () | |
| readInt () | |
| readUUID () | |
| readSlot (bool $additional_processing=true) | |
| readBoolean () | |
| readShort () | |
| readNBT (int $type=0) | |
| readRaw (int $bytes) | |
| readLong () | |
| readFloat () | |
| readUnsignedShort () | |
| ignoreBytes (int $bytes) | |
Public Member Functions inherited from Phpcraft\Command\CommandSender | |
| sendMessage ($message) | |
Public Attributes | |
| $hostname | |
| $hostport | |
| $join_specs = [] | |
| $username | |
| $uuid | |
| $config | |
| $next_heartbeat = 0 | |
| $disconnect_after = 0 | |
| $eid | |
| $pos | |
| $chunk_x | |
| $chunk_z | |
| $yaw = 0 | |
| $pitch = 0 | |
| $tpidCounter | |
| $tp_confirm_deadline = 0 | |
| $on_ground = false | |
| $render_distance = 8 | |
| $chunks = [] | |
| $gamemode = Gamemode::SURVIVAL | |
| $entityMetadata | |
| $invulnerable = false | |
| $flying = false | |
| $can_fly = false | |
| $instant_breaking = false | |
| $fly_speed = 0.05 | |
| $walk_speed = 0.1 | |
Public Attributes inherited from Phpcraft\Connection | |
| const | STATE_HANDSHAKE = 0 |
| const | STATE_STATUS = 1 |
| const | STATE_LOGIN = 2 |
| const | STATE_PLAY = 3 |
| $protocol_version | |
| $stream | |
| $compression_threshold = -1 | |
| $state | |
| $write_buffer = "" | |
| $read_buffer = "" | |
| $read_buffer_offset = 0 | |
Additional Inherited Members | |
Static Public Member Functions inherited from Phpcraft\Connection | |
| static | varInt ($value) |
Static Public Attributes inherited from Phpcraft\Connection | |
| static | $zero |
| static | $pow2 = [] |
A server-to-client connection.
| Phpcraft\ClientConnection::__construct | ( | $stream, | |
| ?Server & | $server = null |
||
| ) |
After this, you should call ClientConnection::handleInitialPacket().
| resource | $stream | |
| Server | null | $server |
| Phpcraft\ClientConnection::disconnect | ( | $reason = [] | ) |
Disconnects the client with a reason.
| array | string | $reason | The reason of the disconnect; chat object. |
| Phpcraft\ClientConnection::finishLogin | ( | UUID | $uuid, |
| Counter | $eidCounter, | ||
| int | $compression_threshold = 256 |
||
| ) |
Sets the compression threshold and finishes the login.
| UUID | $uuid | The UUID of the client. |
| Counter | $eidCounter | The server's Counter to assign an entity ID to the client. |
| int | $compression_threshold | The amount of bytes a packet needs to have before it is compressed. Use -1 to disable compression. Compression will always be disabled on loopback connections. |
| IOException |
| Phpcraft\ClientConnection::getEyePosition | ( | ) |
| Phpcraft\ClientConnection::getHost | ( | ) |
Returns the host the client had connected to, e.g. localhost:25565. Note that SRV records are pre-connection redirects, so if _minecraft._tcp.example.com points to mc.example.com which is an A or AAAA record, this will return mc.example.com:25565.
| Phpcraft\ClientConnection::getName | ( | ) |
Implements Phpcraft\Command\CommandSender.
| Phpcraft\ClientConnection::getPosition | ( | ) |
Implements Phpcraft\Command\CommandSender.
| Phpcraft\ClientConnection::getServer | ( | ) |
Implements Phpcraft\Command\ServerCommandSender.
| Phpcraft\ClientConnection::getUnitVector | ( | ) |
Returns a unit vector goin in the direction the client is looking.
| Phpcraft\ClientConnection::handleAuthentication | ( | ) |
Checks if the asynchronous authentication with Mojang has finished. In case of an error, the client is disconnected and 0 is returned. If Mojang's response was not yet received, 1 is returned. If Mojang's response was received and the authentication was successful, an array such as this is returned:
[
"id" => "11111111222233334444555555555555",
"name" => "Notch",
"properties" => [
[
"name" => "textures",
"value" => "<base64 string>",
"signature" => "<base64 string; signed data using Yggdrasil's private key>"
]
]
]| Phpcraft\ClientConnection::handleEncryptionResponse | ( | $private_key | ) |
Reads an encryption response packet and starts asynchronous authentication with Mojang. This requires ClientConnection::$username to be set. In case of an error, the client is disconnected and false is returned. Otherwise, true is returned, and ClientConnection::handleAuthentication should be regularly called to finish the authentication.
| resource | $private_key | Your OpenSSL private key resource. |
| IOException |
| Phpcraft\ClientConnection::handleInitialPacket | ( | ) |
Deals with the first packet the client has sent. This function deals with the handshake or legacy list ping packet. Errors will cause the connection to be closed.
| Phpcraft\ClientConnection::hasPermission | ( | string | $permission | ) |
| Phpcraft\ClientConnection::hasPosition | ( | ) |
Implements Phpcraft\Command\CommandSender.
| Phpcraft\ClientConnection::isAuthenticationPending | ( | ) |
Returns true if an asynchronous authentication with Mojang is still pending.
| Phpcraft\ClientConnection::rotate | ( | int | $yaw, |
| int | $pitch | ||
| ) |
Changes the client's rotation.
| int | $yaw | |
| int | $pitch |
| IOException |
| Phpcraft\ClientConnection::sendAbilities | ( | ) |
| Phpcraft\ClientConnection::sendAdminBroadcast | ( | $message, | |
| string | $permission = "everything" |
||
| ) |
Sends a message to the client and "[{$this->username}: $message]" to the server console and players with the given permission.
| array | string | $message | |
| string | $permission |
| IOException |
Implements Phpcraft\Command\CommandSender.
| Phpcraft\ClientConnection::sendEncryptionRequest | ( | $private_key | ) |
Sends an Encryption Request Packet.
| resource | $private_key | Your OpenSSL private key resource. |
| IOException |
| Phpcraft\ClientConnection::sendMessage | ( | $message, | |
| int | $position = ChatPosition::SYSTEM |
||
| ) |
Sends the client a chat message.
| array | string | $message | |
| int | $position |
| IOException |
| Phpcraft\ClientConnection::setAbilitiesFromGamemode | ( | int | $gamemode | ) |
Sets the client's abilities according to the given gamemode.
| int | $gamemode |
| Phpcraft\ClientConnection::setGamemode | ( | int | $gamemode | ) |
Sets the client's gamemode and adjusts their abilities accordingly.
| int | $gamemode |
| IOException |
| Phpcraft\ClientConnection::startPacket | ( | $packet | ) |
Clears the write buffer and starts a new packet.
| string | integer | $packet | The name or ID of the new packet. |
Reimplemented from Phpcraft\Connection.
| Phpcraft\ClientConnection::teleport | ( | Point3D | $pos, |
| ?float | $yaw = null, |
||
| ?float | $pitch = null |
||
| ) |
Teleports the client to the given position, and optionally, changes their rotation.
| Point3D | $pos | |
| float | null | $yaw | |
| float | null | $pitch |
| IOException |
| boolean Phpcraft\ClientConnection::$can_fly = false |
| int null Phpcraft\ClientConnection::$chunk_x |
| int null Phpcraft\ClientConnection::$chunk_z |
| array< string > Phpcraft\ClientConnection::$chunks = [] |
A string array of chunks the client has received.
| ClientConfiguration Phpcraft\ClientConnection::$config |
| float Phpcraft\ClientConnection::$disconnect_after = 0 |
This variable is for servers to keep track of how long clients have to answer keep alive packets.
| GMP Phpcraft\ClientConnection::$eid |
The client's entity ID.
| Player null Phpcraft\ClientConnection::$entityMetadata |
| float Phpcraft\ClientConnection::$fly_speed = 0.05 |
| boolean Phpcraft\ClientConnection::$flying = false |
| int Phpcraft\ClientConnection::$gamemode = Gamemode::SURVIVAL |
| string Phpcraft\ClientConnection::$hostname |
The hostname the client had connected to.
| int Phpcraft\ClientConnection::$hostport |
The port the client had connected to.
| boolean Phpcraft\ClientConnection::$instant_breaking = false |
| boolean Phpcraft\ClientConnection::$invulnerable = false |
| array< string > Phpcraft\ClientConnection::$join_specs = [] |
Additional data the client had provided in the handshake. E.g., "FML" is in this array for Forge clients.
| float Phpcraft\ClientConnection::$next_heartbeat = 0 |
This variable is for servers to keep track of when to send the next keep alive packet to clients.
| boolean Phpcraft\ClientConnection::$on_ground = false |
| float Phpcraft\ClientConnection::$pitch = 0 |
The client's rotation on the Y axis, -90 to 90.
| Point3D Phpcraft\ClientConnection::$pos |
The client's position.
| int Phpcraft\ClientConnection::$render_distance = 8 |
| float Phpcraft\ClientConnection::$tp_confirm_deadline = 0 |
| Counter Phpcraft\ClientConnection::$tpidCounter |
| string Phpcraft\ClientConnection::$username |
The client's in-game name.
| UUID Phpcraft\ClientConnection::$uuid |
The UUID of the client.
| float Phpcraft\ClientConnection::$walk_speed = 0.1 |
| float Phpcraft\ClientConnection::$yaw = 0 |
The client's rotation on the X axis, 0 to 359.9.
1.8.16