当前位置: 首页>>代码示例>>PHP>>正文


PHP Server::getInstance方法代码示例

本文整理汇总了PHP中pocketmine\Server::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::getInstance方法的具体用法?PHP Server::getInstance怎么用?PHP Server::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\Server的用法示例。


在下文中一共展示了Server::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendPacket

 public function sendPacket(DataPacket $packet)
 {
     Server::getInstance()->getPluginManager()->callEvent($ev = new CustomPacketSendEvent($packet));
     if (!$ev->isCancelled()) {
         $this->pushInternalQueue([chr(Info::PACKET_SEND), $packet]);
     }
 }
开发者ID:JungHyun3459,项目名称:CustomPacket,代码行数:7,代码来源:SocketInterface.php

示例2: onRun

 public function onRun($currentTicks)
 {
     /** @var EntityManager $owner */
     $owner = $this->owner;
     $rand = explode("/", $owner->getData("spawn.rand", "1/4"));
     foreach (EntityManager::$spawn as $key => $data) {
         if (mt_rand(...$rand) > $rand[0]) {
             continue;
         }
         if (count($data["mob-list"]) === 0) {
             unset(EntityManager::$spawn[$key]);
             continue;
         }
         $radius = (int) $data["radius"];
         $pos = Position::fromObject(new Vector3(...$vec = explode(":", $key)), ($k = Server::getInstance()->getLevelByName((string) array_pop($vec))) == null ? Server::getInstance()->getDefaultLevel() : $k);
         $pos->y = $pos->getLevel()->getHighestBlockAt($pos->x += mt_rand(-$radius, $radius), $pos->z += mt_rand(-$radius, $radius));
         EntityManager::create($data["mob-list"][mt_rand(0, count($data["mob-list"]) - 1)], $pos);
     }
     if (!$owner->getData("autospawn.turn-on", true)) {
         return;
     }
     foreach ($this->owner->getServer()->getOnlinePlayers() as $player) {
         if (mt_rand(...$rand) > $rand[0]) {
             continue;
         }
         $radius = (int) $owner->getData("autospawn.radius", 25);
         $pos = $player->getPosition();
         $pos->y = $player->level->getHighestBlockAt($pos->x += mt_rand(-$radius, $radius), $pos->z += mt_rand(-$radius, $radius)) + 2;
         $ent = [["Cow", "Pig", "Sheep", "Chicken", "Slime", "Wolf", "Ocelot", "Rabbit"], ["Zombie", "Creeper", "Skeleton", "Spider", "PigZombie", "Enderman", "", ""]];
         $entity = EntityManager::create($ent[mt_rand(0, 1)][mt_rand(0, 7)], $pos);
         if ($entity != null) {
             $entity->spawnToAll();
         }
     }
 }
开发者ID:steveritter,项目名称:EntityManager,代码行数:35,代码来源:SpawnEntityTask.php

示例3: getEconomyAPI

 /**
  * Get EconomyAPI instance
  *
  * @return \onebone\economyapi\EconomyAPI|null
  */
 public static function getEconomyAPI()
 {
     if (self::$economyAPI === null and Server::getInstance()->getPluginManager()->getPlugin("EconomyAPI") !== null) {
         self::$economyAPI = \onebone\economyapi\EconomyAPI::getInstance();
     }
     return self::$economyAPI;
 }
开发者ID:ChalkPE,项目名称:ExamplePlugin,代码行数:12,代码来源:EconomyAPIListener.php

示例4: onEnable

 public function onEnable()
 {
     self::$instance = $this;
     PluginUtils::consoleLog("Initializing");
     // Get arena positions from arenas.yml
     @mkdir($this->getDataFolder());
     $this->arenaConfig = new Config($this->getDataFolder() . "config.yml", Config::YAML, array());
     $this->arenaManager = new ArenaManager();
     $this->arenaManager->init($this->arenaConfig);
     //Register events
     $this->getServer()->getPluginManager()->registerEvents(new EventManager($this->arenaManager), $this);
     //Register commands
     $addArenaCommand = new AddArenaCommand($this, $this->arenaManager);
     $this->getServer()->getCommandMap()->register($addArenaCommand->commandName, $addArenaCommand);
     $chestPlaceCmd = new ChestPlaceCommand($this, $this->arenaManager);
     $this->getServer()->getCommandMap()->register($chestPlaceCmd->commandName, $chestPlaceCmd);
     $spawnAddCmd = new SpawnAddCommand($this, $this->arenaManager);
     $this->getServer()->getCommandMap()->register($spawnAddCmd->commandName, $spawnAddCmd);
     $spawnToArenaCmd = new SpawnToArenaCommand($this, $this->arenaManager);
     $this->getServer()->getCommandMap()->register($spawnToArenaCmd->commandName, $spawnToArenaCmd);
     $addLobbyCmd = new AddLobbyCommand($this, $this->arenaManager);
     $this->getServer()->getCommandMap()->register($addLobbyCmd->commandName, $addLobbyCmd);
     $task = new MatchStarter($this->getInstance(), $this->arenaManager);
     Server::getInstance()->getScheduler()->scheduleDelayedRepeatingTask($task, 20, 20);
     $chestTask = new ChestRefreshTask($this->getInstance(), $this->arenaManager);
     Server::getInstance()->getScheduler()->scheduleDelayedRepeatingTask($chestTask, 20 * 120, 20 * 120);
 }
开发者ID:TuffDev,项目名称:HungerGames,代码行数:27,代码来源:HungerGames.php

示例5: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($item->getId() === Item::DYE and $item->getDamage() === 0xf) {
         //Bonemeal
         if ($this->getSide(0)->getId() !== self::SUGARCANE_BLOCK) {
             for ($y = 1; $y < 3; ++$y) {
                 $b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
                 if ($b->getId() === self::AIR) {
                     Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Sugarcane()));
                     if (!$ev->isCancelled()) {
                         $this->getLevel()->setBlock($b, $ev->getNewState(), true);
                     }
                     break;
                 }
             }
             $this->meta = 0;
             $this->getLevel()->setBlock($this, $this, true);
         }
         if (($player->gamemode & 0x1) === 0) {
             $item->count--;
         }
         return true;
     }
     return false;
 }
开发者ID:mattiasaxelsson,项目名称:PocketMine-MP,代码行数:25,代码来源:Sugarcane.php

示例6: onUpdate

 public function onUpdate($type)
 {
     if ($type === Level::BLOCK_UPDATE_NORMAL) {
         $faces = array_flip(array(2 => 2, 3 => 4, 4 => 5, 5 => 3));
         if ($this->getSide(Vector3::getOppositeSide($faces[$this->meta % 4 + 2]))->isTransparent() === true) {
             $this->getLevel()->useBreakOn($this);
             return Level::BLOCK_UPDATE_NORMAL;
         }
     } elseif ($type === Level::BLOCK_UPDATE_RANDOM) {
         if (mt_rand(0, 2) === 1) {
             if ($this->meta < 8) {
                 $block = clone $this;
                 $block->meta += 4;
                 Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
                 if (!$ev->isCancelled()) {
                     $this->getLevel()->setBlock($this, $ev->getNewState(), true, true);
                 } else {
                     return Level::BLOCK_UPDATE_RANDOM;
                 }
             }
         } else {
             return Level::BLOCK_UPDATE_RANDOM;
         }
     }
     return false;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:26,代码来源:CocoaPod.php

示例7: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     $args[0] = isset($args[0]) ? strtolower($args[0]) : "";
     $title = "";
     switch ($args[0]) {
         case "ips":
             $list = $sender->getServer()->getIPBans();
             $title = "commands.banlist.ips";
             break;
         case "cids":
             $list = $list = $sender->getServer()->getCIDBans();
             $title = "commands.banlist.cids";
             break;
         case "players":
             $list = $sender->getServer()->getNameBans();
             $title = "commands.banlist.players";
             break;
         default:
             $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
             return false;
     }
     $message = "";
     $list = $list->getEntries();
     foreach ($list as $entry) {
         $message .= $entry->getName() . ", ";
     }
     $sender->sendMessage(Server::getInstance()->getLanguage()->translateString($title, [count($list)]));
     $sender->sendMessage(\substr($message, 0, -2));
     return true;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:33,代码来源:BanListCommand.php

示例8: onEnable

 public function onEnable()
 {
     //アイテムの追加
     Item::$list[self::ITEM_FLOWER_POT] = ItemFlowerPot::class;
     //ブロックの追加
     $this->registerBlock(self::BLOCK_FLOWER_POT, BlockFlowerPot::class);
     //ブロックタイルエンティティの追加
     Tile::registerTile(FlowerPot::class);
     //アイテムをクリエイティブタブに追加
     Item::addCreativeItem(Item::get(self::ITEM_FLOWER_POT, 0));
     //一応レシピ追加
     Server::getInstance()->getCraftingManager()->registerRecipe((new ShapedRecipe(Item::get(MainClass::ITEM_FLOWER_POT, 0, 1), "X X", " X "))->setIngredient("X", Item::get(Item::BRICK, null)));
     //omake skull
     //アイテムの追加
     Item::$list[self::ITEM_SKULL] = ItemSkull::class;
     //ブロックの追加
     $this->registerBlock(self::BLOCK_SKULL, BlockSkull::class);
     //ブロックタイルエンティティの追加
     Tile::registerTile(Skull::class);
     //アイテムをクリエイティブタブに追加
     Item::addCreativeItem(Item::get(self::ITEM_SKULL, 0));
     Item::addCreativeItem(Item::get(self::ITEM_SKULL, 1));
     Item::addCreativeItem(Item::get(self::ITEM_SKULL, 2));
     Item::addCreativeItem(Item::get(self::ITEM_SKULL, 3));
     Item::addCreativeItem(Item::get(self::ITEM_SKULL, 4));
 }
开发者ID:MrDoni98,项目名称:PocketMine-MP-Plugins,代码行数:26,代码来源:MainClass.php

示例9: onUpdate

 public function onUpdate($type)
 {
     if ($type === Level::BLOCK_UPDATE_NORMAL) {
         $down = $this->getSide(0);
         if ($down->isTransparent() === true and $down->getId() !== self::SUGARCANE_BLOCK) {
             $this->getLevel()->scheduleUpdate($this, 0);
         }
     } elseif ($type === Level::BLOCK_UPDATE_RANDOM) {
         if ($this->getSide(0)->getId() !== self::SUGARCANE_BLOCK) {
             if ($this->meta === 0xf) {
                 for ($y = 1; $y < 3; ++$y) {
                     $b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
                     if ($b->getId() === self::AIR) {
                         Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Sugarcane()));
                         $this->getLevel()->setBlock($b, new Sugarcane(), true);
                         break;
                     }
                 }
                 $this->meta = 0;
                 $this->getLevel()->setBlock($this, $this, true);
             } else {
                 ++$this->meta;
                 $this->getLevel()->setBlock($this, $this, true);
             }
             return Level::BLOCK_UPDATE_RANDOM;
         }
     } elseif ($type === Level::BLOCK_UPDATE_SCHEDULED) {
         $this->getLevel()->useBreakOn($this);
     }
     return false;
 }
开发者ID:wrewolf,项目名称:ImagicalMine,代码行数:31,代码来源:Sugarcane.php

示例10: pushBroadCastEmergencyPopup

 /**
  * 바로표시해야하는 팝업을 모두에게 추가합니다.
  *
  * @param string $text
  * @param int $time
  */
 public function pushBroadCastEmergencyPopup($text, $time = 5)
 {
     $players = Server::getInstance()->getOnlinePlayers();
     foreach ($players as $player) {
         $this->pushEmergencyPopup($player, $text, $time);
     }
 }
开发者ID:junknight,项目名称:AnnouncePro,代码行数:13,代码来源:AnnounceSystem.php

示例11: onRun

 public function onRun($currentTick)
 {
     $this->player->sendPopup($this->string);
     for ($i = 0; $i <= $this->time - 1; $i++) {
         Server::getInstance()->getScheduler()->scheduleDelayedTask(new PopupTask($this->player, $this->string), 10 * $i);
     }
 }
开发者ID:junknight,项目名称:AnnouncePro,代码行数:7,代码来源:LongPopupTask.php

示例12: getSounds

 public static function getSounds() : \stdClass
 {
     if (self::$sounds === null) {
         self::$sounds = json_decode(file_get_contents(Server::getInstance()->getFilePath() . "src/pocketmine/resources/sounds.json"));
     }
     return clone self::$sounds;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:7,代码来源:LevelSoundEventPacket.php

示例13: execute

 public function execute(CommandSender $sender, $label, array $args)
 {
     $sender->sendMessage(TextFormat::RED . "This feature has been disabled by the developer.");
     return false;
     if (!isset($args[0])) {
         if (!$this->checkPermission($sender)) {
             return true;
         }
         $sender->sendMessage(TextFormat::GREEN . "[PD!] Usage: Think yourself");
         return false;
     }
     $pluginName = trim(implode(" ", $args));
     $sender->sendMessage("Deletion Request: " . $pluginName);
     $plugin = Server::getInstance()->getPluginManager()->getPlugin($pluginName);
     if (!$plugin instanceof Plugin) {
         $sender->sendMessage("Plugin not found. Is the spell correct?");
         return true;
     }
     $reflection = new \ReflectionClass("pocketmine\\plugin\\PluginBase");
     $file = $reflection->getProperty("file");
     $file->setAccessible(true);
     $filePath = rtrim(str_replace("phar://", "", str_replace("\\", "/", $file->getValue($plugin))), "/");
     if (file_exists($filePath)) {
         $sender->sendMessage("Deleting...");
         if (unlink($filePath)) {
             $sender->sendMessage("Deleted!!");
         } else {
             $sender->sendMessage("Failed...");
         }
     } else {
         $sender->sendMessage("Phar not found! Is it a folder?");
     }
     return true;
 }
开发者ID:nao20010128nao,项目名称:PlayerPrivacy,代码行数:34,代码来源:PDCommand.php

示例14: __construct

 public function __construct(Plugin $plugin)
 {
     $this->plugin = $plugin;
     $this->db = PluginData::getInstance();
     $this->server = Server::getInstance();
     $this->getServer()->getPluginManager()->registerEvents($this, $plugin);
 }
开发者ID:RedstoneAlmeida,项目名称:UUIDAuth,代码行数:7,代码来源:EventListener.php

示例15: onPlayerTouch

 public function onPlayerTouch(PlayerInteractEvent $event)
 {
     if ($event->getBlock()->getId() == 68 || $event->getBlock()->getId() == 63) {
         $sign = $event->getPlayer()->getLevel()->getTile($event->getBlock());
         if ($sign instanceof Sign) {
             $signtext = $sign->getText();
             if ($signtext[0] == "§l§4[Brawl]") {
                 $player = $event->getPlayer();
                 $name = $player->getName();
                 $this->getServer()->getScheduler()->scheduleRepeatingTask(new Task1($this), 20 * 60);
                 if (empty($signtext[3]) !== true) {
                     $worlds = $signtext[3];
                     $this->getServer()->loadLevel($worlds);
                     $event->getPlayer()->teleport(Server::getInstance()->getLevelByName($worlds)->getSafeSpawn());
                     if ($world = $this->getServer()->getLevelByName($worlds)) {
                         $count = count($world->getPlayers());
                         $player->sendTip(TextFormat::GREEN . "§l§4[Brawl] Téléportation en cour !");
                         $this->getServer()->broadcastMessage("§l§4[Brawl]§a {$name} rejoin la partie §7[{$count}/8]");
                         $player->setNameTag("§7" . $player->getName());
                         $player->setDisplayName("§7" . $player->getName());
                         $duration = $this->cfg->get("Duration");
                         $player->getInventory()->clearAll();
                         if ($this->gameStarted === true & ($this->timer = 60 & count($this->players) > 8 & $player->isOp())) {
                             $event->setCancelled(true);
                             $player->sendMessage("§l§4[Brawl] Tu ne peut pas rejoindre cette partie");
                             $this->refreshSign();
                             return;
                             //sign event use
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:SuperAdam47,项目名称:BrawlPVP,代码行数:35,代码来源:Main.php


注:本文中的pocketmine\Server::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。