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


PHP utils\TextFormat类代码示例

本文整理汇总了PHP中pocketmine\utils\TextFormat的典型用法代码示例。如果您正苦于以下问题:PHP TextFormat类的具体用法?PHP TextFormat怎么用?PHP TextFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: spawnTo

 public function spawnTo(Player $player)
 {
     if ($player instanceof DesktopPlayer) {
         if ($this !== $player and $this->spawned === true and $player->getLevel() === $this->getLevel() and $player->canSee($this)) {
             $this->hasSpawned[$player->getID()] = $player;
             $pk = new SpawnPlayerPacket();
             if ($player->getRemoveFormat()) {
                 $pk->name = TextFormat::clean($this->nameTag);
             } else {
                 $pk->name = $this->nameTag;
             }
             $pk->eid = $this->getID();
             $pk->uuid = $this->bigBrother_formatedUUID;
             $pk->x = $this->x;
             $pk->z = $this->y;
             $pk->y = $this->z;
             $pk->yaw = $this->yaw;
             $pk->pitch = $this->pitch;
             $pk->item = $this->inventory->getItemInHand()->getID();
             $pk->metadata = $this->getData();
             $pk->data = $this->bigBrother_properties;
             $player->putRawPacket($pk);
             $pk = new EntityTeleportPacket();
             $pk->eid = $this->getID();
             $pk->x = $this->x;
             $pk->z = $this->y;
             $pk->y = $this->z;
             $pk->yaw = $this->yaw;
             $pk->pitch = $this->pitch;
             $player->putRawPacket($pk);
             $pk = new SetEntityMotionPacket();
             $pk->eid = $this->getID();
             $pk->speedX = $this->motionX;
             $pk->speedY = $this->motionY;
             $pk->speedZ = $this->motionZ;
             $player->dataPacket($pk);
             $this->inventory->sendHeldItem($player);
             $this->inventory->sendArmorContents($player);
         }
     } else {
         parent::spawnTo($player);
     }
 }
开发者ID:vibrocil,项目名称:BigBrother,代码行数:43,代码来源:DesktopPlayer.php

示例2: onTelegramMessage

 public function onTelegramMessage(TelegramMessageEvent $event)
 {
     if (!PocketTelegram::$broadcastTelegramMessages) {
         return;
     }
     $message = $event->getMessage();
     switch (true) {
         case $message instanceof TextMessage:
             if (PocketTelegram::$enableTelegramCommands and $message->isCommand()) {
                 $this->handleTelegramCommands($message);
                 return;
             }
             $text = $message->getText();
             break;
         case $message instanceof PhotoMessage:
             $text = "(Photo)";
             break;
         default:
             return;
     }
     if ($message->getChat()->getId() !== PocketTelegram::getDefaultChannel()) {
         return;
     }
     if (is_null($from = $message->getFrom()) or is_null($username = $from->getUsername())) {
         return;
     }
     $this->broadcastMessage(PocketTelegram::getInstance()->getConfig()->get("telegramUserPrefix", "@") . $username, TextFormat::clean($text));
 }
开发者ID:ChalkPE,项目名称:PocketTelegram,代码行数:28,代码来源:EventHandler.php

示例3: onSignChange

 public function onSignChange(SignChangeEvent $event)
 {
     if (strtolower(TextFormat::clean($event->getLine(0))) === "[advancedkits]" and !$event->getPlayer()->hasPermission("advancedkits.admin")) {
         $event->getPlayer()->sendMessage($this->ak->langManager->getTranslation("no-perm-sign"));
         $event->setCancelled();
     }
 }
开发者ID:Nader6,项目名称:AdvancedKits,代码行数:7,代码来源:EventListener.php

示例4: onPlayerTouch

 public function onPlayerTouch(PlayerInteractEvent $event)
 {
     $player = $event->getPlayer();
     $b = $event->getBlock();
     $name = $event->getPlayer()->getName();
     $name = strtolower($name);
     if ($b->getID() === 63 || $b->getID() === 68) {
         $sign = $player->getLevel()->getTile($b);
         if (!$sign instanceof Sign) {
             return;
         }
         $sign = $sign->getText();
         if (TextFormat::clean($sign[0]) === '[Checkpoint]') {
             $this->data->set($name, array($player->x, $player->y, $player->z, $player->getLevel()->getName()));
             $this->data->save();
             $player->sendMessage($this->getConfig()->get("CheckpointSaved"));
         }
         if (TextFormat::clean($sign[0]) === '[Earn Reward]') {
             $this->data->remove($name, array($player->x, $player->y, $player->z, $player->getLevel()->getName()));
             $this->data->save();
             $player->sendMessage($this->getConfig()->get("EarnReward"));
             if ($this->getConfig()->get("reward-command")) {
                 $player->getServer()->dispatchCommand(new ConsoleCommandSender(), str_ireplace("{PLAYER}", $player->getName(), $this->getConfig()->get("reward-command")));
                 $player->teleport($player->getLevel()->getSafeSpawn());
             }
         }
     }
     if ($b->getID() === $this->getConfig()->get("CheckPointBlock")) {
         $this->data->set($name, array($player->x, $player->y, $player->z, $player->getLevel()->getName()));
         $this->data->save();
         $player->sendMessage($this->getConfig()->get("CheckpointSaved"));
     }
 }
开发者ID:NL-4-DEVS,项目名称:Parkour,代码行数:33,代码来源:Main.php

示例5: check

 public function check()
 {
     for ($n = 0; $n < $this->threads; ++$n) {
         if ($this->workers[$n]->isTerminated() === true) {
             $this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread);
         } elseif ($this->workers[$n]->isWaiting()) {
             if ($this->workers[$n]->response !== "") {
                 $this->server->getLogger()->info($this->workers[$n]->response);
                 $this->workers[$n]->synchronized(function (RCONInstance $thread) {
                     $thread->notify();
                 }, $this->workers[$n]);
             } else {
                 $response = new RemoteConsoleCommandSender();
                 $command = $this->workers[$n]->cmd;
                 $this->server->getPluginManager()->callEvent($ev = new RemoteServerCommandEvent($response, $command));
                 if (!$ev->isCancelled()) {
                     $this->server->dispatchCommand($ev->getSender(), $ev->getCommand());
                 }
                 $this->workers[$n]->response = TextFormat::clean($response->getMessage());
                 $this->workers[$n]->synchronized(function (RCONInstance $thread) {
                     $thread->notify();
                 }, $this->workers[$n]);
             }
         }
     }
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:26,代码来源:RCON.php

示例6: onPostRelease

 public function onPostRelease($rowId)
 {
     if ($this->src === "{BOT}CapsDetector" or $this->src === "{BOT}SwearDetector") {
         return;
     }
     $message = implode("\n", ["{$this->src} @ `{$this->ip}:{$this->port}` executed /console. Message `#{$rowId}``:", MUtils::toMd($this->msg)]);
     $isBot = substr($this->src, 0, 5) === "{BOT}";
     $this->main->getServer()->getScheduler()->scheduleAsyncTask(new PostUrlTask(Credentials::SLACK_WEBHOOK, json_encode(["text" => TextFormat::clean($message), "icon_url" => Credentials::LEGIONPE_ICON_URL, "username" => $isBot ? substr($this->src, 5) : $this->src, "channel" => $isBot ? "#spam" : "#support"])));
 }
开发者ID:legoboy0215,项目名称:LegionPE-Theta-Base,代码行数:9,代码来源:ConsoleReportHormone.php

示例7: replaceSymbols

 /**
  * Replaces all formatted color codes in the specified message, if revert is true, it will remove all text effects
  * @param string $message
  * @param bool $revert
  * @return string
  */
 public static function replaceSymbols($message, $revert = false)
 {
     $defaultFormat = [TextFormat::BLACK, TextFormat::DARK_BLUE, TextFormat::DARK_GREEN, TextFormat::DARK_AQUA, TextFormat::DARK_RED, TextFormat::DARK_PURPLE, TextFormat::GOLD, TextFormat::GRAY, TextFormat::DARK_GRAY, TextFormat::BLUE, TextFormat::GREEN, TextFormat::AQUA, TextFormat::RED, TextFormat::LIGHT_PURPLE, TextFormat::YELLOW, TextFormat::WHITE, TextFormat::OBFUSCATED, TextFormat::BOLD, TextFormat::STRIKETHROUGH, TextFormat::UNDERLINE, TextFormat::ITALIC, TextFormat::RESET];
     $newFormat = ["&0", "&1", "&2", "&3", "&4", "&5", "&6", "&7", "&8", "&9", "&a", "&b", "&c", "&d", "&e", "&f", "&k", "&l", "&m", "&n", "&o", "&r"];
     if ($revert) {
         return TextFormat::clean($message);
     } else {
         return str_replace($newFormat, $defaultFormat, $message);
     }
 }
开发者ID:happyexceed,项目名称:PocketMine-Plugins-1,代码行数:16,代码来源:Utils.php

示例8: onQueryRegen

 public function onQueryRegen(QueryRegenerateEvent $event)
 {
     $event->setWorld($this->main->query_world());
     $this->main->getPlayersCount($total, $max, $classTotal, $classMax);
     $event->setPlayerCount($classTotal);
     $event->setMaxPlayerCount($classMax);
     $event->setPlayerList([]);
     $event->setServerName(TextFormat::clean($this->main->getServer()->getNetwork()->getName()));
     $extra = $event->getExtraData();
     $extra["class_numplayers"] = $classMax;
     $extra["class_maxplayers"] = $classMax;
     $this->addExtras($extra);
     $event->setExtraData($extra);
 }
开发者ID:legoboy0215,项目名称:LegionPE-Theta-Base,代码行数:14,代码来源:BaseListener.php

示例9: onQueryRegen

 public function onQueryRegen(QueryRegenerateEvent $event)
 {
     $event->setWorld($this->main->query_world());
     $this->main->getPlayersCount($total, $max, $classTotal, $classMax);
     $event->setPlayerCount($classTotal);
     $event->setMaxPlayerCount($classMax);
     $event->setPlayerList([]);
     $event->setServerName(TextFormat::clean($this->main->getServer()->getNetwork()->getName()));
     $extra = $event->getExtraData();
     $name = strtolower(Settings::$CLASSES_NAMES[Settings::$LOCALIZE_CLASS]);
     $extra[$name . "_numplayers"] = $classTotal;
     $extra[$name . "_maxplayers"] = $classMax;
     $this->addExtras($extra);
     $event->setExtraData($extra);
 }
开发者ID:Addison118,项目名称:LegionPE-Theta-Base,代码行数:15,代码来源:BaseListener.php

示例10: onRun

 public function onRun($currentTick)
 {
     foreach ($this->plugin->getServer()->getLevels() as $levels) {
         foreach ($levels->getTiles() as $tiles) {
             if ($tiles instanceof Sign) {
                 $text = $tiles->getText();
                 if (TextFormat::clean(strtolower(trim($text[0]))) === strtolower(trim($this->plugin->sign->get("sign_final_change")))) {
                     $world = $text[1];
                     $level = $this->plugin->getServer()->getLevelByName($world);
                     $players = count($level->getPlayers());
                     $tiles->setText($text[0] = TextFormat::GREEN . $this->plugin->sign->get("sign_final_change"), $text[2] = TextFormat::YELLOW . $players . " players");
                 }
             }
         }
     }
 }
开发者ID:EpicArtz08999,项目名称:Development,代码行数:16,代码来源:SignUpdateTask.php

示例11: onPlayerTouch

 public function onPlayerTouch(PlayerInteractEvent $event)
 {
     $player = $event->getPlayer();
     $b = $event->getBlock();
     $name = $event->getPlayer()->getName();
     $name = strtolower($name);
     if ($b->getID() == 63 || $b->getID() == 68) {
         $sign = $player->getLevel()->getTile($b);
         if (!$sign instanceof Sign) {
             return;
         }
         $sign = $sign->getText();
         if (TextFormat::clean($sign[0]) === '[Checkpoint]') {
             $this->config->set($name, array($player->x, $player->y, $player->z, $player->getLevel()->getName()));
             $this->config->save();
             $player->sendMessage("Saved");
         } elseif (TextFormat::clean($sign[0]) === '[To Checkpoint]') {
             $pos = $this->config->get($name);
             if (is_array($pos)) {
                 if (count($pos) === 4) {
                     $player->sendMessage("Teleporting to Checkpoint...");
                     $level = $this->getServer()->getLevelByName($pos[3]);
                     if ($level) {
                         $player->teleport(new Position($pos[0], $pos[1], $pos[2], $level));
                     } else {
                         $player->sendMessage("Level is not loaded");
                     }
                 } else {
                     $player->sendMessage("Save Corrupted");
                 }
             } else {
                 $player->sendMessage("No Save Found");
             }
         }
     }
 }
开发者ID:gitter-badger,项目名称:Parkour,代码行数:36,代码来源:Main.php

示例12: onData

 /**
  * Handle data received from a client
  *
  * @param Payload    $payload A payload object, that supports __toString()
  * @param Connection $connection
  */
 public function onData($payload, $connection)
 {
     $payloado = $payload;
     $payload = trim($payload);
     if (in_array($connection, $this->autharray)) {
         $this->thread->buffer .= $payloado;
         if (stripos($payloado, "json") != -1) {
         } else {
             $connection->send($payload . "\r\n");
         }
     } elseif ($this->tryAuth($payload)) {
         $this->autharray[] = $connection;
         $connection->send(TextFormat::toANSI(TextFormat::DARK_GREEN . "[PocketDockConsole] Authenticated! Now accepting commands\r\n"));
         $this->thread->log(TextFormat::DARK_GREEN . "Successful login from: " . $connection->getIp() . "!");
         $stuffArray = explode("\n", $this->thread->stuffToSend);
         $stuffArray = array_reverse($stuffArray);
         for ($i = $this->thread->backlog; $i >= 0; $i--) {
             if (isset($stuffArray[$i])) {
                 $line = trim($stuffArray[$i]) . "\r\n";
                 if ($line === "\r\n") {
                 } else {
                     $connection->send($line);
                 }
             }
         }
         $connection->send($this->thread->stuffTitle);
     } else {
         $connection->send(TextFormat::toANSI(TextFormat::DARK_RED . "[PocketDockConsole] Failed login attempt, this event will be recorded!\r\n"));
         $this->thread->log(TextFormat::DARK_RED . "Failed login attempt from: " . $connection->getIp() . "!");
     }
 }
开发者ID:brandon15811,项目名称:PocketDockConsole,代码行数:37,代码来源:PDCApp.php

示例13: serverToInterface

 public function serverToInterface(DesktopPlayer $player, DataPacket $packet)
 {
     switch ($packet->pid()) {
         case Info::DISCONNECT_PACKET:
             if ($player->bigBrother_getStatus() === 0) {
                 $pk = new LoginDisconnectPacket();
                 $pk->reason = TextFormat::toJSON($packet->message === "" ? "You have been disconnected." : $packet->message);
             } else {
                 $pk = new PlayDisconnectPacket();
                 $pk->reason = TextFormat::toJSON($packet->message === "" ? "You have been disconnected." : $packet->message);
             }
             return $pk;
         case Info::TEXT_PACKET:
             echo $player->getSetting("Lang") . "\n";
             /*if($packet->message === "chat.type.achievement"){
             		/*$pk = new ScoreboardObjectivePacket();
             		$pk->ObjectiveName = $packet->parameters[0];
             		$pk->Mode = 0;
             		$pk->ObjectiveValue = 3;
             		return $pk;*/
             /*echo "TextPacket: achievement\n";
             			return null;
             		}else{
             			$pk = new STCChatPacket();
             			$pk->message = TextFormat::toJSON($packet->message, $packet->type, $packet->parameters);
             		}*/
             //return $pk;
             return null;
         case Info::SET_TIME_PACKET:
             $pk = new TimeUpdatePacket();
             $pk->age = $packet->time;
             $pk->time = $packet->time;
             //TODO: calculate offset from MCPE
             return $pk;
         case Info::START_GAME_PACKET:
             $packets = [];
             $pk = new JoinGamePacket();
             $pk->eid = $packet->eid;
             $pk->gamemode = $packet->gamemode;
             $pk->dimension = 0;
             $pk->difficulty = $player->getServer()->getDifficulty();
             $pk->maxPlayers = $player->getServer()->getMaxPlayers();
             $pk->levelType = "default";
             $packets[] = $pk;
             $pk = new SpawnPositionPacket();
             $pk->spawnX = $packet->spawnX;
             $pk->spawnY = $packet->spawnY;
             $pk->spawnZ = $packet->spawnZ;
             $packets[] = $pk;
             $pk = new PlayerAbilitiesPacket();
             $pk->flyingSpeed = 0.05;
             $pk->walkingSpeed = 0.1;
             $pk->canFly = ($player->getGamemode() & 0x1) > 0;
             $pk->damageDisabled = ($player->getGamemode() & 0x1) > 0;
             $pk->isFlying = false;
             $pk->isCreative = ($player->getGamemode() & 0x1) > 0;
             $packets[] = $pk;
             $pk = new PositionAndLookPacket();
             $pk->x = $packet->x;
             $pk->y = $packet->y;
             $pk->z = $packet->z;
             $pk->yaw = $player->yaw;
             $pk->pitch = $player->pitch;
             $packets[] = $pk;
             return $packets;
         case Info::ADD_PLAYER_PACKET:
             $packets = [];
             $packetplayer = $player->getServer()->getPlayerExact($packet->username);
             $pk = new PlayerListPacket();
             $pk->actionID = PlayerListPacket::TYPE_ADD;
             $pk->players[] = [$packetplayer->getUniqueId()->toBinary(), $packetplayer->getName(), [], $packetplayer->getGamemode(), 0, false];
             if ($packetplayer instanceof DesktopPlayer) {
                 $pk->players[0][2] = $packetplayer->bigBrother_getPeroperties();
             }
             $packets[] = $pk;
             $pk = new SpawnPlayerPacket();
             $pk->eid = $packet->eid;
             $pk->uuid = $packetplayer->getUniqueId()->toBinary();
             $pk->x = $packet->x;
             $pk->z = $packet->z;
             $pk->y = $packet->y;
             $pk->yaw = $packet->yaw;
             $pk->pitch = $packet->pitch;
             $pk->item = $packetplayer->getInventory()->getItemInHand()->getId();
             $pk->metadata = $packet->metadata;
             $packets[] = $pk;
             $pk = new EntityTeleportPacket();
             $pk->eid = $packet->eid;
             $pk->x = $packet->x;
             $pk->y = $packet->y;
             $pk->z = $packet->z;
             $pk->yaw = $packet->yaw;
             $pk->pitch = $packet->pitch;
             $packets[] = $pk;
             return $packets;
             /*case Info::ADD_ENTITY_PACKET:
             		return null;*/
             /*case Info::REMOVE_PLAYER_PACKET:
             				$pk = new PlayerListPacket();
             				$pk->actionID = PlayerListPacket::TYPE_REMOVE;
//.........这里部分代码省略.........
开发者ID:iPocketTeam,项目名称:BigBrother,代码行数:101,代码来源:Translator_84.php

示例14: getPlayer

 public function getPlayer($player)
 {
     if (!$this->validateName($player, false)) {
         return false;
     }
     $player = strtolower($player);
     $found = false;
     foreach ($this->getServer()->getOnlinePlayers() as $p) {
         if (strtolower(TextFormat::clean($p->getDisplayName(), true)) === $player || strtolower($p->getName()) === $player) {
             $found = $p;
             break;
         }
     }
     // If cannot get the exact player name/nick, try with portions of it
     if (!$found) {
         $found = ($f = $this->getServer()->getPlayer($player)) === null ? false : $f;
         // PocketMine function to get from portions of name
     }
     /*
      * Copy from PocketMine's function (use above xD) but modified to work with Nicknames :P
      *
      * ALL THE RIGHTS FROM THE FOLLOWING CODE BELONGS TO POCKETMINE-MP
      */
     if (!$found) {
         $delta = \PHP_INT_MAX;
         foreach ($this->getServer()->getOnlinePlayers() as $p) {
             // Clean the Display Name due to colored nicks :S
             if (\stripos($n = TextFormat::clean($p->getDisplayName(), true), $player) === 0) {
                 $curDelta = \strlen($n) - \strlen($player);
                 if ($curDelta < $delta) {
                     $found = $p;
                     $delta = $curDelta;
                 }
                 if ($curDelta === 0) {
                     break;
                 }
             }
         }
     }
     return $found;
 }
开发者ID:flaxues,项目名称:BuddyPets,代码行数:41,代码来源:Main.php

示例15: onInteract

 public function onInteract(PlayerInteractEvent $event)
 {
     $player = $event->getPlayer();
     $sign = $event->getPlayer()->getLevel()->getTile($event->getBlock());
     if ($event->getBlock()->getId() == 63 or $event->getBlock()->getId() == 68) {
         if ($sign instanceof Sign) {
             $signtext = $sign->getText();
             if (TextFormat::clean($signtext[0]) === "[DeadEnd]") {
                 $player->teleport(126.3, 5, 128.3, DeadEnd - lobby);
                 $player->sendMessage(TextFormat::GOLD . "You entered DeadEnd!");
             }
         }
     }
 }
开发者ID:Skull3x,项目名称:DontStopRunning,代码行数:14,代码来源:Main.php


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