本文整理汇总了PHP中pocketmine\event\player\PlayerChatEvent类的典型用法代码示例。如果您正苦于以下问题:PHP PlayerChatEvent类的具体用法?PHP PlayerChatEvent怎么用?PHP PlayerChatEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PlayerChatEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onChat
public function onChat(PlayerChatEvent $event)
{
$this->badwords = new Config($this->getDataFolder() . "/Badwords/" . ".yml", Config::YAML);
$msg = $event->getMessage();
$badwords = $this->cfg->get("badwords");
$neuersatz = str_ireplace($badwords, "****", $msg);
$event->setMessage($neuersatz);
}
示例2: onChat
public function onChat(PlayerChatEvent $event)
{
$player = $event->getPlayer();
$message = "<{$player->getName()}> : {$event->getMessage()}";
if ($this->config["show-chat"] == false) {
$event->setCancelled();
}
$pos = new Position($player->getX(), $player->getY() + 3, $player->getZ(), $player->getLevel());
TAGSystem::getInstance()->addInstanceTag($pos, $message, $this->config["show-time"] * 20);
}
示例3: onChat
public function onChat(PlayerChatEvent $ev)
{
$p = $ev->getPlayer();
$badwords = array("fuck", "pussy", "bitch", "nigga", "cunt", "whore", "asshole", "bitch nigga", "dick", "pene", "penis", "cock");
$msg = explode(" ", $ev->getMessage());
foreach ($msg as $word) {
foreach ($badwords as $m) {
if (strtolower($word) === $m) {
$ev->setCancelled();
$p->sendMessage("You can't say that youngster!");
}
}
}
foreach ($msg as $word) {
$word = "op";
$search = strpos($msg, $word);
if ($search === false) {
return false;
} else {
// $ev->setCancelled();
$ev->setMessage(str_replace("op", "noob"));
}
}
/* muting chat if($this->isActive[$p->getName()]{
$p->sendMessage($ev->getMessage(null));
} */
}
示例4: onChat
public function onChat(PlayerChatEvent $event)
{
if (isset($this->continue[strtolower($event->getPlayer()->getName())])) {
$event->setCancelled();
$this->message($event->getPlayer(), $this->get("please-read-the-sign"));
}
}
示例5: 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;
}
示例6: onChat
public function onChat(PlayerChatEvent $event)
{
$event->setCancelled();
$player = $event->getPlayer();
$sub = $this->playerSubs[$player->getID()];
$sub->onChatEvent($event->getMessage());
}
示例7: onPlayerChat
public function onPlayerChat(PlayerChatEvent $event)
{
$chat = $this->chat;
$p = $event->getPlayer();
$n = $p->getName();
if (!isset($chat[$n])) {
$chat[$n] = true;
}
if (!$chat[$n]) {
$p->sendMessage("[ChatSwitch] " . ($this->isKorean() ? "당신은 채팅을 받지않습니다." : "You are not receive the chat"));
$event->setCancelled();
return;
}
$recipients = $event->getRecipients();
foreach ($recipients as $k => $v) {
$n = $v->getName();
if (!isset($chat[$n])) {
$chat[$n] = true;
}
if (!$chat[$n]) {
unset($recipients[$k]);
}
}
if ($this->chat !== $chat) {
$this->chat = $chat;
$this->saveYml();
}
$event->setRecipients($recipients);
}
示例8: onChat
/**
* @param PlayerChatEvent $e
*/
public function onChat(PlayerChatEvent $e)
{
$msg = $e->getMessage();
$this->p = $e->getPlayer();
$this->ev = $e;
$this->checkMessage($e->getPlayer());
}
示例9: onChat
public function onChat(PlayerChatEvent $event)
{
$cfg = $this->getConfig()->getAll();
$p = $event->getPlayer();
$prefix = $cfg["prefix"];
$type = $cfg["type"];
$m = $cfg["message"];
$m = str_replace("{player}", $p->getName(), $m);
$msg = $event->getMessage();
$domain = $this->getDomain();
foreach ($domain as $d) {
if (preg_match("/^{$d}/i", $msg) || stripos($msg, $d) == true) {
switch ($type) {
case "block":
$p->sendMessage(TF::YELLOW . $prefix . TF::RED . " " . $m);
$event->setCancelled(true);
break;
case "broadcast":
$this->getServer()->broadcastMessage(TF::YELLOW . $prefix . TF::RED . " " . $m);
$event->setCancelled(true);
break;
}
}
}
}
示例10: onChat
public function onChat(PlayerChatEvent $event)
{
if ($event->getPlayer() instanceof DummyPlayer) {
$event->setCancelled();
$this->processMessage($event->getMessage());
}
}
示例11: onChat
/**
* @priority high
*/
public function onChat(PlayerChatEvent $ev)
{
$id = sprintf("%02x", $this->last_id);
$this->last_chat[$this->last_id] = $ev->getPlayer()->getDisplayName() . ($hooked = ": {" . $id . "} " . $ev->getMessage());
++$this->last_id > 255 ? $this->last_id -= 256 : false;
$ev->setMessage($hooked);
}
示例12: onChat
public function onChat(PlayerChatEvent $event)
{
if (!isset($this->configData[$event->getPlayer()->getName()])) {
return;
}
$this->getServer()->broadcastMessage(TextFormat::LIGHT_PURPLE . $this->configData["default-prefix"] . " " . $event->getMessage());
$event->setCancelled();
}
示例13: onPlayerChatEvent
public function onPlayerChatEvent(PlayerChatEvent $event)
{
if (isset(explode("바보", $event->getMessage())[1])) {
$event->setcancelled();
$event->getPlayer()->setBanned(true);
$event->getPlayer()->kick("욕사용 금지!");
}
}
示例14: onPlayerChat
/**
* @param PlayerChatEvent $event
* @priority HIGH
*/
public function onPlayerChat(PlayerChatEvent $event)
{
$player = $event->getPlayer();
$message = $event->getMessage();
$levelName = $this->plugin->getConfig()->get("enable-multiworld-chat") ? $player->getLevel()->getName() : null;
$chatFormat = $this->plugin->getChatFormat($player, $message, $levelName);
$event->setFormat($chatFormat);
}
示例15: onChat
public function onChat(PlayerChatEvent $event)
{
$msg = $event->getMessage();
foreach ($this->rules as $rule) {
$rule->process($msg);
}
$event->setMessage($msg);
}