Overview

Namespaces

  • aliuly
    • common
      • selectors
    • loader
  • xPaw

Classes

  • aliuly\common\ArmorItems
  • aliuly\common\BasicCli
  • aliuly\common\BasicHelp
  • aliuly\common\BasicPlugin
  • aliuly\common\ChatSession
  • aliuly\common\Cmd
  • aliuly\common\CmdSelector
  • aliuly\common\ExpandVars
  • aliuly\common\FastTransfer
  • aliuly\common\FileUtils
  • aliuly\common\FreezeSession
  • aliuly\common\GetMotd
  • aliuly\common\GetMotdAsyncTask
  • aliuly\common\InvisibleSession
  • aliuly\common\InvUtils
  • aliuly\common\ItemName
  • aliuly\common\mc
  • aliuly\common\mc2
  • aliuly\common\MoneyAPI
  • aliuly\common\MPMU
  • aliuly\common\Npc
  • aliuly\common\PermUtils
  • aliuly\common\PluginAsyncTask
  • aliuly\common\PluginCallbackTask
  • aliuly\common\PMScript
  • aliuly\common\QueryAsyncTask
  • aliuly\common\Rcon
  • aliuly\common\RconTask
  • aliuly\common\selectors\All
  • aliuly\common\selectors\AllEntity
  • aliuly\common\selectors\BaseSelector
  • aliuly\common\selectors\Random
  • aliuly\common\Session
  • aliuly\common\ShieldSession
  • aliuly\common\ShoppingCart
  • aliuly\common\SignUtils
  • aliuly\common\SkinUtils
  • aliuly\common\SpySession
  • aliuly\common\SubCommandMap
  • aliuly\common\TPUtils
  • aliuly\loader\Main
  • xPaw\MinecraftQuery

Exceptions

  • xPaw\MinecraftQueryException
  • Overview
  • Namespace
  • Class
 1: <?php
 2: namespace aliuly\common;
 3: use aliuly\common\PluginAsyncTask;
 4: use pocketmine\plugin\Plugin;
 5: use pocketmine\Server;
 6: use xPaw\MinecraftQuery;
 7: use xPaw\MinecraftQueryException;
 8: 
 9: 
10: /**
11:  * A shortcut for doing a Query in the background.
12:  *
13:  * This is a class that allows you to query one host in the background.
14:  *
15:  * Usage:
16:  *
17:  *    new QueryAsyncTask($thisPlugin,"queryResults",$host,$port)
18:  *
19:  * And the method will be called when the query finishes.
20:  */
21: class QueryAsyncTask extends PluginAsyncTask{
22:     protected $host;
23:     protected $port;
24:     /**
25:      * @param Plugin    $owner
26:      * @param str       $callable       method from $owner to call
27:      * @param str           $host               host to query
28:      * @param int           $port               port of host to query
29:      * @param array   $args             arguments to pass to callback method
30:      */
31:     public function __construct(Plugin $owner, $callable, $host, $port= 19132, array $args = []){
32:         parent::__construct($owner,$callable,$args);
33:         $this->host = $host;
34:         $this->port = $port;
35:     }
36:     public function onRun() {
37:         $this->setResult([
38:             "host"=>$this->host,
39:             "port" => $this->port,
40:             "info" => null,
41:             "players" => null,
42:         ]);
43:         $Query = new MinecraftQuery( );
44:         try {
45:             //echo __METHOD__.",".__LINE__."\n";//##DEBUG
46:             //echo "host=$host port=$port\n";//##DEBUG
47:             $Query->Connect( $this->host, $this->port, 1 );
48:         } catch (MinecraftQueryException $e) {
49:             $this->setResult("Query ".$this->host." error: ".$e->getMessage());
50:             return;
51:         }
52:         $this->setResult([
53:             "host"=>$this->host,
54:             "port" => $this->port,
55:             "info" => $Query->GetInfo(),
56:             "players" => $Query->GetPlayers(),
57:         ]);
58:     }
59: }
60: 
API documentation generated by ApiGen