goldman40 / php-rcon-minecraft
从php向minecraft发送命令
dev-master
2016-11-13 19:41 UTC
Requires
- php: >=5.4
This package is not auto-updated.
Last update: 2024-09-28 18:42:21 UTC
README
PHP的简单Rcon类。
连接通过TCP建立。
可在 https://packagist.org.cn/packages/goldman40/php-rcon-minecraft 获取
示例
为了使此脚本工作,需要在服务器上启用rcon,通过在服务器的 server.properties
文件中设置 enable-rcon=true
。还需要设置一个密码,并在脚本中提供。
use thedudeguy\Rcon; $host = 'some.minecraftserver.com'; // Server host name or IP $port = 25567; // Port rcon is listening on $password = 'server-rcon-password'; // rcon.password setting set in server.properties $timeout = 3; // How long to timeout. Default 3 $rcon = new Rcon($host, $port, $password, $timeout); if ($rcon->connect()) { $rcon->send_command("say Hello World!"); }