|
Phpcraft
|


Public Member Functions | |
| __construct (array $streams=[], $private_key=null) | |
| isOpen () | |
| setGroups (array $groups) | |
| getGroup (string $name) | |
| isListening () | |
| getPorts () | |
| getMotd () | |
| isOnlineMode () | |
| broadcast ($msg, int $position=ChatPosition::SYSTEM) | |
| getPlayers () | |
| adminBroadcast ($msg, string $permission="everything") | |
| permissionBroadcast (string $permission, $msg, int $position=ChatPosition::SYSTEM) | |
| sendAdminBroadcast ($message, string $permission="everything") | |
| getOfflinePlayer (string $name_or_uuid) | |
| getPlayer ($name_or_uuid) | |
| getName () | |
| sendMessage ($message) | |
| close ($reason=null) | |
| softClose () | |
| hasPermission (string $permission) | |
| hasServer () | |
| getServer () | |
| hasPosition () | |
| getPosition () | |
Public Attributes | |
| $streams | |
| $private_key | |
| $clients | |
| $persist_configs = false | |
| $compression_threshold = 256 | |
| $groups = [] | |
| $join_function = null | |
| $packet_function = null | |
| $disconnect_function = null | |
| $list_ping_function = null | |
| $allow_incompatible_versions = false | |
| $open_condition | |
Public Attributes inherited from Phpcraft\BareServer | |
| $worlds = [] | |
| $eidCounter | |
Protected Attributes | |
| $tick_loop | |
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 | ( | $msg, | |
| string | $permission = "everything" |
||
| ) |
Sends a message to the server console and all players with the given permission, e.g. "everything" for administrators.
| array | string | null | ChatComponent | $msg | |
| string | $permission |
| Phpcraft\Server::broadcast | ( | $msg, | |
| int | $position = ChatPosition::SYSTEM |
||
| ) |
Sends a message to all players and prints it to the console.
| array | string | null | ChatComponent | $msg | |
| int | $position |
| Phpcraft\Server::close | ( | $reason = null | ) |
Closes all server listen sockets and client connections.
| array | string | null | ChatComponent | $reason | The reason for closing the server, sent to clients before disconnecting them. |
| 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, cast to ChatComponent.
| 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).
Reimplemented in Phpcraft\ProxyServer.
| Phpcraft\Server::getPorts | ( | ) |
Returns the ports the server is listening on.
| Phpcraft\Server::getPosition | ( | ) |
Implements Phpcraft\Command\CommandSender.
| Phpcraft\Server::getServer | ( | ) |
Available in accordance with the CommandSender interface.
Implements Phpcraft\Command\CommandSender.
| Phpcraft\Server::hasPermission | ( | string | $permission | ) |
| Phpcraft\Server::hasPosition | ( | ) |
Implements Phpcraft\Command\CommandSender.
| Phpcraft\Server::hasServer | ( | ) |
Available in accordance with the CommandSender interface.
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, |
| $msg, | |||
| int | $position = ChatPosition::SYSTEM |
||
| ) |
Sends a message to all clients in playing state with the given permission.
| string | $permission | |
| array | string | null | ChatComponent | $msg | |
| 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 | null | ChatComponent | $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 | null | ChatComponent | $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.
| bool Phpcraft\Server::$allow_incompatible_versions = false |
If true, clients using incompatible versions will not be prevented from logging in.
| 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.
| callable Phpcraft\Server::$disconnect_function = null |
The function called when a client's disconnected from the server with the ClientConnection as argument.
| 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.
|
protected |
1.8.17