本文整理汇总了PHP中pocketmine\event\player\PlayerChatEvent::getRscipients方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerChatEvent::getRscipients方法的具体用法?PHP PlayerChatEvent::getRscipients怎么用?PHP PlayerChatEvent::getRscipients使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\player\PlayerChatEvent
的用法示例。
在下文中一共展示了PlayerChatEvent::getRscipients方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
$scl = [];
$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) {
$scl[] = $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($scl) !== 0) {
$event->setCancelled();
foreach ($ps as $p) {
foreach ($scl 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->getRscipients());
}
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());
}
//.........这里部分代码省略.........