1: <?php
2: namespace aliuly\common;
3: use aliuly\common\PluginAsyncTask;
4: use pocketmine\plugin\Plugin;
5: use pocketmine\Server;
6: use aliuly\common\GetMotd;
7:
8:
9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19:
20: class GetMotdAsyncTask extends PluginAsyncTask{
21: protected $host;
22: protected $port;
23: 24: 25: 26: 27: 28: 29:
30: public function __construct(Plugin $owner, $callable, $host, $port= 19132, array $args = []){
31: parent::__construct($owner,$callable,$args);
32: $this->host = $host;
33: $this->port = $port;
34: }
35: public function onRun() {
36: $this->setResult([
37: "host"=>$this->host,
38: "port" => $this->port,
39: "results" => null,
40: ]);
41: $res = GetMotd::query($this->host,$this->port);
42: $this->setResult([
43: "host"=>$this->host,
44: "port" => $this->port,
45: "results" => $res,
46: ]);
47: }
48: }
49: