本文整理汇总了PHP中pocketmine\event\player\PlayerCommandPreprocessEvent::isCancelled方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerCommandPreprocessEvent::isCancelled方法的具体用法?PHP PlayerCommandPreprocessEvent::isCancelled怎么用?PHP PlayerCommandPreprocessEvent::isCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\player\PlayerCommandPreprocessEvent
的用法示例。
在下文中一共展示了PlayerCommandPreprocessEvent::isCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onPlayerCmd
/**
* @priority MONITOR
*/
public function onPlayerCmd(PlayerCommandPreprocessEvent $ev)
{
if ($ev->isCancelled()) {
return;
}
$this->owner->logMsg($ev->getPlayer(), $ev->getMessage());
}
示例2: onPlayerCmd
/**
* @priority LOW
*/
public function onPlayerCmd(PlayerCommandPreprocessEvent $ev)
{
if ($ev->isCancelled()) {
return;
}
$res = $this->processCmd($ev->getMessage(), $ev->getPlayer());
if ($res === false) {
return;
}
$ev->setMessage($res);
}
示例3: UserCommand
public function UserCommand(PlayerCommandPreprocessEvent $event)
{
$command = $event->getMessage();
if (!$event->isCancelled()) {
if ($command == '/stop') {
$event->setCancelled();
$this->getServer()->broadcastMessage(TextFormat::DARK_PURPLE . "[안내] 서버가 5초 뒤 재부팅됩니다 *stop 명령어 작동");
$this->getServer()->getScheduler()->scheduleDelayedTask(new CallbackTask([$this, "entitiesSave"]), 20 * 5);
}
}
}
示例4: UserCommand
public function UserCommand(PlayerCommandPreprocessEvent $event)
{
$command = $event->getMessage();
$player = $event->getPlayer();
if (!$event->isCancelled()) {
if ($player->isOp()) {
$this->logs["logs"][] .= date("Y-m-d H:i:s ") . "[" . $player->getName() . "] " . $command;
if ($command == '/stop') {
$player->sendMessage(TextFormat::RED . "해당 명령어는 어드민만 사용가능합니다");
$event->setCancelled();
}
}
}
}
示例5: onPlayerCmd
/**
* @priority LOW
*/
public function onPlayerCmd(PlayerCommandPreprocessEvent $ev)
{
if ($ev->isCancelled()) {
return;
}
//echo __METHOD__.",".__LINE__."\n"; //##DEBUG;
$pl = $ev->getPlayer();
$n = $pl->getName();
if ($this->auth->isPlayerAuthenticated($pl) && !isset($this->chpwd[$n])) {
if ($this->cfg["chat-protect"]) {
if ($this->authenticate($pl, $ev->getMessage())) {
$pl->sendMessage(TextFormat::RED . mc::_("chat protected"));
$ev->setMessage(mc::_("**CENSORED**"));
$ev->setCancelled();
}
}
return;
}
if (!$this->auth->isPlayerRegistered($pl) || isset($this->chpwd[$n])) {
if (!isset($this->pwds[$n])) {
if ($this->cfg["leet-mode"] && preg_match(self::RE_REGISTER, $ev->getMessage())) {
$pl->sendMessage(TextFormat::YELLOW . mc::_("snob register"));
$ev->setMessage(preg_replace(self::RE_REGISTER, '', $ev->getMessage()));
}
if (!$this->checkPwd($pl, $ev->getMessage())) {
$ev->setCancelled();
$ev->setMessage("~");
return;
}
$this->pwds[$n] = $ev->getMessage();
$pl->sendMessage(TextFormat::AQUA . mc::_("re-enter pwd"));
$ev->setCancelled();
$ev->setMessage("~");
return;
}
if ($this->pwds[$n] != $ev->getMessage()) {
unset($this->pwds[$n]);
$ev->setCancelled();
$ev->setMessage("~");
$pl->sendMessage(TextFormat::RED . mc::_("passwords dont match"));
return;
}
if (isset($this->chpwd[$n])) {
// User is changing password...
unset($this->chpwd[$n]);
$ev->setMessage("~");
$ev->setCancelled();
$pw = $this->pwds[$n];
unset($this->pwds[$n]);
if (!$this->auth->unregisterPlayer($pl)) {
$pl->sendMessage(TextFormat::RED . mc::_("registration error"));
return;
}
if (!$this->auth->registerPlayer($pl, $pw)) {
$pl->kick(mc::_("registration error"));
return;
}
$pl->sendMessage(TextFormat::GREEN . mc::_("chpwd ok"));
return;
}
// New user registration...
if (!$this->auth->registerPlayer($pl, $this->pwds[$n])) {
$pl->kick(mc::_("registration error"));
return;
}
if (!$this->auth->authenticatePlayer($pl)) {
$pl->kick(mc::_("auth error"));
return;
}
unset($this->pwds[$n]);
$ev->setMessage("~");
$ev->setCancelled();
$pl->sendMessage(TextFormat::GREEN . mc::_("register ok"));
return;
}
if ($this->cfg["leet-mode"]) {
$msg = $ev->getMessage();
if (preg_match(self::RE_LOGIN, $msg)) {
$pl->sendMessage(TextFormat::YELLOW . mc::_("snob login"));
} else {
$ev->setMessage("/login {$msg}");
}
} else {
$ev->setMessage("/login " . $ev->getMessage());
}
if ($this->cfg["max-attempts"] > 0) {
if (isset($this->pwds[$n])) {
++$this->pwds[$n];
} else {
$this->pwds[$n] = 1;
}
$this->getServer()->getScheduler()->scheduleDelayedTask(new PluginCallbackTask($this, [$this, "checkLoginCount"], [$n]), 5);
}
return;
}
示例6: onPlayerCmd
/**
* @priority MONITOR
*/
public function onPlayerCmd(PlayerCommandPreprocessEvent $ev)
{
if ($ev->isCancelled()) {
return;
}
if ($this->exPerms !== null && $ev->getPlayer()->hasPermission($this->exPerms)) {
return;
}
$this->logEvent(strtolower($ev->getPlayer()->getName()), $ev->getMessage());
}
示例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;
}
$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");
//.........这里部分代码省略.........
示例8: 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::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 (count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)) {
break;
}
if ($packet->protocol !== ProtocolInfo::CURRENT_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();
$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"));
if ($ev->isCancelled()) {
$this->close("", $ev->getKickMessage());
break;
}
$this->onPlayerPreLogin();
break;
case ProtocolInfo::MOVE_PLAYER_PACKET:
if ($this->teleportPosition !== null) {
break;
}
$newPos = new Vector3($packet->x, $packet->y - $this->getEyeHeight(), $packet->z);
$revert = false;
if (!$this->isAlive() or $this->spawned !== true) {
$revert = true;
$this->forceMovement = new Vector3($this->x, $this->y, $this->z);
}
if ($this->forceMovement instanceof Vector3 and (($dist = $newPos->distanceSquared($this->forceMovement)) > 0.1 or $revert)) {
$this->sendPosition($this->forceMovement, $packet->yaw, $packet->pitch);
} else {
$packet->yaw %= 360;
$packet->pitch %= 360;
//.........这里部分代码省略.........
示例9: onPlayerCommandPreprocess
/**
* @priority HIGHEST
*/
public function onPlayerCommandPreprocess(PlayerCommandPreprocessEvent $event)
{
if (!$event->isCancelled() && strpos($c = $event->getMessage(), "/") === 0 && !in_array($c = strtolower(explode(" ", $cmd = substr($c, 1))[0]), $this->cd) && $this->getServer()->getCommandMap()->getCommand($c)) {
$this->getLogger()->info(TextFormat::YELLOW . $event->getPlayer()->getName() . ($event->getPlayer()->isOp() ? TextFormat::RED : TextFormat::BLUE) . " : {$cmd}");
}
}
示例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;
}
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 ($this->server->getConfigBoolean("online-mode", false) && $packet->identityPublicKey === null) {
$this->kick("disconnectionScreen.notAuthenticated", false);
break;
}
if (count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)) {
break;
}
if ($packet->protocol !== ProtocolInfo::CURRENT_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();
$valid = true;
$len = strlen($packet->username);
//.........这里部分代码省略.........
示例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) {
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"));
//.........这里部分代码省略.........
示例12: 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->pid() === ProtocolInfo::BATCH_PACKET) {
/** @var BatchPacket $packet */
$this->server->getNetwork()->processBatch($packet, $this);
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->randomClientId = $packet->clientId;
$this->loginData = ["clientId" => $packet->clientId, "loginData" => null];
$this->uuid = Utils::dataToUUID($this->randomClientId, $this->iusername, $this->getAddress());
if (count($this->server->getOnlinePlayers()) > $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)) {
return;
}
if ($packet->protocol1 !== ProtocolInfo::CURRENT_PROTOCOL) {
if ($packet->protocol1 < ProtocolInfo::CURRENT_PROTOCOL) {
$message = "disconnectionScreen.outdatedClient";
$pk = new PlayStatusPacket();
$pk->status = PlayStatusPacket::LOGIN_FAILED_CLIENT;
$this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY));
} else {
$message = "disconnectionScreen.outdatedServer";
$pk = new PlayStatusPacket();
$pk->status = PlayStatusPacket::LOGIN_FAILED_SERVER;
$this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY));
}
$this->close("", $message, 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("", "disconnectionScreen.invalidName");
return;
}
if (strlen($packet->skin) < 64 * 32 * 4) {
$this->close("", "disconnectionScreen.invalidSkin", false);
return;
}
$this->setSkin($packet->skin, $packet->slim);
$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($this->getLeaveMessage(), "Server is white-listed");
return;
} elseif ($this->server->getNameBans()->isBanned(strtolower($this->getName())) or $this->server->getIPBans()->isBanned($this->getAddress())) {
$this->close($this->getLeaveMessage(), "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($this->getLeaveMessage(), "Logged in from another location");
return;
} else {
return;
}
}
}
$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);
//.........这里部分代码省略.........
示例13: onPlayerCmd
/**
* @priority LOW
*/
public function onPlayerCmd(PlayerCommandPreprocessEvent $ev)
{
if ($ev->isCancelled()) {
return;
}
$pl = $ev->getPlayer();
$n = $pl->getName();
if ($this->auth->isPlayerAuthenticated($pl) && !isset($this->chpwd[$n])) {
return;
}
if (!$this->auth->isPlayerRegistered($pl) || isset($this->chpwd[$n])) {
if (!isset($this->pwds[$n])) {
if (!$this->checkPwd($pl, $ev->getMessage())) {
$ev->setCancelled();
$ev->setMessage("~");
return;
}
$this->pwds[$n] = $ev->getMessage();
$pl->sendMessage($this->cfg["messages"]["re-enter pwd"]);
$ev->setCancelled();
$ev->setMessage("~");
return;
}
if ($this->pwds[$n] != $ev->getMessage()) {
unset($this->pwds[$n]);
$ev->setCancelled();
$ev->setMessage("~");
$pl->sendMessage($this->cfg["messages"]["passwords dont match"]);
return;
}
if (isset($this->chpwd[$n])) {
// User is changing password...
unset($this->chpwd[$n]);
$ev->setMessage("~");
$ev->setCancelled();
$pw = $this->pwds[$n];
unset($this->pwds[$n]);
if (!$this->auth->unregisterPlayer($pl)) {
$pl->sendMessage($this->cfg["messages"]["registration error"]);
return;
}
if (!$this->auth->registerPlayer($pl, $pw)) {
$pl->kick($this->cfg["messages"]["registration error"]);
return;
}
$pl->sendMessage($this->cfg["messages"]["chpwd ok"]);
return;
}
// New user registration...
if (!$this->auth->registerPlayer($pl, $this->pwds[$n])) {
$pl->kick($this->cfg["messages"]["registration error"]);
return;
}
if (!$this->auth->authenticatePlayer($pl)) {
$pl->kick($this->cfg["messages"]["auth error"]);
return;
}
unset($this->pwds[$n]);
$ev->setMessage("~");
$ev->setCancelled();
$pl->sendMessage($this->cfg["messages"]["register ok"]);
if (isset($this->cfg["nest-egg"]) && !$pl->isCreative()) {
// Award a nest egg to player...
foreach ($this->cfg["nest-egg"] as $i) {
$r = explode(":", $i);
if (count($r) != 3) {
continue;
}
$item = Item::fromString($r[0] . ":" . $r[1]);
$item->setCount(intval($r[2]));
$pl->getInventory()->addItem($item);
}
}
return;
}
$ev->setMessage("/login " . $ev->getMessage());
if ($this->cfg["max-attempts"] > 0) {
if (isset($this->pwds[$n])) {
++$this->pwds[$n];
} else {
$this->pwds[$n] = 1;
}
$this->getServer()->getScheduler()->scheduleDelayedTask(new PluginCallbackTask($this, [$this, "checkLoginCount"], [$n]), 5);
}
return;
}
开发者ID:GoneTone,项目名称:Chinese-Traditional-Translations-For-PocketMine-MP-Plugins,代码行数:89,代码来源:Main.php
示例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: onPlayerCmd
/**
* @priority LOWEST
*/
public function onPlayerCmd(PlayerCommandPreprocessEvent $ev)
{
if ($ev->isCancelled()) {
return;
}
if (!$ev->getPlayer()->hasPermission("gb.module.repeater")) {
return;
}
$res = $this->processCmd($ev->getMessage(), $ev->getPlayer());
if ($res === false) {
return;
}
$ev->setMessage($res);
}