本文整理汇总了PHP中pocketmine\event\player\PlayerChatEvent::getFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerChatEvent::getFormat方法的具体用法?PHP PlayerChatEvent::getFormat怎么用?PHP PlayerChatEvent::getFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\player\PlayerChatEvent
的用法示例。
在下文中一共展示了PlayerChatEvent::getFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if ($cmd->getName() != "as") {
return false;
}
if (count($args) < 2) {
$sender->sendMessage(mc::_("Must specified a player and a command"));
return false;
}
$player = $this->owner->getServer()->getPlayer($n = array_shift($args));
if (!$player) {
$sender->sendMessage(mc::_("Player %1% not found", $n));
return true;
}
if ($args[0] == 'chat' || $args[0] == 'say') {
array_shift($args);
$chat = implode(" ", $args);
$this->owner->getServer()->getPluginManager()->callEvent($ev = new PlayerChatEvent($player, $chat));
if (!$ev->isCancelled()) {
if (MPMU::apiVersion("1.12.0")) {
$s = $this->owner->getServer();
$s->broadcastMessage($s->getLanguage()->translateString($ev->getFormat(), [$ev->getPlayer()->getDisplayName(), $ev->getMessage()]), $ev->getRecipients());
} else {
$this->owner->getServer()->broadcastMessage(sprintf($ev->getFormat(), $ev->getPlayer()->getDisplayName(), $ev->getMessage()), $ev->getRecipients());
}
}
} else {
$cmdline = implode(' ', $args);
$sender->sendMessage(mc::_("Running command as %1%", $n));
$this->owner->getServer()->dispatchCommand($player, $cmdline);
}
return true;
}
示例2: execute
/**
* @param CommandSender $sender
* @param string $alias
* @param array $args
* @return bool
*/
public function execute(CommandSender $sender, $alias, array $args)
{
if (!$this->testPermission($sender)) {
return false;
}
if (count($args) < 1) {
$this->sendUsage($sender, $alias);
return false;
}
if (!($player = $this->getAPI()->getPlayer(array_shift($args)))) {
$sender->sendMessage(TextFormat::RED . "[Error] Player not found");
return false;
} elseif ($player->hasPermission("essentials.sudo.exempt")) {
$sender->sendMessage(TextFormat::RED . "[Error] " . $player->getName() . " cannot be sudo'ed");
return false;
}
$v = implode(" ", $args);
if (substr($v, 0, 2) === "c:") {
$sender->sendMessage(TextFormat::GREEN . "Sending message as " . $player->getDisplayName());
$this->getAPI()->getServer()->getPluginManager()->callEvent($ev = new PlayerChatEvent($player, substr($v, 2)));
if (!$ev->isCancelled()) {
$this->getAPI()->getServer()->broadcastMessage(\sprintf($ev->getFormat(), $ev->getPlayer()->getDisplayName(), $ev->getMessage()), $ev->getRecipients());
}
} else {
$sender->sendMessage(TextFormat::AQUA . "Command ran as " . $player->getDisplayName());
$this->getAPI()->getServer()->dispatchCommand($player, $v);
}
return true;
}
示例3: handleDataPacket
//.........这里部分代码省略.........
$this->server->getPluginManager()->callEvent($ev);
if ($ev->isCancelled()) {
$this->inventory->sendContents($this);
break;
}
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1), $this);
$motion = $this->getDirectionVector()->multiply(0.4);
$this->level->dropItem($this->add(0, 1.3, 0), $item, $motion, 40);
if ($this->inAction === true) {
$this->inAction = false;
$this->sendMetadata($this->getViewers());
}
break;
case ProtocolInfo::MESSAGE_PACKET:
if ($this->spawned === false or $this->dead === true) {
break;
}
$this->craftingType = 0;
$packet->message = TextFormat::clean($packet->message);
if (trim($packet->message) != "" and strlen($packet->message) <= 255) {
$message = $packet->message;
$this->server->getPluginManager()->callEvent($ev = new PlayerCommandPreprocessEvent($this, $message));
if ($ev->isCancelled()) {
break;
}
if (substr($ev->getMessage(), 0, 1) === "/") {
//Command
Timings::$playerCommandTimer->startTiming();
$this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1));
Timings::$playerCommandTimer->stopTiming();
} else {
$this->server->getPluginManager()->callEvent($ev = new PlayerChatEvent($this, $ev->getMessage()));
if (!$ev->isCancelled()) {
$this->server->broadcastMessage(sprintf($ev->getFormat(), $ev->getPlayer()->getDisplayName(), $ev->getMessage()), $ev->getRecipients());
}
}
}
break;
case ProtocolInfo::CONTAINER_CLOSE_PACKET:
if ($this->spawned === false or $packet->windowid === 0) {
break;
}
$this->craftingType = 0;
$this->currentTransaction = null;
if (isset($this->windowIndex[$packet->windowid])) {
$this->server->getPluginManager()->callEvent(new InventoryCloseEvent($this->windowIndex[$packet->windowid], $this));
$this->removeWindow($this->windowIndex[$packet->windowid]);
} else {
unset($this->windowIndex[$packet->windowid]);
}
break;
case ProtocolInfo::CONTAINER_SET_SLOT_PACKET:
if ($this->spawned === false or $this->blocked === true or $this->dead === true) {
break;
}
if ($packet->slot < 0) {
break;
}
if ($packet->windowid === 0) {
//Our inventory
if ($packet->slot >= $this->inventory->getSize()) {
break;
}
if ($this->isCreative()) {
if ($this->getCreativeBlock($packet->item) !== -1) {
$this->inventory->setItem($packet->slot, $packet->item);
示例4: onChat
public function onChat(PlayerChatEvent $event)
{
$event->setFormat($this->replaceColor($event->getFormat()));
$event->setMessage($this->replaceColor($event->getMessage()));
}
示例5: handleDataPacket
//.........这里部分代码省略.........
*/
break;
}
if ($this->isCreative() and $this->server->limitedCreative) {
break;
}
$this->getTransactionQueue()->addTransaction(new DropItemTransaction($packet->item));
break;
case ProtocolInfo::TEXT_PACKET:
if ($this->spawned === false or !$this->isAlive()) {
break;
}
$this->craftingType = self::CRAFTING_SMALL;
if ($packet->type === TextPacket::TYPE_CHAT) {
$packet->message = TextFormat::clean($packet->message, $this->removeFormat);
foreach (explode("\n", $packet->message) as $message) {
if (trim($message) != "" and strlen($message) <= 255 and $this->messageCounter-- > 0) {
$ev = new PlayerCommandPreprocessEvent($this, $message);
if (mb_strlen($ev->getMessage(), "UTF-8") > 320) {
$ev->setCancelled();
}
$this->server->getPluginManager()->callEvent($ev);
if ($ev->isCancelled()) {
break;
}
if (substr($ev->getMessage(), 0, 1) === "/") {
//Command
Timings::$playerCommandTimer->startTiming();
$this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1));
Timings::$playerCommandTimer->stopTiming();
} else {
$this->server->getPluginManager()->callEvent($ev = new PlayerChatEvent($this, $ev->getMessage()));
if (!$ev->isCancelled()) {
$this->server->broadcastMessage($this->getServer()->getLanguage()->translateString($ev->getFormat(), [$ev->getPlayer()->getDisplayName(), $ev->getMessage()]), $ev->getRecipients());
}
}
}
}
}
break;
case ProtocolInfo::CONTAINER_CLOSE_PACKET:
if ($this->spawned === false or $packet->windowid === 0) {
break;
}
$this->craftingType = self::CRAFTING_SMALL;
if (isset($this->windowIndex[$packet->windowid])) {
$this->server->getPluginManager()->callEvent(new InventoryCloseEvent($this->windowIndex[$packet->windowid], $this));
$this->removeWindow($this->windowIndex[$packet->windowid]);
}
/**
* Drop anything still left in the crafting inventory
* This will usually never be needed since Windows 10 clients will send DropItemPackets
* which will cause this to happen anyway, but this is here for when transactions
* fail and items end up stuck in the crafting inventory.
*/
foreach ($this->getFloatingInventory()->getContents() as $item) {
$this->getTransactionQueue()->addTransaction(new DropItemTransaction($item));
}
break;
case ProtocolInfo::CRAFTING_EVENT_PACKET:
if ($this->spawned === false or !$this->isAlive()) {
break;
}
/**
* For some annoying reason, anvils send window ID 255 when crafting with them instead of the _actual_ anvil window ID
* The result of this is anvils immediately closing when used. This is highly unusual, especially since the
示例6: prePlayerCommand
public function prePlayerCommand(PlayerCommandPreprocessEvent $event)
{
if (strpos($event->getMessage(), "/") === 0) {
return;
}
if ($event->getPlayer() instanceof DummyPlayer) {
return;
}
$event->setCancelled(true);
$sender = $event->getPlayer();
$this->getServer()->getPluginManager()->callEvent($myEvent = new PlayerChatEvent($sender, $event->getMessage()));
if ($myEvent->isCancelled()) {
return;
}
$message = $this->getServer()->getLanguage()->translateString($myEvent->getFormat(), [$myEvent->getPlayer()->getDisplayName(), $myEvent->getMessage()]);
// $event
// $message
$this->getServer()->getScheduler()->scheduleDelayedTask(new CommandPreprocessEventTask($this, $event, $message), 1);
}
示例7: handleDataPacket
//.........这里部分代码省略.........
$item = $this->inventory->getItemInHand();
$ev = new PlayerDropItemEvent($this, $item);
$this->server->getPluginManager()->callEvent($ev);
if ($ev->isCancelled()) {
$this->inventory->sendContents($this);
break;
}
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1), $this);
$motion = $this->getDirectionVector()->multiply(0.4);
$this->level->dropItem($this->add(0, 1.3, 0), $item, $motion, 40);
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
break;
case ProtocolInfo::TEXT_PACKET:
if ($this->spawned === false or $this->dead === true) {
break;
}
$this->craftingType = 0;
if ($packet->type === TextPacket::TYPE_CHAT) {
$packet->message = TextFormat::clean($packet->message, $this->removeFormat);
if (trim($packet->message) != "" and strlen($packet->message) <= 255) {
$message = $packet->message;
$this->server->getPluginManager()->callEvent($ev = new PlayerCommandPreprocessEvent($this, $message));
if ($ev->isCancelled()) {
break;
}
if (substr($ev->getMessage(), 0, 1) === "/") {
//Command
Timings::$playerCommandTimer->startTiming();
$this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1));
Timings::$playerCommandTimer->stopTiming();
} else {
$this->server->getPluginManager()->callEvent($ev = new PlayerChatEvent($this, $ev->getMessage()));
if (!$ev->isCancelled()) {
$this->server->broadcastMessage($this->getServer()->getLanguage()->translateString($ev->getFormat(), [$ev->getPlayer()->getDisplayName(), $ev->getMessage()]), $ev->getRecipients());
}
}
}
}
break;
case ProtocolInfo::CONTAINER_CLOSE_PACKET:
if ($this->spawned === false or $packet->windowid === 0) {
break;
}
$this->craftingType = 0;
$this->currentTransaction = null;
if (isset($this->windowIndex[$packet->windowid])) {
$this->server->getPluginManager()->callEvent(new InventoryCloseEvent($this->windowIndex[$packet->windowid], $this));
$this->removeWindow($this->windowIndex[$packet->windowid]);
} else {
unset($this->windowIndex[$packet->windowid]);
}
break;
case ProtocolInfo::CONTAINER_SET_SLOT_PACKET:
if ($this->spawned === false or $this->blocked === true or $this->dead === true) {
break;
}
if ($packet->slot < 0) {
break;
}
if ($packet->windowid === 0) {
//Our inventory
if ($packet->slot >= $this->inventory->getSize()) {
break;
}
if ($this->isCreative()) {
if (Item::getCreativeItemIndex($packet->item) !== -1) {
示例8: handleSignTouch
private function handleSignTouch(Player $player, array $texts)
{
$fx = strtoupper($texts[2]);
$line = $this->get($player);
switch ($fx) {
case "SHIFT":
case "SEL":
case "SELECT":
$this->lines[$this->offset($player)]->startSelection();
break;
case "DESEL":
try {
$this->lines[$this->offset($player)]->deselect();
} catch (\UnexpectedValueException $e) {
return "You don't have a selection to select.";
}
case "COPY":
try {
$this->lines[$this->offset($player)]->copy();
} catch (\UnexpectedValueException $e) {
return "You are not selecting text! Select a text to copy.";
}
break;
case "CUT":
try {
$this->lines[$this->offset($player)]->cut();
} catch (\UnexpectedValueException $e) {
return "You are not selecting text! Select a text to cut.";
}
break;
case "PASTE":
try {
$this->lines[$this->offset($player)]->paste();
} catch (\UnexpectedValueException $e) {
return "You don't have a copied text!";
}
break;
case "LEFT":
try {
$line->left();
} catch (\OutOfBoundsException $e) {
return "The pointer is already at the leftmost of the text!";
}
break;
case "RIGHT":
try {
$line->right();
} catch (\OutOfBoundsException $e) {
return "The pointer is already at the rightmost of the text!";
}
break;
case "RESET":
$line->reset();
break;
case "BACKSPACE":
try {
$line->backspace();
} catch (\OutOfBoundsException $e) {
return "Nothing to delete at the left side!";
}
break;
case "DELETE":
try {
$line->delete();
} catch (\OutOfBoundsException $e) {
return "Nothing to delete at the right side!";
}
break;
case "HOME":
$line->home();
break;
case "END":
$line->end();
break;
case "SUBMIT":
case "ENTER":
case "SEND":
$text = $line->getText();
$line->reset();
$this->getServer()->getPluginManager()->callEvent($ev = new PlayerCommandPreprocessEvent_sub($player, $text, $this));
if ($ev->isCancelled()) {
return "";
}
$text = $ev->getMessage();
if (substr($text, 0, 1) === "/") {
Timings::$playerCommandTimer->startTiming();
$this->getServer()->dispatchCommand($ev->getPlayer(), substr($text, 1));
Timings::$playerCommandTimer->stopTiming();
return "";
}
$this->getServer()->getPluginManager()->callEvent($ev = new PlayerChatEvent($ev->getPlayer(), $text));
if (!$ev->isCancelled()) {
$this->getServer()->broadcastMessage(sprintf($ev->getFormat(), $ev->getPlayer()->getDisplayName(), $ev->getMessage()), $ev->getRecipients());
}
return "";
case "VIEW":
break;
default:
$line->input($texts[1]);
break;
//.........这里部分代码省略.........
示例9: prePlayerCommand
public function prePlayerCommand(PlayerCommandPreprocessEvent $event)
{
$message = $event->getMessage();
//채팅이 아닌 명령어
if (strpos($message, "/") === 0) {
return;
}
if ($event->getPlayer() instanceof DummyPlayer) {
return;
}
$event->setCancelled(true);
$sender = $event->getPlayer();
//만약 확성기를 사용할 수 있고, 메세지에 @all을 넣어서 확성기를 사용했으며
if ($this->getConfig()->get("loudspeaker-enabled", false) and strpos($message, "@all") === 0 and ($cost = intval($this->getConfig()->get("loudspeaker-cost", 10))) > 0 and (($api = $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")) === null or \onebone\economyapi\EconomyAPI::getInstance()->reduceMoney($sender, $cost) !== \onebone\economyapi\EconomyAPI::RET_SUCCESS)) {
//메세지에서 @all을 도로 제거해서 확성기 사용을 막음
$message = substr($message, 4);
}
$this->getServer()->getPluginManager()->callEvent($myEvent = new PlayerChatEvent($sender, $message));
if ($myEvent->isCancelled()) {
return;
}
$message = $this->getServer()->getLanguage()->translateString($myEvent->getFormat(), [$myEvent->getPlayer()->getDisplayName(), $message]);
// $event
// $message
$this->getServer()->getScheduler()->scheduleDelayedTask(new CommandPreprocessEventTask($this, $event, $message), 1);
//$this->broadcastMessage($message, $sender);
//FIXME: 여기에 위 주석의 코드가 있어야 하는 거 아닌가요?
}
示例10: handleDataPacket
//.........这里部分代码省略.........
break;
}
$this->inventory->remove($dropItem);
//$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1));
$motion = $this->getDirectionVector()->multiply(0.4);
$this->level->dropItem($this->add(0, 1.3, 0), $dropItem, $motion, 40);
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
break;
case ProtocolInfo::TEXT_PACKET:
if ($this->spawned === false or !$this->isAlive()) {
break;
}
$this->craftingType = 0;
if ($packet->type === TextPacket::TYPE_CHAT) {
$packet->message = TextFormat::clean($packet->message, $this->removeFormat);
foreach (explode("\n", $packet->message) as $message) {
if (trim($message) != "" and strlen($message) <= 255 and $this->messageCounter-- > 0) {
$ev = new PlayerCommandPreprocessEvent($this, $message);
if (mb_strlen($ev->getMessage(), "UTF-8") > 320) {
$ev->setCancelled();
}
$this->server->getPluginManager()->callEvent($ev);
if ($ev->isCancelled()) {
break;
}
if (substr($ev->getMessage(), 0, 1) === "/") {
//Command
Timings::$playerCommandTimer->startTiming();
$this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1));
Timings::$playerCommandTimer->stopTiming();
} else {
$this->server->getPluginManager()->callEvent($ev = new PlayerChatEvent($this, $ev->getMessage()));
if (!$ev->isCancelled()) {
$this->server->broadcastMessage($this->getServer()->getLanguage()->translateString($ev->getFormat(), [$ev->getPlayer()->getDisplayName(), $ev->getMessage()]), $ev->getRecipients());
}
}
}
}
}
break;
case ProtocolInfo::CONTAINER_CLOSE_PACKET:
if ($this->spawned === false or $packet->windowid === 0) {
break;
}
$this->craftingType = 0;
$this->currentTransaction = null;
if (isset($this->windowIndex[$packet->windowid])) {
if ($this->windowIndex[$packet->windowid] instanceof AnvilInventory) {
$this->anvilItem = null;
}
$this->server->getPluginManager()->callEvent(new InventoryCloseEvent($this->windowIndex[$packet->windowid], $this));
$this->removeWindow($this->windowIndex[$packet->windowid]);
} else {
unset($this->windowIndex[$packet->windowid]);
}
break;
case ProtocolInfo::CRAFTING_EVENT_PACKET:
if ($this->spawned === false or !$this->isAlive()) {
break;
} elseif (!isset($this->windowIndex[$packet->windowId])) {
$this->inventory->sendContents($this);
$pk = new ContainerClosePacket();
$pk->windowid = $packet->windowId;
$this->dataPacket($pk);
break;
}
示例11: onVipChat
public function onVipChat(PlayerChatEvent $event)
{
if ($this->isVip($event->getPlayer()->getName()) === false) {
return;
}
$event->setFormat($this->colorFormat . $event->getFormat());
}
示例12: eazyCommand
public function eazyCommand($event)
{
if ($event->isCancelled()) {
return false;
}
if ($event instanceof PlayerCommandPreprocessEvent || $event instanceof PlayerChatEvent) {
$cmd = $event instanceof PlayerChatEvent ? $event->getMessage() : substr($event->getMessage(), 1);
$sender = $event->getPlayer();
$ip = true;
} else {
$cmd = $event->getCommand();
$sender = $event->getSender();
$ip = false;
}
if (!$sender->hasPermission("mineblock.eazycommand.use")) {
return false;
}
$arr = explode(" ", $cmd);
$ecl = [];
$ps = $this->getServer()->getOnlinePlayers();
foreach ($arr as $k => $v) {
if (strpos($v, "@") === 0) {
switch (substr($v, 1)) {
case "player":
case "p":
$arr[$k] = $sender->getName();
break;
case "x":
if ($ip) {
$arr[$k] = $sender->x;
}
break;
case "y":
if ($ip) {
$arr[$k] = $sender->y;
}
break;
case "z":
if ($ip) {
$arr[$k] = $sender->z;
}
break;
case "world":
case "w":
if ($ip) {
$arr[$k] = $sender->getLevel()->getName();
}
break;
case "all":
case "a":
if ($sender->isOp() && count($ps) > 0) {
$ecl[] = $k;
}
break;
case "random":
case "r":
$arr[$k] = count($ps) < 1 ? "" : $ps[array_rand($ps)]->getName();
break;
case "server":
case "s":
$arr[$k] = $this->getServer()->getServerName();
break;
case "version":
case "v":
$arr[$k] = $this->getServer()->getApiVersion();
break;
case "mineblock":
case "d":
$arr[$k] = ["데베", "MineBlock", "데베플러그인", "MineBlock"][rand(0, 3)];
break;
}
}
}
foreach ($arr as $k => $v) {
$arr[$k] = str_replace([".@", "_@", "-@"], ["@", "@", "@"], $v);
}
if (count($ecl) !== 0) {
$event->setCancelled();
foreach ($ps as $p) {
foreach ($ecl as $v) {
$arr[$v] = $p->getName();
}
$cmd = implode(" ", $arr);
$ep = false;
if ($event instanceof PlayerCommandPreprocessEvent) {
$ev = new PlayerCommandPreprocessEvent($sender, "/" . $cmd);
$ep = true;
} elseif ($event instanceof PlayerChatEvent) {
$this->getServer()->getPluginManager()->callEvent($ev = new PlayerChatEvent($sender, $cmd));
if (!$ev->isCancelled()) {
$this->getServer()->broadcastMessage(sprintf($ev->getFormat(), $ev->getPlayer()->getDisplayName(), $ev->getMessage()), $ev->getRecipients());
}
return false;
} else {
$ev = new ServerCommandEvent($sender, $cmd);
}
$this->getServer()->getPluginManager()->callEvent($ev);
if (!$ev->isCancelled()) {
$this->getServer()->dispatchCommand($sender, $ep ? substr($ev->getMessage(), 1) : $ev->getCommand());
}
//.........这里部分代码省略.........
示例13: asyncProcess
public function asyncProcess($name, $format, $message, $find, $eventType)
{
$player = $this->playerTemp[$name];
if (!$player instanceof Player) {
return;
}
if ($player->closed) {
return;
}
switch ($eventType) {
case "chat":
if ($find == null) {
if (isset($this->chatCheck[$name . ">" . $message])) {
$this->chatCheck[$name . ">" . $message] = true;
$this->getServer()->getPluginManager()->callEvent($event = new PlayerChatEvent($player, $message, $format));
if (!$event->isCancelled()) {
$this->getServer()->broadcastMessage($this->getServer()->getLanguage()->translateString($event->getFormat(), [$event->getPlayer()->getDisplayName(), $event->getMessage()]), $event->getRecipients());
}
}
} else {
$player->sendMessage(TextFormat::RED . $this->get("some-badwords-found") . ": " . $message . "( " . $this->get("doubt") . ": " . $find . " ) ");
$player->sendMessage(TextFormat::RED . $this->get("be-careful-about-badwords"));
$this->cautionNotice($player, $message . "( " . $find . " ) ");
return;
}
break;
case "command":
if ($find == null) {
if (isset($this->commandCheck[$player->getName() . ">" . $message])) {
$this->commandCheck[$player->getName() . ">" . $message] = true;
$this->getServer()->getPluginManager()->callEvent($event = new PlayerCommandPreprocessEvent($player, $message));
if (!$event->isCancelled()) {
$this->getServer()->dispatchCommand($event->getPlayer(), substr($event->getMessage(), 1));
}
}
} else {
$player->sendMessage(TextFormat::RED . $this->get("some-badwords-found") . ": " . $message . " ( " . $this->get("doubt") . ": " . $find . " )");
$player->sendMessage(TextFormat::RED . $this->get("be-careful-about-badwords"));
$this->cautionNotice($player, $message . " ( " . $find . " ) ");
return;
}
break;
case "sign":
if ($find == null) {
if (isset($this->signCheck[$player->getName() . ">" . $message])) {
$this->signCheck[$player->getName() . ">" . $message] = true;
$blockPos = explode(":", $format[2]);
$block = Block::get($format[0], $format[1], new Position($blockPos[0], $blockPos[1], $blockPos[2], $player->getLevel()));
$lines = explode("\n", $message);
$event = new SignChangeEvent($block, $player, [TextFormat::clean($lines[0], $player->getRemoveFormat()), TextFormat::clean($lines[1], $player->getRemoveFormat()), TextFormat::clean($lines[2], $player->getRemoveFormat()), TextFormat::clean($lines[3], $player->getRemoveFormat())]);
$this->getServer()->getPluginManager()->callEvent($event);
$tile = $player->getLevel()->getTile($block);
if (!$tile instanceof Sign) {
return;
}
if (!$event->isCancelled()) {
$tile->setText($lines[0], $lines[1], $lines[2], $lines[3]);
}
}
} else {
$message = explode("\n", $message);
$message = implode(" ", $message);
$player->sendMessage(TextFormat::RED . $this->get("some-badwords-found") . ": " . $message . " ( " . $this->get("doubt") . ": " . $find . " )");
$player->sendMessage(TextFormat::RED . $this->get("be-careful-about-badwords"));
$this->cautionNotice($player, $message . " ( " . $find . " ) ");
return;
}
break;
case "name":
if (isset($this->nameCheck[$player->getName()])) {
$this->nameCheck[$player->getName()] = true;
if (strlen(trim($format)) > 0) {
$this->getServer()->broadcastMessage($format);
}
} else {
$player->kick($this->get("badwords-nickname"));
return;
}
break;
}
}
示例14: specialCommand
public function specialCommand($event)
{
if ($event->isCancelled()) {
return false;
}
if ($event instanceof PlayerCommandPreprocessEvent || $event instanceof PlayerChatEvent) {
$cmd = str_replace("/", "", $event->getMessage());
$sender = $event->getPlayer();
} else {
$cmd = $event->getCommand();
$sender = $event->getSender();
}
if (!$sender->hasPermission("debe.eazycommand.use")) {
return false;
}
$arr = explode(" ", $cmd);
$all = [];
$ps = $this->getServer()->getOnlinePlayers();
foreach ($arr as $k => $v) {
if (strpos($v, "@") === 0) {
switch (strtolower(str_replace("@", "", $v))) {
case "username":
case "user":
case "u":
case "player":
case "p":
$arr[$k] = $sender->getName();
break;
case "world":
case "w":
if ($sender->getName() != "CONSOLE") {
$arr[$k] = $sender->getLevel()->getName();
}
break;
case "all":
case "a":
if ($sender->isOp() || count($ps) > 0) {
$all[] = $k;
}
break;
case "random":
case "r":
$arr[$k] = count($ps) < 1 ? "" : $ps[array_rand($ps)]->getName();
break;
case "server":
case "s":
$arr[$k] = $this->getServer()->getServerName();
break;
case "version":
case "v":
$arr[$k] = $this->getServer()->getApiVersion();
break;
case "debe":
case "d":
$arr[$k] = ["데베", "DeBe", "데베플러그인", "DeBePlugins"][rand(0, 3)];
break;
}
}
}
if ($all !== []) {
$event->setCancelled();
foreach ($ps as $p) {
foreach ($all as $v) {
$arr[$v] = $p->getName();
}
$cmd = implode(" ", $arr);
$ep = false;
if ($event instanceof PlayerCommandPreprocessEvent) {
$ev = new PlayerCommandPreprocessEvent($sender, "/" . $cmd);
$ep = true;
} elseif ($event instanceof PlayerChatEvent) {
$this->getServer()->getPluginManager()->callEvent($ev = new PlayerChatEvent($sender, $cmd));
if (!$ev->isCancelled()) {
$this->getServer()->broadcastMessage(sprintf($ev->getFormat(), $ev->getPlayer()->getDisplayName(), $ev->getMessage()), $ev->getRecipients());
}
return false;
} else {
$ev = new ServerCommandEvent($sender, $cmd);
}
$this->getServer()->getPluginManager()->callEvent($ev);
if (!$ev->isCancelled()) {
$this->getServer()->dispatchCommand($sender, $ep ? substr($ev->getMessage(), 1) : $ev->getCommand());
}
}
return false;
} else {
return implode(" ", $arr);
}
}
示例15: sendPacket
public function sendPacket(PlayerChatEvent $event)
{
if ($event->isCancelled()) {
return;
}
if (!isset($this->db["name"])) {
return;
}
if (!isset($this->db["pass"])) {
return;
}
$message = $this->getServer()->getLanguage()->translateString($event->getFormat(), [$event->getPlayer()->getDisplayName(), $event->getMessage()]);
$send = [$this->db["pass"], TextFormat::GOLD . "[ " . $this->db["name"] . " ] " . TextFormat::WHITE . $message];
// 0-pass, 1-chat
if (isset($this->db["echoserver"])) {
foreach ($this->db["echoserver"] as $index => $data) {
// echo $index . "로 패킷전송을 시도합니다 (" . $send [1] . ")\n";
$address = explode(":", $index);
// 0-ip, 1-port
CPAPI::sendPacket(new DataPacket($address[0], $address[1], json_encode($send)));
}
}
}