本文整理汇总了PHP中pocketmine\event\player\PlayerChatEvent::isCancelled方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerChatEvent::isCancelled方法的具体用法?PHP PlayerChatEvent::isCancelled怎么用?PHP PlayerChatEvent::isCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\player\PlayerChatEvent
的用法示例。
在下文中一共展示了PlayerChatEvent::isCancelled方法的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: onChat
public function onChat(PlayerChatEvent $event)
{
$player = $event->getPlayer();
if ($player instanceof Player) {
if (!$event->isCancelled()) {
$user = $player->getName();
$message = $event->getMessage();
$chat = Utils::getURL("URL...");
if ($chat === 1) {
$event->setCancelled(true);
}
//$event->setCancelled();
}
}
}
示例4: onChat
public function onChat(PlayerChatEvent $ev)
{
if ($ev->isCancelled()) {
return;
}
$player = $ev->getPlayer();
if (!$this->cfg["settings"]["chat"]) {
$ev->setCancelled();
$player->sendMessage(TextFormat::RED . "[YouChat] Chat has been disabled!");
return;
}
$n = trim(strtolower($player->getName()));
$prefix = $this->cfg["settings"]["prefix"];
if (isset($this->players[$n])) {
if ($this->players[$n]["prefix"]) {
$prefix = $this->players[$n]["prefix"];
}
if ($this->players[$n]["mute"]) {
$ev->setCancelled();
$player->sendMessage(TextFormat::RED . "[YouChat] You have been muted from chat!");
return;
}
if ($this->players[$n]["pause"]) {
$ev->setCancelled();
$player->sendMessage(TextFormat::RED . "[YouChat] You have paused chat!");
return;
}
}
$recvr = [];
foreach ($ev->getRecipients() as $to) {
$m = strtolower($to->getName());
if (isset($this->players[$m])) {
if ($this->players[$m]["pause"]) {
continue;
}
}
$recvr[] = $to;
}
$ev->setRecipients($recvr);
$vars = ["{YouChat}" => $this->getDescription()->getFullName(), "{player}" => $player->getName(), "{displayname}" => "{%0}", "{nick}" => $player->getDisplayName(), "{world}" => $player->getLevel()->getName(), "{message}" => "{%1}", "{prefix}" => $prefix, "{BLACK}" => TextFormat::BLACK, "{DARK_BLUE}" => TextFormat::DARK_BLUE, "{DARK_GREEN}" => TextFormat::DARK_GREEN, "{DARK_AQUA}" => TextFormat::DARK_AQUA, "{DARK_RED}" => TextFormat::DARK_RED, "{DARK_PURPLE}" => TextFormat::DARK_PURPLE, "{GOLD}" => TextFormat::GOLD, "{GRAY}" => TextFormat::GRAY, "{DARK_GRAY}" => TextFormat::DARK_GRAY, "{BLUE}" => TextFormat::BLUE, "{GREEN}" => TextFormat::GREEN, "{AQUA}" => TextFormat::AQUA, "{RED}" => TextFormat::RED, "{LIGHT_PURPLE}" => TextFormat::LIGHT_PURPLE, "{YELLOW}" => TextFormat::YELLOW, "{WHITE}" => TextFormat::WHITE, "{OBFUSCATED}" => TextFormat::OBFUSCATED, "{BOLD}" => TextFormat::BOLD, "{STRIKETHROUGH}" => TextFormat::STRIKETHROUGH, "{UNDERLINE}" => TextFormat::UNDERLINE, "{ITALIC}" => TextFormat::ITALIC, "{RESET}" => TextFormat::RESET];
if (($kr = $this->getServer()->getPluginManager()->getPlugin("KillRate")) !== null) {
$vars["{kills}"] = $kr->getScore($player, "player");
$vars["{points}"] = $kr->getScore($player, "points");
}
$ev->setFormat(strtr($this->cfg["settings"]["chat-format"], $vars));
}
示例5: onPlayerChat
public function onPlayerChat(PlayerChatEvent $event)
{
if ($event->isCancelled()) {
return;
}
$p = $event->getPlayer();
$m = "[ChatMute] ";
$ik = $this->isKorean();
if ($this->mute["AllMute"] && !$p->hasPermission("mineblock.chatmute.chat")) {
$p->sendMessage($m . ($ik ? "모든 채팅 음소거 상태입니다.." : "All Mute"));
$event->setCancelled();
} else {
$n = $p->getName();
if (isset($this->mute["Mute"][$n])) {
$p->sendMessage($m . ($ik ? "당신은 채팅 음소거 상태입니다." : "ChatMute"));
$event->setCancelled();
}
}
}
示例6: onPlayerChat
public function onPlayerChat(PlayerChatEvent $event)
{
if ($event->isCancelled()) {
return;
}
$player = $event->getPlayer();
$m = "[ChatMute] ";
$ik = $this->isKorean();
if ($this->mute->get("AllMute")) {
$player->sendMessage($m . ($ik ? "모든 채팅 음소거 상태입니다.." : "All Mute"));
$event->setCancelled();
} else {
$name = $player->getName();
if (isset($this->mute->get("Mute")[$name])) {
$player->sendMessage($m . ($ik ? "당신은 채팅 음소거 상태입니다." : "ChatMute"));
$event->setCancelled();
}
}
}
示例7: handleDataPacket
/**
* Handles a Minecraft packet
* TODO: Separate all of this in handlers
*
* WARNING: Do not use this, it's only for internal use.
* Changes to this function won't be recorded on the version.
*
* @param DataPacket $packet
*/
public function handleDataPacket(DataPacket $packet)
{
if ($this->connected === false) {
return;
}
if ($packet::NETWORK_ID === ProtocolInfo::BATCH_PACKET) {
/** @var BatchPacket $packet */
$this->server->getNetwork()->processBatch($packet, $this);
return;
}
$timings = Timings::getReceiveDataPacketTimings($packet);
$timings->startTiming();
$this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
if ($ev->isCancelled()) {
$timings->stopTiming();
return;
}
switch ($packet::NETWORK_ID) {
case ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET:
$tile = $this->level->getTile($this->temporalVector->setComponents($packet->x, $packet->y, $packet->z));
if ($tile instanceof ItemFrame) {
if ($tile->getItem()->getId() !== Item::AIR) {
$this->getServer()->getPluginManager()->callEvent($ev = new ItemFrameDropItemEvent($this->getLevel()->getBlock($tile), $this, $tile->getItem(), $tile->getItemDropChance()));
if (!$ev->isCancelled()) {
if (mt_rand(0, 10) / 10 <= $tile->getItemDropChance()) {
$this->level->dropItem($tile, $tile->getItem());
}
$tile->setItem(Item::get(Item::AIR));
$tile->setItemRotation(0);
}
}
}
break;
case ProtocolInfo::PLAYER_INPUT_PACKET:
break;
case ProtocolInfo::LOGIN_PACKET:
if ($this->loggedIn) {
break;
}
$this->username = TextFormat::clean($packet->username);
$this->displayName = $this->username;
$this->iusername = strtolower($this->username);
#$this->setDataProperty(self::DATA_NAMETAG, self::DATA_TYPE_STRING, $this->username, false);
if ($this->server->getMaxPlayers() !== -1) {
if (count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)) {
break;
}
}
if (!in_array($packet->protocol, ProtocolInfo::ACCEPT_PROTOCOL)) {
if ($packet->protocol < ProtocolInfo::CURRENT_PROTOCOL) {
$message = "disconnectionScreen.outdatedClient";
$pk = new PlayStatusPacket();
$pk->status = PlayStatusPacket::LOGIN_FAILED_CLIENT;
$this->directDataPacket($pk);
} else {
$message = "disconnectionScreen.outdatedServer";
$pk = new PlayStatusPacket();
$pk->status = PlayStatusPacket::LOGIN_FAILED_SERVER;
$this->directDataPacket($pk);
}
$this->close("", $message, false);
break;
}
$this->randomClientId = $packet->clientId;
$this->uuid = UUID::fromString($packet->clientUUID);
$this->rawUUID = $this->uuid->toBinary();
$this->identityPublicKey = $packet->identityPublicKey;
$this->chainData = $packet->chainData;
$valid = true;
$len = strlen($packet->username);
if ($len > 16 or $len < 3) {
$valid = false;
}
for ($i = 0; $i < $len and $valid; ++$i) {
$c = ord($packet->username[$i]);
if ($c >= ord("a") and $c <= ord("z") or $c >= ord("A") and $c <= ord("Z") or $c >= ord("0") and $c <= ord("9") or $c === ord("_")) {
continue;
}
$valid = false;
break;
}
if (!$valid or $this->iusername === "rcon" or $this->iusername === "console") {
$this->close("", "disconnectionScreen.invalidName");
break;
}
if (strlen($packet->skin) !== 64 * 32 * 4 and strlen($packet->skin) !== 64 * 64 * 4) {
$this->close("", "disconnectionScreen.invalidSkin");
break;
}
$this->setSkin($packet->skin, $packet->skinId);
$this->server->getPluginManager()->callEvent($ev = new PlayerPreLoginEvent($this, "Plugin reason"));
//.........这里部分代码省略.........
示例8: onChat
public function onChat(PlayerChatEvent $ev)
{
//echo __METHOD__.",".__LINE__."\n";//##DEBUG
if ($ev->isCancelled()) {
return;
}
$p = $ev->getPlayer();
if ($p->hasPermission("gb.cmd.togglechat.excempt")) {
return;
}
// Can always chat!
if (!$this->chat) {
$p->sendMessage(mc::_("Chat has been globally disabled!"));
$ev->setCancelled();
return;
}
if ($this->getState($p, false)) {
$p->sendMessage(mc::_("You have chat disabled! Use /chat-on"));
$ev->setCancelled();
return;
}
$recvr = [];
foreach ($ev->getRecipients() as $to) {
if ($this->getState($to, false)) {
continue;
}
$recvr[] = $to;
}
$ev->setRecipients($recvr);
}
示例9: 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);
}
}
示例10: handleDataPacket
/**
* Handles a Minecraft packet
* TODO: Separate all of this in handlers
*
* WARNING: Do not use this, it's only for internal use.
* Changes to this function won't be recorded on the version.
*
* @param DataPacket $packet
*/
public function handleDataPacket(DataPacket $packet)
{
if ($this->connected === false) {
return;
}
$this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
if ($ev->isCancelled()) {
return;
}
switch ($packet->pid()) {
case ProtocolInfo::LOGIN_PACKET:
if ($this->loggedIn === true) {
break;
}
$this->username = TextFormat::clean($packet->username);
$this->displayName = $this->username;
$this->nameTag = $this->username;
$this->iusername = strtolower($this->username);
$this->loginData = ["clientId" => $packet->clientId, "loginData" => $packet->loginData];
if (count($this->server->getOnlinePlayers()) > $this->server->getMaxPlayers()) {
if ($this->kick("server full") === true) {
return;
}
}
if ($packet->protocol1 !== ProtocolInfo::CURRENT_PROTOCOL) {
if ($packet->protocol1 < ProtocolInfo::CURRENT_PROTOCOL) {
$pk = new LoginStatusPacket();
$pk->status = 1;
$this->dataPacket($pk);
} else {
$pk = new LoginStatusPacket();
$pk->status = 2;
$this->dataPacket($pk);
}
$this->close("", "Incorrect protocol #" . $packet->protocol1, false);
return;
}
if (strpos($packet->username, "") !== false or preg_match('#^[a-zA-Z0-9_]{3,16}$#', $packet->username) == 0 or $this->username === "" or $this->iusername === "rcon" or $this->iusername === "console" or strlen($packet->username) > 16 or strlen($packet->username) < 3) {
$this->close("", "Bad username");
return;
}
$this->server->getPluginManager()->callEvent($ev = new PlayerPreLoginEvent($this, "Plugin reason"));
if ($ev->isCancelled()) {
$this->close("", $ev->getKickMessage());
return;
}
if (!$this->server->isWhitelisted(strtolower($this->getName()))) {
$this->close(TextFormat::YELLOW . $this->username . " has left the game", "Server is white-listed");
return;
} elseif ($this->server->getNameBans()->isBanned(strtolower($this->getName())) or $this->server->getIPBans()->isBanned($this->getAddress())) {
$this->close(TextFormat::YELLOW . $this->username . " has left the game", "You are banned");
return;
}
if ($this->hasPermission(Server::BROADCAST_CHANNEL_USERS)) {
$this->server->getPluginManager()->subscribeToPermission(Server::BROADCAST_CHANNEL_USERS, $this);
}
if ($this->hasPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE)) {
$this->server->getPluginManager()->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this);
}
foreach ($this->server->getOnlinePlayers() as $p) {
if ($p !== $this and strtolower($p->getName()) === strtolower($this->getName())) {
if ($p->kick("logged in from another location") === false) {
$this->close(TextFormat::YELLOW . $this->getName() . " has left the game", "Logged in from another location");
return;
} else {
break;
}
}
}
$nbt = $this->server->getOfflinePlayerData($this->username);
if (!isset($nbt->NameTag)) {
$nbt->NameTag = new String("NameTag", $this->username);
} else {
$nbt["NameTag"] = $this->username;
}
$this->gamemode = $nbt["playerGameType"] & 0x3;
if ($this->server->getForceGamemode()) {
$this->gamemode = $this->server->getGamemode();
$nbt->playerGameType = new Int("playerGameType", $this->gamemode);
}
if (($level = $this->server->getLevelByName($nbt["Level"])) === null) {
$this->setLevel($this->server->getDefaultLevel(), true);
$nbt["Level"] = $this->level->getName();
$nbt["Pos"][0] = $this->level->getSpawnLocation()->x;
$nbt["Pos"][1] = $this->level->getSpawnLocation()->y;
$nbt["Pos"][2] = $this->level->getSpawnLocation()->z;
} else {
$this->setLevel($level, true);
}
if (!$nbt instanceof Compound) {
$this->close(TextFormat::YELLOW . $this->username . " has left the game", "Invalid data");
//.........这里部分代码省略.........
示例11: handleDataPacket
/**
* Handles a Minecraft packet
* TODO: Separate all of this in handlers
*
* WARNING: Do not use this, it's only for internal use.
* Changes to this function won't be recorded on the version.
*
* @param DataPacket $packet
*/
public function handleDataPacket(DataPacket $packet)
{
if ($this->connected === false) {
return;
}
if ($packet::NETWORK_ID === ProtocolInfo::BATCH_PACKET) {
/** @var BatchPacket $packet */
$this->server->getNetwork()->processBatch($packet, $this);
return;
}
$timings = Timings::getReceiveDataPacketTimings($packet);
$timings->startTiming();
$this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
if ($ev->isCancelled()) {
$timings->stopTiming();
return;
}
switch ($packet::NETWORK_ID) {
case ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET:
$tile = $this->level->getTile($this->temporalVector->setComponents($packet->x, $packet->y, $packet->z));
if ($tile instanceof ItemFrame) {
$block = $this->level->getBlock($tile);
$this->server->getPluginManager()->callEvent($ev = new BlockBreakEvent($this, $block, $this->getInventory()->getItemInHand(), true));
if (!$ev->isCancelled()) {
$item = $tile->getItem();
$this->server->getPluginManager()->callEvent($ev = new ItemFrameDropItemEvent($this, $block, $tile, $item));
if (!$ev->isCancelled()) {
if ($item->getId() !== Item::AIR) {
if (mt_rand(0, 10) / 10 < $tile->getItemDropChance()) {
$this->level->dropItem($tile, $item);
}
$tile->setItem(Item::get(Item::AIR));
$tile->setItemRotation(0);
}
} else {
$tile->spawnTo($this);
}
} else {
$tile->spawnTo($this);
}
}
break;
case ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET:
/*if($this->spawned){
$this->viewDistance = $packet->radius ** 2;
}*/
$pk = new ChunkRadiusUpdatedPacket();
$pk->radius = $this->server->chunkRadius != -1 ? $this->server->chunkRadius : $packet->radius;
$this->dataPacket($pk);
break;
case ProtocolInfo::PLAYER_INPUT_PACKET:
break;
case ProtocolInfo::LOGIN_PACKET:
if ($this->loggedIn) {
break;
}
$pk = new PlayStatusPacket();
$pk->status = PlayStatusPacket::LOGIN_SUCCESS;
$this->dataPacket($pk);
$this->username = TextFormat::clean($packet->username);
$this->displayName = $this->username;
$this->setNameTag($this->username);
$this->iusername = strtolower($this->username);
$this->protocol = $packet->protocol;
if (count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)) {
break;
}
if (!in_array($packet->protocol, ProtocolInfo::ACCEPTED_PROTOCOLS)) {
if ($packet->protocol < ProtocolInfo::CURRENT_PROTOCOL) {
$message = "disconnectionScreen.outdatedClient";
$pk = new PlayStatusPacket();
$pk->status = PlayStatusPacket::LOGIN_FAILED_CLIENT;
$this->directDataPacket($pk);
} else {
$message = "disconnectionScreen.outdatedServer";
$pk = new PlayStatusPacket();
$pk->status = PlayStatusPacket::LOGIN_FAILED_SERVER;
$this->directDataPacket($pk);
}
$this->close("", $message, false);
break;
}
$this->randomClientId = $packet->clientId;
$this->loginData = ["clientId" => $packet->clientId, "loginData" => null];
$this->uuid = UUID::fromString($packet->clientUUID);
$this->rawUUID = $this->uuid->toBinary();
$valid = true;
$len = strlen($packet->username);
if ($len > 16 or $len < 3) {
$valid = false;
}
//.........这里部分代码省略.........
示例12: 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: 여기에 위 주석의 코드가 있어야 하는 거 아닌가요?
}
示例13: 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());
}
//.........这里部分代码省略.........
示例14: 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;
}
}
示例15: 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);
}