diff --git a/README.md b/README.md index 7cbb57a5..2905b705 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ NostalgiaCore is a fork of Legacy PocketMine-MP 1.3.12, which fixes bugs of Legacy PocketMine-MP, and adds new content -Supported MCPE versions: 0.3.0 ~ 0.8.1 (maybe 0.8.2) +Supported MCPI & MCPE versions: 0.3.0 ~ 0.8.1 (maybe 0.8.2) (Special thx to GullCraft Network and DartMiner43) diff --git a/src/Player.php b/src/Player.php index 64f8d1eb..038bcbf5 100755 --- a/src/Player.php +++ b/src/Player.php @@ -3595,6 +3595,44 @@ class Player{ } } break; + case ProtocolInfo::CHAT_PACKET: + if($this->spawned === false){ + break; + } + $this->craftingItems = []; + $this->toCraft = []; + $this->craftingType = CraftingRecipes::TYPE_INVENTORY; + if(trim($packet->message) != "" and strlen($packet->message) <= 255){ + $message = $packet->message; + if($message[0] === "/"){ //Command + if($this instanceof Player){ + console("[DEBUG] " . FORMAT_AQUA . $this->username . FORMAT_RESET . " issued server command: " . $message); + }else{ + console("[DEBUG] " . FORMAT_YELLOW . "*" . $this . FORMAT_RESET . " issued server command: " . $message); + } + $this->server->api->console->run(substr($message, 1), $this); + }else{ + $data = ["player" => $this, "message" => $message]; + if(Player::$disableEmojisInChat && Utils::hasEmoji($data["message"])){ + $this->sendChat("Your message contains illegal characters"); + break; + } + + //if($message == "pf"){ + // Living::$pathfind = !Living::$pathfind; + //} + + if($this->server->api->handle("player.chat", $data) !== false){ + $this->server->send2Discord("<" . $this->username . "> " . $message); + if(isset($data["message"])){ + $this->server->api->chat->send($this, $data["message"]); + }else{ + $this->server->api->chat->send($this, $message); + } + } + } + } + break; case ProtocolInfo::CONTAINER_CLOSE_PACKET: if($this->spawned === false){ break; diff --git a/src/network/protocol/packet/ChatPacket.php b/src/network/protocol/packet/ChatPacket.php index cbdf6c9f..0efd9553 100644 --- a/src/network/protocol/packet/ChatPacket.php +++ b/src/network/protocol/packet/ChatPacket.php @@ -17,7 +17,7 @@ class ChatPacket extends RakNetDataPacket{ } public function decode(){ - console($this->getString()); + $this->message = $this->getString(); } public function encode(){