|
Phpcraft
|


Public Member Functions | |
| __construct (array $streams=[], $private_key=null) | |
| setGroups (array $groups) | |
| getGroup (string $name) | |
| isOpen () | |
| isListening () | |
| getPorts () | |
| getMotd () | |
| isOnlineMode () | |
| broadcast ($message, int $position=ChatPosition::SYSTEM) | |
| getPlayers () | |
| adminBroadcast ($message, string $permission="everything") | |
| permissionBroadcast (string $permission, $message, int $position=ChatPosition::SYSTEM) | |
| sendAdminBroadcast ($message, string $permission="everything") | |
| getOfflinePlayer (string $name_or_uuid) | |
| getPlayer ($name_or_uuid) | |
| getName () | |
| sendMessage ($message) | |
| close ($reason=[]) | |
| softClose () | |
| hasPermission (string $permission) | |
| getServer () | |
| hasPosition () | |
| getPosition () | |
Public Attributes | |
| $streams | |
| $private_key | |
| $clients | |
| $eidCounter | |
| $persist_configs = false | |
| $compression_threshold = 256 | |
| $groups = [] | |
| $join_function = null | |
| $packet_function = null | |
| $disconnect_function = null | |
| $list_ping_function = null | |
| $deny_incompatible_versions = true | |
| $open_condition | |
A basic Minecraft server. This deals with connections, configurations, handshakes, status requests, keep alive packets, and teleportation confirmations. This does not include implementing an entire server; that is what packet_function and IntegratedServer are for.
| Phpcraft\Server::__construct | ( | array | $streams = [], |
$private_key = null |
|||
| ) |
| array<resource> | $streams An array of streams created by stream_socket_server to listen for clients on. | |
| resource | null | $private_key | A private key generated using openssl_pkey_new(["private_key_bits" => 1024, "private_key_type" => OPENSSL_KEYTYPE_RSA]) to use for online mode, or null to use offline mode. |
| Phpcraft\Server::adminBroadcast | ( | $message, | |
| string | $permission = "everything" |
||
| ) |
Sends a message to the server console and all players with the given permission, e.g. "everything" for administrators.
| array | string | $message | |
| string | $permission |
| Phpcraft\Server::broadcast | ( | $message, | |
| int | $position = ChatPosition::SYSTEM |
||
| ) |
Sends a message to all players (clients in playing state) and prints it to the console.
| array | string | $message | |
| int | $position |
| Phpcraft\Server::close | ( | $reason = [] | ) |
Closes all server listen sockets and client connections.
| array | string | $reason | The reason for closing the server as a chat object, sent to all clients. |
| Phpcraft\Server::getGroup | ( | string | $name | ) |
Returns the group with the given name or null if not found.
| string | $name |
| Phpcraft\Server::getMotd | ( | ) |
Returns the "description" key from $this->list_ping_function's return array.
| Phpcraft\Server::getName | ( | ) |
Implements Phpcraft\Command\CommandSender.
| Phpcraft\Server::getOfflinePlayer | ( | string | $name_or_uuid | ) |
Gets the ClientConfiguration of a player who might be offline.
| string | UUID | $name_or_uuid |
| Phpcraft\Server::getPlayer | ( | $name_or_uuid | ) |
Returns a client in state 3 (playing) with the given name or UUID, or null if not found.
| string | UUID | $name_or_uuid |
| Phpcraft\Server::getPlayers | ( | ) |
Returns all clients in state 3 (playing).
| Phpcraft\Server::getPorts | ( | ) |
Returns the ports the server is listening on.
| Phpcraft\Server::getPosition | ( | ) |
Implements Phpcraft\Command\CommandSender.
| Phpcraft\Server::getServer | ( | ) |
Implements Phpcraft\Command\ServerCommandSender.
| Phpcraft\Server::hasPermission | ( | string | $permission | ) |
| Phpcraft\Server::hasPosition | ( | ) |
Implements Phpcraft\Command\CommandSender.
| Phpcraft\Server::isListening | ( | ) |
Returns true if the server has at least one socket to listen for new connections.
| Phpcraft\Server::isOnlineMode | ( | ) |
Returns true if the server is in online mode.
| Phpcraft\Server::isOpen | ( | ) |
Returns true if the server has at least one socket to listen for new connections on or at least one client.
| Phpcraft\Server::permissionBroadcast | ( | string | $permission, |
| $message, | |||
| int | $position = ChatPosition::SYSTEM |
||
| ) |
Sends a message to all clients in playing state with the given permission.
| string | $permission | |
| array | string | $message | |
| int | $position |
| Phpcraft\Server::sendAdminBroadcast | ( | $message, | |
| string | $permission = "everything" |
||
| ) |
Sends a message to the server console and "[Server: $message]" to all players with the given permission.
| array | string | $message | |
| string | $permission |
Implements Phpcraft\Command\CommandSender.
| Phpcraft\Server::sendMessage | ( | $message | ) |
Prints a message to the console. Available in accordance with the CommandSender interface. If you want to print to console specifically, just use PHP's echo.
| array | string | $message |
Implements Phpcraft\Command\CommandSender.
| Phpcraft\Server::setGroups | ( | array | $groups | ) |
| array<string,array<string,string|array<string>>> | $groups |
| Phpcraft\Server::softClose | ( | ) |
Closes all server listen sockets but keeps connected clients.
| SplObjectStorage Phpcraft\Server::$clients |
A ClientConnection array of all clients that are connected to the server.
| int Phpcraft\Server::$compression_threshold = 256 |
The amount of bytes at which a packet will be compressed. This applies bi-directionally, but the server decides on the value. Use -1 to disable compression.
| bool Phpcraft\Server::$deny_incompatible_versions = true |
If true, clients using incompatible versions will be prevented from logging in.
| callable Phpcraft\Server::$disconnect_function = null |
The function called when a client's disconnected from the server with the ClientConnection as argument.
| Counter Phpcraft\Server::$eidCounter |
The counter used to assign entity IDs.
| array< Group > Phpcraft\Server::$groups = [] |
| callable Phpcraft\Server::$join_function = null |
The function called when a client has entered state 3 (playing) with the ClientConnection as argument.
| callable Phpcraft\Server::$list_ping_function = null |
The function called when to get the server's response to a list ping request with the ClientConnection as argument or null if called internally to get list ping information, e.g. in a plugin. See Phpcraft::getServerStatus for an example of all the data a server may respond with (excluding "ping"). Additionally, if you set "no_ping", the client will show "(no connection)" where usually the ping in ms would be.
| Condition Phpcraft\Server::$open_condition |
| callable Phpcraft\Server::$packet_function = null |
The function called when the server receives a packet from a client in state 3 (playing) unless it's a keep alive response with the ClientConnection and ServerboundPacketId as arguments.
| bool Phpcraft\Server::$persist_configs = false |
True if you'd like every client's config to be persisted across connections from the same client. This is true by default on the IntegratedServer.
| resource Phpcraft\Server::$private_key |
A private key generated using openssl_pkey_new(["private_key_bits" => 1024, "private_key_type" => OPENSSL_KEYTYPE_RSA]) to use for online mode, or null to use offline mode.
| array< resource > Phpcraft\Server::$streams |
The streams the server listens for new connections on.
1.8.16