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: 
 3: namespace aliuly\common;
 4: use aliuly\common\Session;
 5: use pocketmine\event\player\PlayerJoinEvent;
 6: use pocketmine\plugin\PluginBase;
 7: use pocketmine\Player;
 8: 
 9: /**
10:  * Invisible Player sessions
11:  *
12:  * NOTE, if GrabBag is available, it will use the GrabBag invisible
13:  * implementation.  This gives you a command line interface and also
14:  * reduces the number of listeners in use.
15:  */
16: class InvisibleSession extends Session {
17:   protected $api;
18:   /**
19:    * @param PluginBase $owner - plugin that owns this session
20:    */
21:   public function __construct(PluginBase $owner) {
22:     $bag = $owner->getServer()->getPluginManager()->getPlugin("GrabBag");
23:     if ($bag && $bag->isEnabled() && MPMU::apiCheck($bag->getDescription()->getVersion(),"2.3") && $bag->api->getFeature("invisible")) {
24:       $this->api = $bag->api;
25:       return;
26:     }
27:     parent::__construct($owner);
28:     $this->api = null;
29:   }
30:   /**
31:    * Make player invisible
32:    * @param Player $player - player to change
33:    * @param bool $invis - if true (default) invisible, if false, visible.
34:    */
35:   public function invisible(Player $player, $invis) {
36:     if ($this->api !== null) {
37:       $this->api->invisible($player,$invis);
38:       return;
39:     }
40:     if ($invis) {
41:       if ($this->getState("invis",$player,false)) return;
42:       $this->setState("invis",$player,true);
43:       foreach($this->owner->getServer()->getOnlinePlayers() as $online){
44:         $online->hidePlayer($player);
45:       }
46:     } else {
47:       if (!$this->getState("invis",$player,false)) return;
48:       $this->unsetState("invis",$player);
49:       foreach($this->owner->getServer()->getOnlinePlayers() as $online){
50:         $online->showPlayer($player);
51:       }
52:     }
53:   }
54:   /**
55:    * Check if player is invisible...
56:    * @param Player $player - player to check
57:    */
58:   public function isInvisible(Player $player) {
59:     if ($this->api !== null) return $this->api->isInvisible($player);
60:     return $this->getState("invis",$player,false);
61:   }
62:   /**
63:    * Make sure that players are invisible to recent joiners...
64:    * --- this will conflict with SimpleAuthHelper's hide unauth players
65:    */
66:   public function onPlayerJoin(PlayerJoinEvent $e) {
67:         $pl = $e->getPlayer();
68:         foreach($this->owner->getServer()->getOnlinePlayers() as $online){
69:             if ($this->getState("invis",$online,false)) {
70:                 $pl->hidePlayer($online);
71:             }
72:         }
73:     }
74: }
75: 
API documentation generated by ApiGen