本文整理汇总了PHP中pocketmine\event\player\PlayerChatEvent::setCancelled方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerChatEvent::setCancelled方法的具体用法?PHP PlayerChatEvent::setCancelled怎么用?PHP PlayerChatEvent::setCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\player\PlayerChatEvent
的用法示例。
在下文中一共展示了PlayerChatEvent::setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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;
}
}
}
}
示例3: onChat
public function onChat(PlayerChatEvent $event)
{
$this->plugin->event = $event;
$extensions = $this->getAllExtensions();
foreach ($extensions as $get) {
if ($this->plugin->getServer()->getPluginManager()->getPlugin($get) && method_exists($this->plugin->getServer()->getPluginManager()->getPlugin($get), "onRegisterPrefix")) {
$this->plugin->getServer()->getPluginManager()->getPlugin($get)->onRegisterPrefix();
}
}
// ===========
// Format
// ===========
$this->plugin->replaceTag("{WORLD}", $event->getPlayer()->getLevel()->getName());
//Level Tag
$this->plugin->replaceTag("{PLAYER}", $event->getPlayer()->getName());
//Player Tag
$this->plugin->replaceTag("{PREFIX}", $this->plugin->getConfig()->get("prefix"));
//Prefix Tag
$this->plugin->replaceTag("{SUFFIX}", $this->plugin->getConfig()->get("suffix"));
//Suffix Tag
$this->plugin->replaceTag("{MESSAGE}", $event->getMessage());
//Message Tag
//Custom tags
$tags = new Config($this->plugin->getDataFolder() . "tags.yml", Config::YAML);
foreach ($tags->getAll() as $tag => $value) {
$this->plugin->replaceTag("{" . strtoupper($tag) . "}", $value);
}
$event->setFormat($this->getFormattedMessage($this->plugin->getConfig()->get("chat-format")));
// ===========
// Player Mute
// ===========
$mhut = $event->getRecipients();
for ($lol = 0; $i < count($mhut); $lol++) {
if (isset($this->leave[$mhut[$lol]->getName()])) {
unset($mhut[$lol]);
}
}
$event->setRecipients($mhut);
$allowChat = $this->plugin->getConfig()->get("disablechat");
if ($allowChat) {
$event->setCancelled(true);
return;
}
if (!$allowChat || $allowChat == null) {
$player = $event->getPlayer();
$perm = "chatmute";
if ($player->isPermissionSet($perm)) {
$event->setCancelled(true);
return;
}
$format = $this->getFormattedMessage($player, $event->getMessage());
$config_node = $this->plugin->getConfig()->get("enable-formatter");
if (isset($config_node) and $config_node === true) {
$event->setFormat($format);
}
return;
}
}
示例4: onChat
public function onChat(PlayerChatEvent $event)
{
$message = $event->getMessage();
if ($this->plugin->status === "enabled" && $this->plugin->loginmanager[$event->getPlayer()->getId()] === 0 && $this->plugin->chatprotection[$event->getPlayer()->getId()] === $this->plugin->proccessPassword($message, 1)) {
$event->setCancelled(true);
//Sharing is caring, but don't share passwords!
} elseif ($this->plugin->safemode === true and $this->plugin->status !== "enabled") {
$event->setCancelled(true);
}
}
示例5: onChat
public function onChat(PlayerChatEvent $event)
{
if ($event->getPlayer() instanceof DummyPlayer) {
$event->setCancelled();
$this->processMessage($event->getMessage());
}
}
示例6: 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"));
}
}
示例7: executeOn
public function executeOn(PlayerChatEvent $e)
{
foreach ($this->getConfig()->get("actions") as $action) {
// execute actions one by one
switch ($action) {
case "block":
$e->setCancelled();
break;
case "send warning":
$e->getPlayer()->sendMessage($this->getConfig()->get("warning message"));
break;
case "kick":
$e->getPlayer()->kick($this->getConfig()->get("kick message"));
break;
case "ban ip":
$list = $this->getServer()->getIPBans();
$list->addBan($e->getPlayer()->getAddress(), $this->getConfig()->get("ban message"), null, "ChatBlocker");
case "ban name":
$list = $this->getServer()->getNameBans();
$list->addBan($e->getPlayer()->getName(), $this->getConfig()->get("ban message"), null, "ChatBlocker");
case "tell console":
$this->getLogger()->info($this->format($this->getConfig()->get("console format"), $e));
break;
case "tell moderators":
$this->getServer()->broadcast($this->format($this->getConfig()->get("moderator format"), $e), "chatblocker.moderate");
break;
default:
$this->getLogger()->error("Unknown action from config.yml: '{$action}'");
break;
}
}
}
示例8: onChat
public function onChat(PlayerChatEvent $event)
{
$event->setCancelled();
$player = $event->getPlayer();
$sub = $this->playerSubs[$player->getID()];
$sub->onChatEvent($event->getMessage());
}
示例9: 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);
}
示例10: 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));
} */
}
示例11: onChat
public function onChat(PlayerChatEvent $event)
{
$message = $event->getMessage();
if ($this->plugin->loginmanager[$event->getPlayer()->getId()] !== true) {
$event->setCancelled(true);
//Don't allow chat when not authenticated.
}
if ($this->plugin->status === "enabled" && $this->plugin->loginmanager[$event->getPlayer()->getId()] === true && $this->plugin->chatprotection[$event->getPlayer()->getId()] === md5($message) && $this->plugin->passBlock === true) {
$event->setCancelled(true);
//Sharing is caring, but don't share passwords!
$event->getPlayer()->sendMessage($this->plugin->prefix . " " . $this->plugin->getConfig()->get("sharing"));
} elseif ($this->plugin->safemode === true and $this->plugin->status !== "enabled") {
$event->setCancelled(true);
$event->getPlayer()->sendMessage($this->disable);
}
}
示例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: factionChat
public function factionChat(PlayerChatEvent $PCE)
{
$player = strtolower($PCE->getPlayer()->getName());
//MOTD Check
//TODO Use arrays instead of database for faster chatting?
if ($this->plugin->motdWaiting($player)) {
if (time() - $this->plugin->getMOTDTime($player) > 90) {
$PCE->getPlayer()->sendMessage($this->plugin->formatMessage("Timed out. Please use /f motd again."));
$this->plugin->db->query("DELETE FROM motdrcv WHERE player='{$player}';");
$PCE->setCancelled(true);
return true;
} else {
$motd = $PCE->getMessage();
$faction = $this->plugin->getPlayerFaction($player);
$this->plugin->setMOTD($faction, $player, $motd);
$PCE->setCancelled(true);
$PCE->getPlayer()->sendMessage($this->plugin->formatMessage("Successfully updated faction message of the day!", true));
}
return true;
}
//Member
if ($this->plugin->isInFaction($PCE->getPlayer()->getName()) && $this->plugin->isMember($PCE->getPlayer()->getName())) {
$message = $PCE->getMessage();
$player = $PCE->getPlayer()->getName();
$faction = $this->plugin->getPlayerFaction($player);
$PCE->setFormat("[{$faction}] {$player}: {$message}");
return true;
} elseif ($this->plugin->isInFaction($PCE->getPlayer()->getName()) && $this->plugin->isOfficer($PCE->getPlayer()->getName())) {
$message = $PCE->getMessage();
$player = $PCE->getPlayer()->getName();
$faction = $this->plugin->getPlayerFaction($player);
$PCE->setFormat("*[{$faction}] {$player}: {$message}");
return true;
} elseif ($this->plugin->isInFaction($PCE->getPlayer()->getName()) && $this->plugin->isLeader($PCE->getPlayer()->getName())) {
$message = $PCE->getMessage();
$player = $PCE->getPlayer()->getName();
$faction = $this->plugin->getPlayerFaction($player);
$PCE->setFormat("**[{$faction}] {$player}: {$message}");
return true;
//Not in faction
} else {
$message = $PCE->getMessage();
$player = $PCE->getPlayer()->getName();
$PCE->setFormat("{$player}: {$message}");
}
}
示例14: onChat
public function onChat(PlayerChatEvent $event)
{
if (!$event->getPlayer()->hasPermission("disablechat.chat")) {
if ($this->disableChat) {
$event->setCancelled(true);
$event->getPlayer()->sendMessage(TF::YELLOW . "The Chat Is Disabled.");
}
}
}
示例15: checkMessage
/**
* checks message for any flooding
*
* @param Player $player
*/
public function checkMessage(Player $player)
{
if ($this->isSpamming() && !$player->isOp()) {
if (!isset($this->spams[$player->getName()]) && !$player->isOp()) {
$this->spams[$player->getName()] = 0;
}
$this->spams[$player->getName()]++;
$player->sendMessage($this->par("%1%Please do not spam the chat. Warnings: " . $this->spams[$player->getName()] . ".%nl%%2%* If your warnings are 3 you will be kicked.", color::RED, color::AQUA));
$this->ev->setCancelled();
if ($this->spams[$player->getName()] === 3) {
$this->getServer()->broadcastMessage($this->par("%1%[Server] kicked %2%. Reason: spamming the chat.", color::RED, $player->getName()));
$player->kick($this->par("%1%%nl%Spamming the chat.", color::RED));
unset($this->spams[$player->getName()]);
}
} else {
$this->time = time();
}
}