本文整理汇总了PHP中pocketmine\event\player\PlayerChatEvent::setMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerChatEvent::setMessage方法的具体用法?PHP PlayerChatEvent::setMessage怎么用?PHP PlayerChatEvent::setMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\player\PlayerChatEvent
的用法示例。
在下文中一共展示了PlayerChatEvent::setMessage方法的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
/**
* @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);
}
示例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)
{
$msg = $event->getMessage();
foreach ($this->rules as $rule) {
$rule->process($msg);
}
$event->setMessage($msg);
}
示例5: onChat
public function onChat(PlayerChatEvent $event)
{
$message = $event->getMessage();
$flitered_message = str_ireplace($this->fliter, "***", $message);
if ($flitered_message !== $message) {
$event->setMessage($flitered_message);
}
}
示例6: onChat
/**
* @param PlayerChatEvent $event
*/
public function onChat(PlayerChatEvent $event)
{
$msg = $event->getMessage();
foreach ($this->plugin->getLastCharacter() as $c) {
if ($msg[0] !== '/') {
$msg[0] = strtoupper($msg[0]);
if (strpos($msg, $c) == true && $msg[strpos($msg, $c) + 1] == ' ') {
$msg[strpos($msg, $c) + 2] = strtoupper($msg[strpos($msg, $c) + 2]);
}
$event->setMessage($msg);
}
}
}
示例7: onChat
public function onChat(PlayerChatEvent $event)
{
$hp = $event->getPlayer()->getHealth() - 0;
$color = TextFormat::GREEN;
if ($hp < 0) {
$hp = 0;
}
if ($hp <= 5) {
$color = TextFormat::RED;
} else {
if ($hp <= 10) {
$color = TextFormat::YELLOW;
}
}
$event->setMessage($color . "HP: " . $hp . TextFormat::WHITE . ">" . $event->getMessage());
}
示例8: onTalk
public function onTalk(PlayerChatEvent $ev)
{
if ($ev->getPlayer()->hasPermission("simplenospam.bypass")) {
$ev->setCancelled(false);
return true;
}
if (in_array($ev->getPlayer()->getName(), $this->talked)) {
$config = $this->config->getAll();
$ev->setCancelled();
$ev->getPlayer()->sendMessage("[AntiSpam] Not allowed to talk again for " . $config['interval'] . " seconds");
} else {
if (!in_array($ev->getPlayer()->getName(), $this->talked)) {
$bw = $this->config->getAll();
$msg = explode(" ", $ev->getMessage());
foreach ($msg as $word) {
foreach ($bw['Blocked words'] as $blw) {
if ($blw === strtolower($word)) {
if ($bw['replace words'] === "true") {
$ev->setMessage($bw['Replacement Message']);
$ev->getPlayer()->sendMessage("[AnitSpam] You are not allowed to say the word " . $blw);
return true;
} else {
$ev->setCancelled();
$ev->getPlayer()->sendMessage("[AnitSpam] You are not allowed to say the word " . $blw);
return true;
}
}
}
}
array_push($this->talked, $ev->getPlayer()->getName());
$task = new allowtalk($this, $ev->getPlayer());
$this->getServer()->getScheduler()->scheduleDelayedTask($task, 20 * $bw['interval']);
return;
}
}
}
示例9: onPlayerChat
/**
* @param PlayerChatEvent $event
*/
public function onPlayerChat(PlayerChatEvent $event)
{
if (!$this->getPlugin()->getConfig()->getNested("color.colorChat") !== true and !$event->getPlayer()->hasPermission("easymessages.action.color")) {
$event->setMessage($this->getPlugin()->replaceSymbols($event->getMessage(), true));
}
}
示例10: onChat
public function onChat(PlayerChatEvent $e)
{
if ($this->getClan($e->getPlayer()->getName()) != null) {
$e->setMessage(TextFormat::GOLD . "[ " . $this->getClan($e->getPlayer()->getName()) . " ] " . TextFormat::WHITE . $e->getMessage());
}
}
示例11: onPlayerChat
public function onPlayerChat(PlayerChatEvent $event)
{
$player = $event->getPlayer();
$cfg = $this->plugin->getConfig()->getAll();
$prefix = "";
if ($cfg["show-prefix"]) {
$prefix = Main::PREFIX;
}
if (!ServerAuth::getAPI()->isPlayerRegistered($player->getName())) {
if ($player->hasPermission("chatlogin.register")) {
//Check if confirmation is required
if ($cfg["password-confirm-required"]) {
if (!isset($this->plugin->confirm_users[strtolower($player->getName())])) {
$this->plugin->confirm_users[strtolower($player->getName())] = $event->getMessage();
$player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["register-confirm-message"]));
} else {
//Check passwords
if ($this->plugin->confirm_users[strtolower($player->getName())] == $event->getMessage()) {
unset($this->plugin->confirm_users[strtolower($player->getName())]);
$status = ServerAuth::getAPI()->registerPlayer($player, $event->getMessage());
if ($status == ServerAuth::SUCCESS) {
ServerAuth::getAPI()->authenticatePlayer($player, $event->getMessage());
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["register"]["register-success"]));
} elseif ($status == ServerAuth::ERR_USER_ALREADY_REGISTERED) {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["register"]["already-registered"]));
} elseif ($status == ServerAuth::ERR_PASSWORD_TOO_SHORT) {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["password-too-short"]));
$player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["register-message"]));
} elseif ($status == ServerAuth::ERR_PASSWORD_TOO_LONG) {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["password-too-long"]));
$player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["register-message"]));
} elseif ($status == ServerAuth::ERR_MAX_IP_REACHED) {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["max-ip-reached"]));
} elseif ($status == ServerAuth::CANCELLED) {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->getCancelledMessage()));
} else {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["generic"]));
$player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["register-message"]));
}
} else {
unset($this->plugin->confirm_users[strtolower($player->getName())]);
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["password-no-match"]));
$player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["register-message"]));
}
}
} else {
$status = ServerAuth::getAPI()->registerPlayer($player, $event->getMessage());
if ($status == ServerAuth::SUCCESS) {
ServerAuth::getAPI()->authenticatePlayer($player, $event->getMessage());
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["register"]["register-success"]));
} elseif ($status == ServerAuth::ERR_USER_ALREADY_REGISTERED) {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["register"]["already-registered"]));
} elseif ($status == ServerAuth::ERR_PASSWORD_TOO_SHORT) {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["password-too-short"]));
$player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["register-message"]));
} elseif ($status == ServerAuth::ERR_PASSWORD_TOO_LONG) {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["password-too-long"]));
$player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["register-message"]));
} elseif ($status == ServerAuth::ERR_MAX_IP_REACHED) {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["max-ip-reached"]));
} elseif ($status == ServerAuth::CANCELLED) {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->getCancelledMessage()));
} else {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["generic"]));
$player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["register-message"]));
}
}
} else {
$player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg['no-register-permissions']));
}
$event->setMessage("");
$event->setCancelled(true);
} elseif (!ServerAuth::getAPI()->isPlayerAuthenticated($player)) {
if ($player->hasPermission("chatlogin.login")) {
$status = ServerAuth::getAPI()->authenticatePlayer($player, $event->getMessage());
if ($status == ServerAuth::SUCCESS) {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["login"]["login-success"]));
} elseif ($status == ServerAuth::ERR_WRONG_PASSWORD) {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["wrong-password"]));
$player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["login-message"]));
} elseif ($status == ServerAuth::ERR_USER_ALREADY_AUTHENTICATED) {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["login"]["already-login"]));
} elseif ($status == ServerAuth::ERR_USER_NOT_REGISTERED) {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["user-not-registered"]));
} elseif ($status == ServerAuth::CANCELLED) {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->getCancelledMessage()));
} else {
$player->sendMessage($this->plugin->translateColors("&", $prefix . ServerAuth::getAPI()->chlang["errors"]["generic"]));
$player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg["login-message"]));
}
} else {
$player->sendMessage($this->plugin->translateColors("&", $prefix . $cfg['no-login-permissions']));
}
$event->setMessage("");
$event->setCancelled(true);
}
}
示例12: onChat
public function onChat(PlayerChatEvent $event)
{
$event->setFormat($this->replaceColor($event->getFormat()));
$event->setMessage($this->replaceColor($event->getMessage()));
}
示例13: onChat
/**
* @param PlayerChatEvent $e
*
* @priority LOW
*/
public function onChat(PlayerChatEvent $e)
{
$p = $e->getPlayer();
if ($this->inArena($p)) {
$e->setMessage(str_replace(["%PLAYER", "%MESSAGE"], [$p->getDisplayName(), $e->getMessage()], SurvivalGames::$cfg["chat_format"]));
$e->setRecipients($this->getPlayers());
} else {
$e->setRecipients(array_diff($this->getPlayers(), $e->getRecipients()));
}
}
示例14: onChatEvent
public function onChatEvent(PlayerChatEvent $event)
{
$message = $event->getMessage();
$event->setMessage($this->config["identify-capital-alphabet"] ? str_replace($this->config["messages"], $this->mosaicList, $message) : str_ireplace($this->config["messages"], $this->mosaicList, $message));
}
示例15: onPlayerChat
public function onPlayerChat(PlayerChatEvent $event)
{
$Player = $event->getPlayer();
$Level = $Player->getLevel();
$Message = $event->getMessage();
if (!$this->plugin->game || $this->plugin->game->level_name != $Level->getFolderName()) {
return;
}
if ($Team = $this->plugin->game->getTeamByPlayer($Player)) {
$event->setFormat("BedWars: <" . $this->plugin->teamColor($Team->name) . "%s" . TextFormat::RESET . ">: %s");
$prefix = mb_strtolower($this->plugin->getMessage("bedwars.sayall.prefix"));
if (mb_substr(mb_strtolower($Message), 0, mb_strlen($prefix)) == $prefix) {
$event->setMessage(mb_substr($Message, mb_strlen($prefix)));
return;
}
$Players = $Level->getPlayers();
foreach ($this->plugin->game->Teams as $Team2) {
if ($Team->name != $Team2->name) {
foreach ($Team2->Players as $Player2) {
foreach ($Players as $i => $Player3) {
if ($Player2->getName() == $Player3->getName()) {
array_splice($Players, $i, 1);
}
}
}
}
}
$event->setRecipients($Players);
}
}