Phpcraft
|
Public Member Functions | |
__construct () | |
discover () | |
Static Public Member Functions | |
static | announce (string $motd, $port) |
Public Attributes | |
const | MSG_REGEX = '/^\[MOTD\]([^\[\]]+)\[\/MOTD\]\[AD\]([0-9]{4,5})\[\/AD\]$/' |
$servers = [] | |
Phpcraft\LanInterface::__construct | ( | ) |
Constructs a LanInterface to ->discover LAN servers. Unlike LanInterface::announce, this requires the "sockets" extension.
IOException |
|
static |
Announces a LAN server. Minecraft does this every 1.5 seconds and once a host:port has been sent, it is added to the server list until the server list is refreshed, and can't be updated.
string | $motd | Supports ยง format for colour. |
int | string | $port | Although this is supposed to be an integer, Minecraft accepts and displays any string but connects to :25565 if this is not a valid port. Do with that as you wish. |
IOException |
Phpcraft\LanInterface::discover | ( | ) |
Checks for worlds/servers on the local network and updates $this->servers. Unlike Minecraft, Phpcraft dynamically updates the server list including MOTD changes and requires a server to be announced regularly, otherwise it will be removed. This function only needs to be called every 1-2 seconds (optimally every 1.5 seconds). If you want all servers at the time of execution, initiate a LanInterface instance, wait 1.5 to 2 seconds, then call discover, and finally access its ->servers.
Phpcraft\LanInterface::$servers = [] |
const Phpcraft\LanInterface::MSG_REGEX = '/^\[MOTD\]([^\[\]]+)\[\/MOTD\]\[AD\]([0-9]{4,5})\[\/AD\]$/' |