コード例 #1
0
ファイル: Main.php プロジェクト: DWWf/pocketmine-plugins
 public function updateSigns()
 {
     $wp = $this->getServer()->getPluginManager()->getPlugin("WorldProtect");
     foreach ($this->getServer()->getLevels() as $lv) {
         foreach ($lv->getTiles() as $tile) {
             if (!$tile instanceof Sign) {
                 continue;
             }
             $sign = $tile->getText();
             if (!in_array($sign[0], $this->text["world"])) {
                 continue;
             }
             if (!($t = $this->matchCounter($sign[3]))) {
                 continue;
             }
             if (($lv = $this->getServer()->getLevelByName($sign[1])) !== null) {
                 $cnt = count($lv->getPlayers());
                 $max = null;
                 if ($wp !== null) {
                     $max = $wp->getMaxPlayers($lv->getName());
                 }
                 if ($max == null) {
                     $upd = $t . TextFormat::BLUE . $cnt;
                 } else {
                     $upd = $t . ($cnt >= $max ? TextFormat::RED : TextFormat::GREEN) . $cnt . "/" . $max;
                 }
             } else {
                 $upd = $t . mc::_("N/A");
             }
             if ($upd == $sign[3]) {
                 continue;
             }
             $tile->setText($sign[0], $sign[1], $sign[2], $upd);
         }
     }
 }
コード例 #2
0
 /**
  * Check's if $sender is a player in game
  *
  * @param CommandSender $sender
  * @param bool $msg If false, no message is shown
  * @return bool
  */
 public static function inGame(CommandSender $sender, $msg = true)
 {
     if (!$sender instanceof Player) {
         if ($msg) {
             $sender->sendMessage(mc::_("You can only do this in-game"));
         }
         return false;
     }
     return true;
 }