예제 #1
0
 /**
  * @priority HIGHEST
  */
 public function onTeleport(EntityTeleportEvent $ev)
 {
     //echo __METHOD__.",".__LINE__."\n"; //##DEBUG
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getEntity();
     if (!$pl instanceof Player) {
         return;
     }
     if ($pl->hasPermission("wp.cmd.gm.exempt")) {
         return;
     }
     //echo __METHOD__.",".__LINE__."\n"; //##DEBUG
     $world = $ev->getTo()->getLevel();
     if (!$world) {
         $world = $pl->getLevel();
     }
     $world = $world->getName();
     $gm = $this->owner->getCfg($world, "gamemode", null);
     if ($gm === null) {
         $gm = $this->owner->getServer()->getGamemode();
     }
     if ($pl->getGamemode() == $gm) {
         return;
     }
     $pl->sendMessage(mc::_("Changing gamemode to %1%", MPMU::gamemodeStr($gm)));
     $pl->setGamemode($gm);
 }
예제 #2
0
 private function wpDetails(CommandSender $c, $world, $pageNumber)
 {
     if (!$this->owner->getServer()->isLevelGenerated($world)) {
         $c->sendMessage(mc::_("World %1% does not exist", $world));
         return;
     }
     $f = $this->owner->getServer()->getDataPath() . "worlds/{$world}/wpcfg.yml";
     if (!is_file($f)) {
         $c->sendMessage(mc::_("World %1% is not protected", $world));
         return;
     }
     $wcfg = (new Config($f, Config::YAML))->getAll();
     $txt = [mc::_("Details for %1%", $world)];
     if (isset($wcfg["protect"])) {
         $txt[] = TextFormat::AQUA . mc::_("Protect:  ") . TextFormat::WHITE . $wcfg["protect"];
     }
     if (isset($wcfg["max-players"])) {
         $txt[] = TextFormat::AQUA . mc::_("Max Players:  ") . TextFormat::WHITE . $wcfg["max-players"];
     }
     if (isset($wcfg["gamemode"])) {
         $txt[] = TextFormat::AQUA . mc::_("Gamemode:  ") . TextFormat::WHITE . MPMU::gamemodeStr($wcfg["gamemode"]);
     }
     if (isset($wcfg["pvp"])) {
         if ($wcfg["pvp"] === true) {
             $txt[] = TextFormat::AQUA . mc::_("PvP: ") . TextFormat::RED . mc::_("on");
         } elseif ($wcfg["pvp"] === false) {
             $txt[] = TextFormat::AQUA . mc::_("PvP: ") . TextFormat::GREEN . mc::_("off");
         } else {
             $txt[] = TextFormat::AQUA . mc::_("PvP: ") . TextFormat::YELLOW . mc::_("spawn-off");
         }
     }
     if (isset($wcfg["no-explode"])) {
         if ($wcfg["no-explode"] === "off") {
             $txt[] = TextFormat::AQUA . mc::_("NoExplode: ") . TextFormat::RED . mc::_("off");
         } elseif ($wcfg["no-explode"] === "world") {
             $txt[] = TextFormat::AQUA . mc::_("NoExplode: ") . TextFormat::GREEN . mc::_("world");
         } else {
             $txt[] = TextFormat::AQUA . mc::_("NoExplode: ") . TextFormat::YELLOW . mc::_("spawn");
         }
     }
     if (isset($wcfg["border"])) {
         $txt[] = TextFormat::AQUA . mc::_("Border: ") . TextFormat::WHITE . implode(",", $wcfg["border"]);
     }
     if (isset($wcfg["auth"])) {
         $txt[] = TextFormat::AQUA . mc::_("Auth List(%1%): ", count($wcfg["auth"])) . TextFormat::WHITE . implode(",", $wcfg["auth"]);
     }
     if (isset($wcfg["unbreakable"])) {
         $txt[] = TextFormat::AQUA . mc::_("Unbreakable(%1%): ", count($wcfg["unbreakable"])) . TextFormat::WHITE . implode(",", $wcfg["unbreakable"]);
     }
     if (isset($wcfg["banitem"])) {
         $txt[] = TextFormat::AQUA . mc::_("Banned(%1%): ", count($wcfg["banitem"])) . TextFormat::WHITE . implode(",", $wcfg["banitem"]);
     }
     if (isset($wcfg["motd"])) {
         $txt[] = mc::_("MOTD:");
         if (is_array($wcfg["motd"])) {
             foreach ($wcfg["motd"] as $ln) {
                 $txt[] = TextFormat::BLUE . "  " . $ln . TextFormat::RESET;
             }
         } else {
             $txt[] = TextFormat::BLUE . "  " . $wcfg["motd"];
         }
     }
     return $this->paginateText($c, $pageNumber, $txt);
 }