Phpcraft
|
Public Member Functions | |
__construct ($stream, ?Server &$server=null) | |
handleInitialPacket () | |
disconnect ($reason=null) | |
startPacket ($packet) | |
getHost () | |
sendEncryptionRequest ($private_key) | |
handleEncryptionResponse ($private_key, callable $callback) | |
finishLogin (UUID $uuid, Counter $eidCounter, int $compression_threshold=256) | |
teleport (Point3D $pos, ?float $yaw=null, ?float $pitch=null, int $deadline=3) | |
rotate (int $yaw, int $pitch) | |
getEyePosition () | |
getUnitVector () | |
generateChunkQueue () | |
unloadChunks () | |
getChunk () | |
getWorld () | |
getServer () | |
sendAdminBroadcast ($message, string $permission="everything") | |
sendMessage ($message, int $position=ChatPosition::SYSTEM) | |
hasPermission (string $permission) | |
setGamemode (int $gamemode, bool $abilities=true) | |
sendAbilities () | |
setAbilitiesFromGamemode (int $gamemode) | |
getName () | |
hasPosition () | |
getPosition () | |
hasServer () | |
Public Member Functions inherited from Phpcraft\Connection | |
__construct (int $protocol_version=-1, $stream=null) | |
isOpen () | |
setReadBuffer (string $buffer) | |
hasRemainingData () | |
getRemainingData () | |
writeChat (ChatComponent $value) | |
writeString (string $value) | |
writeRaw (string $value) | |
writeFloat (float $value) | |
writePosition (Point3D $pos) | |
writeGMP ($value, int $bytes, int $bits, bool $signed, int $gmp_export_options=GMP_MSW_FIRST|GMP_BIG_ENDIAN) | |
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 () | |
readGMP (int $bytes, int $bits, bool $signed, int $gmp_import_options=GMP_MSW_FIRST|GMP_BIG_ENDIAN) | |
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 | |
$downstream | |
$convert_packets | |
$eid | |
$downstream_eid | |
$world = "world" | |
$pos | |
$chunk_x | |
$chunk_z | |
$yaw = 0 | |
$pitch = 0 | |
$tpidCounter | |
$tp_confirm_deadline = 0 | |
$on_ground = false | |
$render_distance = 8 | |
$chunks = [] | |
$chunk_queue = [] | |
$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 |
const | LENIENCY_LENIENT = 1 |
const | LENIENCY_VANILLA = 0 |
const | LENIENCY_STRICT = -1 |
$protocol_version | |
$stream | |
$compression_threshold = -1 | |
$state | |
$write_buffer = "" | |
$lenient = false | |
$leniency = self::LENIENCY_VANILLA | |
$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 = null | ) |
Disconnects the client with an optional reason.
array | string | null | ChatComponent | $reason | The reason for the disconnect. |
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::generateChunkQueue | ( | ) |
Phpcraft\ClientConnection::getChunk | ( | ) |
Returns the chunk the client is standing in or null if there's no applicable world.
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\CommandSender.
Phpcraft\ClientConnection::getUnitVector | ( | ) |
Returns a unit vector goin in the direction the client is looking.
Phpcraft\ClientConnection::getWorld | ( | ) |
Returns a World that you can directly interact with or null if not applicable.
Phpcraft\ClientConnection::handleEncryptionResponse | ( | $private_key, | |
callable | $callback | ||
) |
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 the callback is called with false. Should the authentication with Mojang finish successfully, the callback is called with an array like this as argument:
[ "id" => "11111111222233334444555555555555", "name" => "Notch", "properties" => [ [ "name" => "textures", "value" => "<base64 string>", "signature" => "<base64 string; signed data using Yggdrasil's private key>" ] ] ]
resource | $private_key | Your OpenSSL private key resource. |
callable | $callback |
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::hasServer | ( | ) |
Available in accordance with the CommandSender interface.
Implements Phpcraft\Command\CommandSender.
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 | null | ChatComponent | $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 a chat message to the client.
array | string | null | ChatComponent | $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, |
bool | $abilities = true |
||
) |
Sets the client's gamemode and adjusts their abilities accordingly.
int | $gamemode | |
bool | $abilities | If false, abilities will not be touched. |
Exception |
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 , |
||
int | $deadline = 3 |
||
) |
Teleports the client to the given position, and optionally, changes their rotation.
Point3D | $pos | |
float | null | $yaw | |
float | null | $pitch | |
int | $deadline |
IOException |
Phpcraft\ClientConnection::unloadChunks | ( | ) |
IOException |
boolean Phpcraft\ClientConnection::$can_fly = false |
array Phpcraft\ClientConnection::$chunk_queue = [] |
int null Phpcraft\ClientConnection::$chunk_x |
int null Phpcraft\ClientConnection::$chunk_z |
array Phpcraft\ClientConnection::$chunks = [] |
ClientConfiguration Phpcraft\ClientConnection::$config |
bool Phpcraft\ClientConnection::$convert_packets |
Used by proxy servers to store if the client is incompatible with the downstream server and needs packets to be converted.
float Phpcraft\ClientConnection::$disconnect_after = 0 |
This variable is for servers to keep track of how long clients have to answer keep alive packets.
ServerConnection Phpcraft\ClientConnection::$downstream |
Used by proxy servers to store the downstream connection instance.
GMP Phpcraft\ClientConnection::$downstream_eid |
The downstream entity ID. Used only on proxy servers.
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 in the world they are in.
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 |
string Phpcraft\ClientConnection::$world = "world" |
The name of the world the client is in.
float Phpcraft\ClientConnection::$yaw = 0 |
The client's rotation on the X axis, 0 to 359.9.