mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 09:49:50 +00:00
Merge phase 1 of network refactor - session handler rewrite
There are further changes that need to be done yet, but this section is now ready for showtime.
This commit is contained in:
commit
25a5394152
File diff suppressed because it is too large
Load Diff
@ -70,7 +70,8 @@ use pocketmine\nbt\tag\ShortTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\network\AdvancedNetworkInterface;
|
||||
use pocketmine\network\mcpe\CompressBatchedTask;
|
||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\network\mcpe\NetworkCompression;
|
||||
use pocketmine\network\mcpe\PacketStream;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerListPacket;
|
||||
use pocketmine\network\mcpe\protocol\ProtocolInfo;
|
||||
@ -223,8 +224,6 @@ class Server{
|
||||
private $network;
|
||||
/** @var bool */
|
||||
private $networkCompressionAsync = true;
|
||||
/** @var int */
|
||||
public $networkCompressionLevel = 7;
|
||||
|
||||
/** @var bool */
|
||||
private $autoTickRate = true;
|
||||
@ -1517,15 +1516,15 @@ class Server{
|
||||
$this->asyncPool = new AsyncPool($this, $poolSize, (int) max(-1, (int) $this->getProperty("memory.async-worker-hard-limit", 256)), $this->autoloader, $this->logger);
|
||||
|
||||
if($this->getProperty("network.batch-threshold", 256) >= 0){
|
||||
Network::$BATCH_THRESHOLD = (int) $this->getProperty("network.batch-threshold", 256);
|
||||
NetworkCompression::$THRESHOLD = (int) $this->getProperty("network.batch-threshold", 256);
|
||||
}else{
|
||||
Network::$BATCH_THRESHOLD = -1;
|
||||
NetworkCompression::$THRESHOLD = -1;
|
||||
}
|
||||
|
||||
$this->networkCompressionLevel = $this->getProperty("network.compression-level", 7);
|
||||
if($this->networkCompressionLevel < 1 or $this->networkCompressionLevel > 9){
|
||||
$this->logger->warning("Invalid network compression level $this->networkCompressionLevel set, setting to default 7");
|
||||
$this->networkCompressionLevel = 7;
|
||||
NetworkCompression::$LEVEL = $this->getProperty("network.compression-level", 7);
|
||||
if(NetworkCompression::$LEVEL < 1 or NetworkCompression::$LEVEL > 9){
|
||||
$this->logger->warning("Invalid network compression level " . NetworkCompression::$LEVEL . " set, setting to default 7");
|
||||
NetworkCompression::$LEVEL = 7;
|
||||
}
|
||||
$this->networkCompressionAsync = (bool) $this->getProperty("network.async-compression", true);
|
||||
|
||||
@ -1864,24 +1863,23 @@ class Server{
|
||||
$targets = array_filter($players, function(Player $player) : bool{ return $player->isConnected(); });
|
||||
|
||||
if(!empty($targets)){
|
||||
$pk = new BatchPacket();
|
||||
$stream = new PacketStream();
|
||||
|
||||
foreach($packets as $p){
|
||||
$pk->addPacket($p);
|
||||
$stream->putPacket($p);
|
||||
}
|
||||
|
||||
if(Network::$BATCH_THRESHOLD >= 0 and strlen($pk->payload) >= Network::$BATCH_THRESHOLD){
|
||||
$pk->setCompressionLevel($this->networkCompressionLevel);
|
||||
}else{
|
||||
$pk->setCompressionLevel(0); //Do not compress packets under the threshold
|
||||
$compressionLevel = NetworkCompression::$LEVEL;
|
||||
if(NetworkCompression::$THRESHOLD < 0 or strlen($stream->buffer) < NetworkCompression::$THRESHOLD){
|
||||
$compressionLevel = 0; //Do not compress packets under the threshold
|
||||
$forceSync = true;
|
||||
}
|
||||
|
||||
if(!$forceSync and !$immediate and $this->networkCompressionAsync){
|
||||
$task = new CompressBatchedTask($pk, $targets);
|
||||
$task = new CompressBatchedTask($stream, $targets, $compressionLevel);
|
||||
$this->asyncPool->submitTask($task);
|
||||
}else{
|
||||
$this->broadcastPacketsCallback($pk, $targets, $immediate);
|
||||
$this->broadcastPacketsCallback(NetworkCompression::compress($stream->buffer), $targets, $immediate);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1889,17 +1887,13 @@ class Server{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BatchPacket $pk
|
||||
* @param Player[] $players
|
||||
* @param bool $immediate
|
||||
* @param string $payload
|
||||
* @param Player[] $players
|
||||
* @param bool $immediate
|
||||
*/
|
||||
public function broadcastPacketsCallback(BatchPacket $pk, array $players, bool $immediate = false){
|
||||
if(!$pk->isEncoded){
|
||||
$pk->encode();
|
||||
}
|
||||
|
||||
public function broadcastPacketsCallback(string $payload, array $players, bool $immediate = false){
|
||||
foreach($players as $i){
|
||||
$i->sendDataPacket($pk, false, $immediate);
|
||||
$i->getNetworkSession()->getInterface()->putPacket($i, $payload, $immediate);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,9 +25,9 @@ namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\network\mcpe\NetworkCompression;
|
||||
use pocketmine\network\mcpe\PacketStream;
|
||||
use pocketmine\network\mcpe\protocol\CraftingDataPacket;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\timings\Timings;
|
||||
|
||||
class CraftingManager{
|
||||
@ -38,7 +38,7 @@ class CraftingManager{
|
||||
/** @var FurnaceRecipe[] */
|
||||
protected $furnaceRecipes = [];
|
||||
|
||||
/** @var BatchPacket */
|
||||
/** @var string */
|
||||
private $craftingDataCache;
|
||||
|
||||
public function __construct(){
|
||||
@ -102,21 +102,19 @@ class CraftingManager{
|
||||
|
||||
$pk->encode();
|
||||
|
||||
$batch = new BatchPacket();
|
||||
$batch->addPacket($pk);
|
||||
$batch->setCompressionLevel(Server::getInstance()->networkCompressionLevel);
|
||||
$batch->encode();
|
||||
$batch = new PacketStream();
|
||||
$batch->putPacket($pk);
|
||||
|
||||
$this->craftingDataCache = $batch;
|
||||
$this->craftingDataCache = NetworkCompression::compress($batch->buffer);
|
||||
Timings::$craftingDataCacheRebuildTimer->stopTiming();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pre-compressed CraftingDataPacket for sending to players. Rebuilds the cache if it is not found.
|
||||
*
|
||||
* @return BatchPacket
|
||||
* @return string
|
||||
*/
|
||||
public function getCraftingDataPacket() : BatchPacket{
|
||||
public function getCraftingDataPacket() : string{
|
||||
if($this->craftingDataCache === null){
|
||||
$this->buildCraftingDataCache();
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\entity\Human;
|
||||
use pocketmine\event\player\PlayerItemHeldEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\protocol\InventoryContentPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
|
||||
@ -55,33 +54,7 @@ class PlayerInventory extends BaseInventory{
|
||||
return 36;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a client equips a hotbar slot. This method should not be used by plugins.
|
||||
* This method will call PlayerItemHeldEvent.
|
||||
*
|
||||
* @param int $hotbarSlot Number of the hotbar slot to equip.
|
||||
*
|
||||
* @return bool if the equipment change was successful, false if not.
|
||||
*/
|
||||
public function equipItem(int $hotbarSlot) : bool{
|
||||
if(!$this->isHotbarSlot($hotbarSlot)){
|
||||
$this->sendContents($this->getHolder());
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->getHolder()->getLevel()->getServer()->getPluginManager()->callEvent($ev = new PlayerItemHeldEvent($this->getHolder(), $this->getItem($hotbarSlot), $hotbarSlot));
|
||||
|
||||
if($ev->isCancelled()){
|
||||
$this->sendHeldItem($this->getHolder());
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->setHeldItemIndex($hotbarSlot, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function isHotbarSlot(int $slot) : bool{
|
||||
public function isHotbarSlot(int $slot) : bool{
|
||||
return $slot >= 0 and $slot <= $this->getHotbarSize();
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,6 @@ use pocketmine\metadata\MetadataValue;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\network\mcpe\ChunkRequestTask;
|
||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
@ -123,7 +122,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
/** @var Block[][] */
|
||||
private $blockCache = [];
|
||||
|
||||
/** @var BatchPacket[] */
|
||||
/** @var string[] */
|
||||
private $chunkCache = [];
|
||||
|
||||
/** @var int */
|
||||
@ -2498,7 +2497,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
}
|
||||
|
||||
public function chunkRequestCallback(int $x, int $z, BatchPacket $payload){
|
||||
public function chunkRequestCallback(int $x, int $z, string $payload){
|
||||
$this->timings->syncChunkSendTimer->startTiming();
|
||||
|
||||
$index = Level::chunkHash($x, $z);
|
||||
|
@ -33,9 +33,6 @@ use pocketmine\network\mcpe\protocol\PacketPool;
|
||||
use pocketmine\Server;
|
||||
|
||||
class Network{
|
||||
|
||||
public static $BATCH_THRESHOLD = 512;
|
||||
|
||||
/** @var Server */
|
||||
private $server;
|
||||
|
||||
|
@ -26,7 +26,6 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace pocketmine\network;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\Player;
|
||||
|
||||
/**
|
||||
@ -42,14 +41,11 @@ interface NetworkInterface{
|
||||
/**
|
||||
* Sends a DataPacket to the interface, returns an unique identifier for the packet if $needACK is true
|
||||
*
|
||||
* @param Player $player
|
||||
* @param DataPacket $packet
|
||||
* @param bool $needACK
|
||||
* @param bool $immediate
|
||||
*
|
||||
* @return int|null
|
||||
* @param Player $player
|
||||
* @param string $payload
|
||||
* @param bool $immediate
|
||||
*/
|
||||
public function putPacket(Player $player, DataPacket $packet, bool $needACK = false, bool $immediate = true) : ?int;
|
||||
public function putPacket(Player $player, string $payload, bool $immediate = true) : void;
|
||||
|
||||
/**
|
||||
* Terminates the connection
|
||||
|
@ -25,7 +25,6 @@ namespace pocketmine\network\mcpe;
|
||||
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\network\mcpe\protocol\FullChunkDataPacket;
|
||||
use pocketmine\scheduler\AsyncTask;
|
||||
use pocketmine\Server;
|
||||
@ -47,7 +46,7 @@ class ChunkRequestTask extends AsyncTask{
|
||||
|
||||
public function __construct(Level $level, int $chunkX, int $chunkZ, Chunk $chunk){
|
||||
$this->levelId = $level->getId();
|
||||
$this->compressionLevel = $level->getServer()->networkCompressionLevel;
|
||||
$this->compressionLevel = NetworkCompression::$LEVEL;
|
||||
|
||||
$this->chunk = $chunk->fastSerialize();
|
||||
$this->chunkX = $chunkX;
|
||||
@ -72,22 +71,17 @@ class ChunkRequestTask extends AsyncTask{
|
||||
$pk->chunkZ = $this->chunkZ;
|
||||
$pk->data = $chunk->networkSerialize() . $this->tiles;
|
||||
|
||||
$batch = new BatchPacket();
|
||||
$batch->addPacket($pk);
|
||||
$batch->setCompressionLevel($this->compressionLevel);
|
||||
$batch->encode();
|
||||
$stream = new PacketStream();
|
||||
$stream->putPacket($pk);
|
||||
|
||||
$this->setResult($batch->buffer, false);
|
||||
$this->setResult(NetworkCompression::compress($stream->buffer, $this->compressionLevel), false);
|
||||
}
|
||||
|
||||
public function onCompletion(Server $server) : void{
|
||||
$level = $server->getLevel($this->levelId);
|
||||
if($level instanceof Level){
|
||||
if($this->hasResult()){
|
||||
$batch = new BatchPacket($this->getResult());
|
||||
assert(strlen($batch->buffer) > 0);
|
||||
$batch->isEncoded = true;
|
||||
$level->chunkRequestCallback($this->chunkX, $this->chunkZ, $batch);
|
||||
$level->chunkRequestCallback($this->chunkX, $this->chunkZ, $this->getResult());
|
||||
}else{
|
||||
$server->getLogger()->error("Chunk request for level #" . $this->levelId . ", x=" . $this->chunkX . ", z=" . $this->chunkZ . " doesn't have any result data");
|
||||
}
|
||||
|
@ -23,44 +23,34 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\scheduler\AsyncTask;
|
||||
use pocketmine\Server;
|
||||
|
||||
class CompressBatchedTask extends AsyncTask{
|
||||
|
||||
public $level = 7;
|
||||
public $data;
|
||||
private $level;
|
||||
private $data;
|
||||
|
||||
/**
|
||||
* @param BatchPacket $batch
|
||||
* @param string[] $targets
|
||||
* @param PacketStream $stream
|
||||
* @param string[] $targets
|
||||
* @param int $compressionLevel
|
||||
*/
|
||||
public function __construct(BatchPacket $batch, array $targets){
|
||||
$this->data = $batch->payload;
|
||||
$this->level = $batch->getCompressionLevel();
|
||||
public function __construct(PacketStream $stream, array $targets, int $compressionLevel){
|
||||
$this->data = $stream->buffer;
|
||||
$this->level = $compressionLevel;
|
||||
$this->storeLocal($targets);
|
||||
}
|
||||
|
||||
public function onRun() : void{
|
||||
$batch = new BatchPacket();
|
||||
$batch->payload = $this->data;
|
||||
$this->data = null;
|
||||
|
||||
$batch->setCompressionLevel($this->level);
|
||||
$batch->encode();
|
||||
|
||||
$this->setResult($batch->buffer, false);
|
||||
$this->setResult(NetworkCompression::compress($this->data, $this->level), false);
|
||||
}
|
||||
|
||||
public function onCompletion(Server $server) : void{
|
||||
$pk = new BatchPacket($this->getResult());
|
||||
$pk->isEncoded = true;
|
||||
|
||||
/** @var Player[] $targets */
|
||||
$targets = $this->fetchLocal();
|
||||
|
||||
$server->broadcastPacketsCallback($pk, $targets);
|
||||
$server->broadcastPacketsCallback($this->getResult(), $targets);
|
||||
}
|
||||
}
|
||||
|
47
src/pocketmine/network/mcpe/NetworkCompression.php
Normal file
47
src/pocketmine/network/mcpe/NetworkCompression.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe;
|
||||
|
||||
final class NetworkCompression{
|
||||
public static $LEVEL = 7;
|
||||
public static $THRESHOLD = 256;
|
||||
|
||||
private function __construct(){
|
||||
|
||||
}
|
||||
|
||||
public static function decompress(string $payload) : string{
|
||||
return zlib_decode($payload, 1024 * 1024 * 64); //Max 64MB
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $payload
|
||||
* @param int $compressionLevel
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function compress(string $payload, ?int $compressionLevel = null) : string{
|
||||
return zlib_encode($payload, ZLIB_ENCODING_DEFLATE, $compressionLevel ?? self::$LEVEL);
|
||||
}
|
||||
}
|
@ -23,569 +23,163 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\AddBehaviorTreePacket;
|
||||
use pocketmine\network\mcpe\protocol\AddEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddHangingEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddItemEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddPaintingPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddPlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\AdventureSettingsPacket;
|
||||
use pocketmine\network\mcpe\protocol\AnimatePacket;
|
||||
use pocketmine\network\mcpe\protocol\AvailableCommandsPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\BookEditPacket;
|
||||
use pocketmine\network\mcpe\protocol\BossEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\CameraPacket;
|
||||
use pocketmine\network\mcpe\protocol\ChangeDimensionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientboundMapItemDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket;
|
||||
use pocketmine\network\mcpe\protocol\CommandOutputPacket;
|
||||
use pocketmine\network\mcpe\protocol\CommandRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerClosePacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerOpenPacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerSetDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\CraftingDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\CraftingEventPacket;
|
||||
use pocketmine\event\server\DataPacketReceiveEvent;
|
||||
use pocketmine\event\server\DataPacketSendEvent;
|
||||
use pocketmine\network\mcpe\handler\DeathSessionHandler;
|
||||
use pocketmine\network\mcpe\handler\LoginSessionHandler;
|
||||
use pocketmine\network\mcpe\handler\PreSpawnSessionHandler;
|
||||
use pocketmine\network\mcpe\handler\ResourcePacksSessionHandler;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\network\mcpe\handler\SimpleSessionHandler;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\DisconnectPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityFallPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\EventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ExplodePacket;
|
||||
use pocketmine\network\mcpe\protocol\FullChunkDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\GameRulesChangedPacket;
|
||||
use pocketmine\network\mcpe\protocol\GuiDataPickItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\HurtArmorPacket;
|
||||
use pocketmine\network\mcpe\protocol\InteractPacket;
|
||||
use pocketmine\network\mcpe\protocol\InventoryContentPacket;
|
||||
use pocketmine\network\mcpe\protocol\InventorySlotPacket;
|
||||
use pocketmine\network\mcpe\protocol\InventoryTransactionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ItemFrameDropItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\LabTablePacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LoginPacket;
|
||||
use pocketmine\network\mcpe\protocol\MapInfoRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEffectPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\ModalFormRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ModalFormResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveEntityAbsolutePacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveEntityDeltaPacket;
|
||||
use pocketmine\network\mcpe\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\NpcRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\PhotoTransferPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlaySoundPacket;
|
||||
use pocketmine\network\mcpe\protocol\PacketPool;
|
||||
use pocketmine\network\mcpe\protocol\PlayStatusPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerActionPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerHotbarPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerInputPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerListPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerSkinPacket;
|
||||
use pocketmine\network\mcpe\protocol\PurchaseReceiptPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveObjectivePacket;
|
||||
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackDataInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackStackPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePacksInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\RespawnPacket;
|
||||
use pocketmine\network\mcpe\protocol\RiderJumpPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerSettingsRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerSettingsResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerToClientHandshakePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetCommandsEnabledPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetDefaultGameTypePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetDifficultyPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetDisplayObjectivePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityLinkPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityMotionPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetHealthPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetLastHurtByPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetLocalPlayerAsInitializedPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetPlayerGameTypePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetScorePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetSpawnPositionPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetTimePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetTitlePacket;
|
||||
use pocketmine\network\mcpe\protocol\ShowCreditsPacket;
|
||||
use pocketmine\network\mcpe\protocol\ShowProfilePacket;
|
||||
use pocketmine\network\mcpe\protocol\ShowStoreOfferPacket;
|
||||
use pocketmine\network\mcpe\protocol\SimpleEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket;
|
||||
use pocketmine\network\mcpe\protocol\StartGamePacket;
|
||||
use pocketmine\network\mcpe\protocol\StopSoundPacket;
|
||||
use pocketmine\network\mcpe\protocol\StructureBlockUpdatePacket;
|
||||
use pocketmine\network\mcpe\protocol\SubClientLoginPacket;
|
||||
use pocketmine\network\mcpe\protocol\TakeItemEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\TextPacket;
|
||||
use pocketmine\network\mcpe\protocol\TransferPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateAttributesPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateBlockSyncedPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateEquipPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateTradePacket;
|
||||
use pocketmine\network\mcpe\protocol\WSConnectPacket;
|
||||
use pocketmine\network\NetworkInterface;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\timings\Timings;
|
||||
|
||||
abstract class NetworkSession{
|
||||
class NetworkSession{
|
||||
|
||||
abstract public function handleDataPacket(DataPacket $packet);
|
||||
|
||||
public function handleLogin(LoginPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlayStatus(PlayStatusPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleServerToClientHandshake(ServerToClientHandshakePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleClientToServerHandshake(ClientToServerHandshakePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleDisconnect(DisconnectPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePacksInfo(ResourcePacksInfoPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackStack(ResourcePackStackPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackClientResponse(ResourcePackClientResponsePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleText(TextPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetTime(SetTimePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleStartGame(StartGamePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddPlayer(AddPlayerPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddEntity(AddEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRemoveEntity(RemoveEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddItemEntity(AddItemEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddHangingEntity(AddHangingEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleTakeItemEntity(TakeItemEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMoveEntityAbsolute(MoveEntityAbsolutePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMovePlayer(MovePlayerPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRiderJump(RiderJumpPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleUpdateBlock(UpdateBlockPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddPainting(AddPaintingPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleExplode(ExplodePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleLevelSoundEvent(LevelSoundEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleLevelEvent(LevelEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBlockEvent(BlockEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleEntityEvent(EntityEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMobEffect(MobEffectPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleUpdateAttributes(UpdateAttributesPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleInventoryTransaction(InventoryTransactionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMobEquipment(MobEquipmentPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMobArmorEquipment(MobArmorEquipmentPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleInteract(InteractPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBlockPickRequest(BlockPickRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleEntityPickRequest(EntityPickRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlayerAction(PlayerActionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleEntityFall(EntityFallPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleHurtArmor(HurtArmorPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetEntityData(SetEntityDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetEntityMotion(SetEntityMotionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetEntityLink(SetEntityLinkPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetHealth(SetHealthPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetSpawnPosition(SetSpawnPositionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAnimate(AnimatePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRespawn(RespawnPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleContainerOpen(ContainerOpenPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleContainerClose(ContainerClosePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlayerHotbar(PlayerHotbarPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleInventoryContent(InventoryContentPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleInventorySlot(InventorySlotPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleContainerSetData(ContainerSetDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleCraftingData(CraftingDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleCraftingEvent(CraftingEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleGuiDataPickItem(GuiDataPickItemPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAdventureSettings(AdventureSettingsPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBlockEntityData(BlockEntityDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlayerInput(PlayerInputPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleFullChunkData(FullChunkDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetCommandsEnabled(SetCommandsEnabledPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetDifficulty(SetDifficultyPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleChangeDimension(ChangeDimensionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetPlayerGameType(SetPlayerGameTypePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlayerList(PlayerListPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSimpleEvent(SimpleEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleEvent(EventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSpawnExperienceOrb(SpawnExperienceOrbPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleClientboundMapItemData(ClientboundMapItemDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMapInfoRequest(MapInfoRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
/** @var Server */
|
||||
private $server;
|
||||
/** @var Player */
|
||||
private $player;
|
||||
/** @var NetworkInterface */
|
||||
private $interface;
|
||||
/** @var string */
|
||||
private $ip;
|
||||
/** @var int */
|
||||
private $port;
|
||||
|
||||
public function handleRequestChunkRadius(RequestChunkRadiusPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
/** @var SessionHandler */
|
||||
private $handler;
|
||||
|
||||
public function handleChunkRadiusUpdated(ChunkRadiusUpdatedPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
public function __construct(Server $server, Player $player, NetworkInterface $interface, string $ip, int $port){
|
||||
$this->server = $server;
|
||||
$this->player = $player;
|
||||
$this->interface = $interface;
|
||||
|
||||
public function handleItemFrameDropItem(ItemFrameDropItemPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
$this->ip = $ip;
|
||||
$this->port = $port;
|
||||
|
||||
public function handleGameRulesChanged(GameRulesChangedPacket $packet) : bool{
|
||||
return false;
|
||||
$this->setHandler(new LoginSessionHandler($player, $this));
|
||||
}
|
||||
|
||||
public function handleCamera(CameraPacket $packet) : bool{
|
||||
return false;
|
||||
public function getInterface() : NetworkInterface{
|
||||
return $this->interface;
|
||||
}
|
||||
|
||||
public function handleBossEvent(BossEventPacket $packet) : bool{
|
||||
return false;
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIp() : string{
|
||||
return $this->ip;
|
||||
}
|
||||
|
||||
public function handleShowCredits(ShowCreditsPacket $packet) : bool{
|
||||
return false;
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPort() : int{
|
||||
return $this->port;
|
||||
}
|
||||
|
||||
public function handleAvailableCommands(AvailableCommandsPacket $packet) : bool{
|
||||
return false;
|
||||
public function getHandler() : SessionHandler{
|
||||
return $this->handler;
|
||||
}
|
||||
|
||||
public function handleCommandRequest(CommandRequestPacket $packet) : bool{
|
||||
return false;
|
||||
public function setHandler(SessionHandler $handler) : void{
|
||||
$this->handler = $handler;
|
||||
$this->handler->setUp();
|
||||
}
|
||||
|
||||
public function handleCommandBlockUpdate(CommandBlockUpdatePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
public function handleEncoded(string $payload) : void{
|
||||
//TODO: decryption if enabled
|
||||
|
||||
public function handleCommandOutput(CommandOutputPacket $packet) : bool{
|
||||
return false;
|
||||
$stream = new PacketStream(NetworkCompression::decompress($payload));
|
||||
while(!$stream->feof()){
|
||||
$this->handleDataPacket(PacketPool::getPacket($stream->getString()));
|
||||
}
|
||||
}
|
||||
|
||||
public function handleUpdateTrade(UpdateTradePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
public function handleDataPacket(DataPacket $packet) : void{
|
||||
$timings = Timings::getReceiveDataPacketTimings($packet);
|
||||
$timings->startTiming();
|
||||
|
||||
public function handleUpdateEquip(UpdateEquipPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
$packet->decode();
|
||||
if(!$packet->feof() and !$packet->mayHaveUnreadBytes()){
|
||||
$remains = substr($packet->buffer, $packet->offset);
|
||||
$this->server->getLogger()->debug("Still " . strlen($remains) . " bytes unread in " . $packet->getName() . ": 0x" . bin2hex($remains));
|
||||
}
|
||||
|
||||
public function handleResourcePackDataInfo(ResourcePackDataInfoPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
$this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this->player, $packet));
|
||||
if(!$ev->isCancelled() and !$packet->handle($this->handler)){
|
||||
$this->server->getLogger()->debug("Unhandled " . $packet->getName() . " received from " . $this->player->getName() . ": 0x" . bin2hex($packet->buffer));
|
||||
}
|
||||
|
||||
public function handleResourcePackChunkData(ResourcePackChunkDataPacket $packet) : bool{
|
||||
return false;
|
||||
$timings->stopTiming();
|
||||
}
|
||||
|
||||
public function handleResourcePackChunkRequest(ResourcePackChunkRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
public function sendDataPacket(DataPacket $packet, bool $immediate = false) : bool{
|
||||
$timings = Timings::getSendDataPacketTimings($packet);
|
||||
$timings->startTiming();
|
||||
try{
|
||||
$this->server->getPluginManager()->callEvent($ev = new DataPacketSendEvent($this->player, $packet));
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleTransfer(TransferPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
//TODO: implement buffering (this is just a quick fix)
|
||||
$this->server->batchPackets([$this->player], [$packet], true, $immediate);
|
||||
|
||||
public function handlePlaySound(PlaySoundPacket $packet) : bool{
|
||||
return false;
|
||||
return true;
|
||||
}finally{
|
||||
$timings->stopTiming();
|
||||
}
|
||||
}
|
||||
|
||||
public function handleStopSound(StopSoundPacket $packet) : bool{
|
||||
return false;
|
||||
public function serverDisconnect(string $reason, bool $notify = true) : void{
|
||||
if($notify){
|
||||
$pk = new DisconnectPacket();
|
||||
$pk->message = $reason;
|
||||
$pk->hideDisconnectionScreen = $reason === "";
|
||||
$this->sendDataPacket($pk, true);
|
||||
}
|
||||
$this->interface->close($this->player, $notify ? $reason : "");
|
||||
}
|
||||
|
||||
public function handleSetTitle(SetTitlePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
//TODO: onEnableEncryption() step
|
||||
|
||||
public function handleAddBehaviorTree(AddBehaviorTreePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
public function onLoginSuccess() : void{
|
||||
$pk = new PlayStatusPacket();
|
||||
$pk->status = PlayStatusPacket::LOGIN_SUCCESS;
|
||||
$this->sendDataPacket($pk);
|
||||
|
||||
public function handleStructureBlockUpdate(StructureBlockUpdatePacket $packet) : bool{
|
||||
return false;
|
||||
$this->setHandler(new ResourcePacksSessionHandler($this->player, $this, $this->server->getResourcePackManager()));
|
||||
}
|
||||
|
||||
public function handleShowStoreOffer(ShowStoreOfferPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
public function onResourcePacksDone() : void{
|
||||
$this->player->_actuallyConstruct();
|
||||
|
||||
public function handlePurchaseReceipt(PurchaseReceiptPacket $packet) : bool{
|
||||
return false;
|
||||
$this->setHandler(new PreSpawnSessionHandler($this->server, $this->player, $this));
|
||||
}
|
||||
|
||||
public function handlePlayerSkin(PlayerSkinPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSubClientLogin(SubClientLoginPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleWSConnect(WSConnectPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetLastHurtBy(SetLastHurtByPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBookEdit(BookEditPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleNpcRequest(NpcRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePhotoTransfer(PhotoTransferPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleModalFormRequest(ModalFormRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleModalFormResponse(ModalFormResponsePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleServerSettingsRequest(ServerSettingsRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleServerSettingsResponse(ServerSettingsResponsePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleShowProfile(ShowProfilePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetDefaultGameType(SetDefaultGameTypePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRemoveObjective(RemoveObjectivePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetDisplayObjective(SetDisplayObjectivePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetScore(SetScorePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleLabTable(LabTablePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
public function onSpawn() : void{
|
||||
$pk = new PlayStatusPacket();
|
||||
$pk->status = PlayStatusPacket::PLAYER_SPAWN;
|
||||
$this->sendDataPacket($pk);
|
||||
|
||||
public function handleUpdateBlockSynced(UpdateBlockSyncedPacket $packet) : bool{
|
||||
return false;
|
||||
//TODO: split this up even further
|
||||
$this->setHandler(new SimpleSessionHandler($this->player));
|
||||
}
|
||||
|
||||
public function handleMoveEntityDelta(MoveEntityDeltaPacket $packet) : bool{
|
||||
return false;
|
||||
public function onDeath() : void{
|
||||
$this->setHandler(new DeathSessionHandler($this->player, $this));
|
||||
}
|
||||
|
||||
public function handleSetLocalPlayerAsInitialized(SetLocalPlayerAsInitializedPacket $packet) : bool{
|
||||
return false;
|
||||
public function onRespawn() : void{
|
||||
$this->setHandler(new SimpleSessionHandler($this->player));
|
||||
}
|
||||
}
|
||||
|
41
src/pocketmine/network/mcpe/PacketStream.php
Normal file
41
src/pocketmine/network/mcpe/PacketStream.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\PacketPool;
|
||||
|
||||
class PacketStream extends NetworkBinaryStream{
|
||||
|
||||
public function putPacket(DataPacket $packet) : void{
|
||||
if(!$packet->isEncoded){
|
||||
$packet->encode();
|
||||
}
|
||||
$this->putString($packet->buffer);
|
||||
}
|
||||
|
||||
public function getPacket() : DataPacket{
|
||||
return PacketPool::getPacket($this->getString());
|
||||
}
|
||||
}
|
@ -25,9 +25,6 @@ namespace pocketmine\network\mcpe;
|
||||
|
||||
use pocketmine\event\player\PlayerCreationEvent;
|
||||
use pocketmine\network\AdvancedNetworkInterface;
|
||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\PacketPool;
|
||||
use pocketmine\network\mcpe\protocol\ProtocolInfo;
|
||||
use pocketmine\network\Network;
|
||||
use pocketmine\Player;
|
||||
@ -48,6 +45,8 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
|
||||
*/
|
||||
private const MCPE_RAKNET_PROTOCOL_VERSION = 8;
|
||||
|
||||
private const MCPE_RAKNET_PACKET_ID = "\xfe";
|
||||
|
||||
/** @var Server */
|
||||
private $server;
|
||||
|
||||
@ -63,9 +62,6 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
|
||||
/** @var string[] */
|
||||
private $identifiers = [];
|
||||
|
||||
/** @var int[] */
|
||||
private $identifiersACK = [];
|
||||
|
||||
/** @var ServerHandler */
|
||||
private $interface;
|
||||
|
||||
@ -112,7 +108,6 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
|
||||
$player = $this->players[$identifier];
|
||||
unset($this->identifiers[spl_object_hash($player)]);
|
||||
unset($this->players[$identifier]);
|
||||
unset($this->identifiersACK[$identifier]);
|
||||
$player->close($player->getLeaveMessage(), $reason);
|
||||
}
|
||||
}
|
||||
@ -120,7 +115,6 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
|
||||
public function close(Player $player, string $reason = "unknown reason") : void{
|
||||
if(isset($this->identifiers[$h = spl_object_hash($player)])){
|
||||
unset($this->players[$this->identifiers[$h]]);
|
||||
unset($this->identifiersACK[$this->identifiers[$h]]);
|
||||
$this->interface->closeSession($this->identifiers[$h], $reason);
|
||||
unset($this->identifiers[$h]);
|
||||
}
|
||||
@ -143,7 +137,6 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
|
||||
|
||||
$player = new $class($this, $ev->getAddress(), $ev->getPort());
|
||||
$this->players[$identifier] = $player;
|
||||
$this->identifiersACK[$identifier] = 0;
|
||||
$this->identifiers[spl_object_hash($player)] = $identifier;
|
||||
$this->server->addPlayer($player);
|
||||
}
|
||||
@ -153,13 +146,12 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
|
||||
//get this now for blocking in case the player was closed before the exception was raised
|
||||
$address = $this->players[$identifier]->getAddress();
|
||||
try{
|
||||
if($packet->buffer !== ""){
|
||||
$pk = PacketPool::getPacket($packet->buffer);
|
||||
$this->players[$identifier]->handleDataPacket($pk);
|
||||
if($packet->buffer !== "" and $packet->buffer{0} === self::MCPE_RAKNET_PACKET_ID){ //Batch
|
||||
$this->players[$identifier]->getNetworkSession()->handleEncoded(substr($packet->buffer, 1));
|
||||
}
|
||||
}catch(\Throwable $e){
|
||||
$logger = $this->server->getLogger();
|
||||
$logger->debug("Packet " . (isset($pk) ? get_class($pk) : "unknown") . " 0x" . bin2hex($packet->buffer));
|
||||
$logger->debug("EncapsulatedPacket 0x" . bin2hex($packet->buffer));
|
||||
$logger->logException($e);
|
||||
|
||||
$this->interface->blockAddress($address, 5);
|
||||
@ -216,40 +208,17 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
|
||||
}
|
||||
}
|
||||
|
||||
public function putPacket(Player $player, DataPacket $packet, bool $needACK = false, bool $immediate = true) : ?int{
|
||||
public function putPacket(Player $player, string $payload, bool $immediate = true) : void{
|
||||
if(isset($this->identifiers[$h = spl_object_hash($player)])){
|
||||
$identifier = $this->identifiers[$h];
|
||||
if(!$packet->isEncoded){
|
||||
$packet->encode();
|
||||
}
|
||||
|
||||
if($packet instanceof BatchPacket){
|
||||
if($needACK){
|
||||
$pk = new EncapsulatedPacket();
|
||||
$pk->identifierACK = $this->identifiersACK[$identifier]++;
|
||||
$pk->buffer = $packet->buffer;
|
||||
$pk->reliability = PacketReliability::RELIABLE_ORDERED;
|
||||
$pk->orderChannel = 0;
|
||||
}else{
|
||||
if(!isset($packet->__encapsulatedPacket)){
|
||||
$packet->__encapsulatedPacket = new CachedEncapsulatedPacket;
|
||||
$packet->__encapsulatedPacket->identifierACK = null;
|
||||
$packet->__encapsulatedPacket->buffer = $packet->buffer;
|
||||
$packet->__encapsulatedPacket->reliability = PacketReliability::RELIABLE_ORDERED;
|
||||
$packet->__encapsulatedPacket->orderChannel = 0;
|
||||
}
|
||||
$pk = $packet->__encapsulatedPacket;
|
||||
}
|
||||
$pk = new EncapsulatedPacket();
|
||||
$pk->buffer = self::MCPE_RAKNET_PACKET_ID . $payload;
|
||||
$pk->reliability = PacketReliability::RELIABLE_ORDERED;
|
||||
$pk->orderChannel = 0;
|
||||
|
||||
$this->interface->sendEncapsulated($identifier, $pk, ($needACK ? RakLib::FLAG_NEED_ACK : 0) | ($immediate ? RakLib::PRIORITY_IMMEDIATE : RakLib::PRIORITY_NORMAL));
|
||||
return $pk->identifierACK;
|
||||
}else{
|
||||
$this->server->batchPackets([$player], [$packet], true, $immediate);
|
||||
return null;
|
||||
}
|
||||
$this->interface->sendEncapsulated($identifier, $pk, ($immediate ? RakLib::PRIORITY_IMMEDIATE : RakLib::PRIORITY_NORMAL));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function updatePing(string $identifier, int $pingMS) : void{
|
||||
|
61
src/pocketmine/network/mcpe/handler/DeathSessionHandler.php
Normal file
61
src/pocketmine/network/mcpe/handler/DeathSessionHandler.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\handler;
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\PlayerActionPacket;
|
||||
use pocketmine\network\mcpe\protocol\RespawnPacket;
|
||||
use pocketmine\Player;
|
||||
|
||||
class DeathSessionHandler extends SessionHandler{
|
||||
|
||||
/** @var Player */
|
||||
private $player;
|
||||
/** @var NetworkSession */
|
||||
private $session;
|
||||
|
||||
public function __construct(Player $player, NetworkSession $session){
|
||||
$this->player = $player;
|
||||
$this->session = $session;
|
||||
}
|
||||
|
||||
public function setUp() : void{
|
||||
$pk = new RespawnPacket();
|
||||
$pk->position = $this->player->getOffsetPosition($this->player->getSpawn());
|
||||
$this->session->sendDataPacket($pk);
|
||||
}
|
||||
|
||||
public function handlePlayerAction(PlayerActionPacket $packet) : bool{
|
||||
switch($packet->action){
|
||||
case PlayerActionPacket::ACTION_RESPAWN:
|
||||
$this->player->respawn();
|
||||
return true;
|
||||
case PlayerActionPacket::ACTION_DIMENSION_CHANGE_REQUEST:
|
||||
//TODO: players send this when they die in another dimension
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
89
src/pocketmine/network/mcpe/handler/LoginSessionHandler.php
Normal file
89
src/pocketmine/network/mcpe/handler/LoginSessionHandler.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\handler;
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\LoginPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayStatusPacket;
|
||||
use pocketmine\network\mcpe\protocol\ProtocolInfo;
|
||||
use pocketmine\Player;
|
||||
|
||||
/**
|
||||
* Handles the initial login phase of the session. This handler is used as the initial state.
|
||||
*/
|
||||
class LoginSessionHandler extends SessionHandler{
|
||||
|
||||
/** @var Player */
|
||||
private $player;
|
||||
/** @var NetworkSession */
|
||||
private $session;
|
||||
|
||||
public function __construct(Player $player, NetworkSession $session){
|
||||
$this->player = $player;
|
||||
$this->session = $session;
|
||||
}
|
||||
|
||||
public function handleLogin(LoginPacket $packet) : bool{
|
||||
if(!$this->isCompatibleProtocol($packet->protocol)){
|
||||
$pk = new PlayStatusPacket();
|
||||
$pk->status = $packet->protocol < ProtocolInfo::CURRENT_PROTOCOL ?
|
||||
PlayStatusPacket::LOGIN_FAILED_CLIENT : PlayStatusPacket::LOGIN_FAILED_SERVER;
|
||||
$pk->protocol = $packet->protocol;
|
||||
$this->session->sendDataPacket($pk, true);
|
||||
|
||||
//This pocketmine disconnect message will only be seen by the console (PlayStatusPacket causes the messages to be shown for the client)
|
||||
$this->player->close(
|
||||
"",
|
||||
$this->player->getServer()->getLanguage()->translateString("pocketmine.disconnect.incompatibleProtocol", [$packet->protocol]),
|
||||
false
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!Player::isValidUserName($packet->username)){
|
||||
$this->player->close("", "disconnectionScreen.invalidName");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if($packet->skin === null or !$packet->skin->isValid()){
|
||||
$this->player->close("", "disconnectionScreen.invalidSkin");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if($this->player->handleLogin($packet)){
|
||||
if($this->session->getHandler() === $this){ //when login verification is disabled, the handler will already have been replaced
|
||||
$this->session->setHandler(new NullSessionHandler()); //drop packets received during login verification
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function isCompatibleProtocol(int $protocolVersion) : bool{
|
||||
return $protocolVersion === ProtocolInfo::CURRENT_PROTOCOL;
|
||||
}
|
||||
}
|
@ -21,15 +21,11 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe;
|
||||
namespace pocketmine\network\mcpe\handler;
|
||||
|
||||
use raklib\protocol\EncapsulatedPacket;
|
||||
/**
|
||||
* Handler which simply ignores all packets received.
|
||||
*/
|
||||
class NullSessionHandler extends SessionHandler{
|
||||
|
||||
class CachedEncapsulatedPacket extends EncapsulatedPacket{
|
||||
/** @var string|null */
|
||||
private $internalData = null;
|
||||
|
||||
public function toInternalBinary() : string{
|
||||
return $this->internalData ?? ($this->internalData = parent::toInternalBinary());
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\handler;
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
|
||||
use pocketmine\network\mcpe\protocol\StartGamePacket;
|
||||
use pocketmine\network\mcpe\protocol\types\DimensionIds;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
|
||||
/**
|
||||
* Handler used for the pre-spawn phase of the session.
|
||||
*/
|
||||
class PreSpawnSessionHandler extends SessionHandler{
|
||||
|
||||
/** @var Server */
|
||||
private $server;
|
||||
/** @var Player */
|
||||
private $player;
|
||||
/** @var NetworkSession */
|
||||
private $session;
|
||||
|
||||
public function __construct(Server $server, Player $player, NetworkSession $session){
|
||||
$this->player = $player;
|
||||
$this->server = $server;
|
||||
$this->session = $session;
|
||||
}
|
||||
|
||||
public function setUp() : void{
|
||||
$spawnPosition = $this->player->getSpawn();
|
||||
|
||||
$pk = new StartGamePacket();
|
||||
$pk->entityUniqueId = $this->player->getId();
|
||||
$pk->entityRuntimeId = $this->player->getId();
|
||||
$pk->playerGamemode = Player::getClientFriendlyGamemode($this->player->getGamemode());
|
||||
$pk->playerPosition = $this->player->getOffsetPosition($this->player);
|
||||
$pk->pitch = $this->player->pitch;
|
||||
$pk->yaw = $this->player->yaw;
|
||||
$pk->seed = -1;
|
||||
$pk->dimension = DimensionIds::OVERWORLD; //TODO: implement this properly
|
||||
$pk->worldGamemode = Player::getClientFriendlyGamemode($this->server->getGamemode());
|
||||
$pk->difficulty = $this->player->getLevel()->getDifficulty();
|
||||
$pk->spawnX = $spawnPosition->getFloorX();
|
||||
$pk->spawnY = $spawnPosition->getFloorY();
|
||||
$pk->spawnZ = $spawnPosition->getFloorZ();
|
||||
$pk->hasAchievementsDisabled = true;
|
||||
$pk->time = $this->player->getLevel()->getTime();
|
||||
$pk->eduMode = false;
|
||||
$pk->rainLevel = 0; //TODO: implement these properly
|
||||
$pk->lightningLevel = 0;
|
||||
$pk->commandsEnabled = true;
|
||||
$pk->levelId = "";
|
||||
$pk->worldName = $this->server->getMotd();
|
||||
$this->session->sendDataPacket($pk);
|
||||
|
||||
$this->player->getLevel()->sendTime($this->player);
|
||||
|
||||
$this->player->sendAttributes(true);
|
||||
$this->player->sendCommandData();
|
||||
$this->player->sendSettings();
|
||||
$this->player->sendPotionEffects($this->player);
|
||||
$this->player->sendData($this->player);
|
||||
|
||||
$this->player->sendAllInventories();
|
||||
$this->player->getInventory()->sendCreativeContents();
|
||||
$this->player->getInventory()->sendHeldItem($this->player);
|
||||
$this->session->getInterface()->putPacket($this->player, $this->server->getCraftingManager()->getCraftingDataPacket());
|
||||
|
||||
$this->server->sendFullPlayerListData($this->player);
|
||||
}
|
||||
|
||||
public function handleRequestChunkRadius(RequestChunkRadiusPacket $packet) : bool{
|
||||
$this->player->setViewDistance($packet->radius);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\handler;
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackDataInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePacksInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackStackPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\resourcepacks\ResourcePack;
|
||||
use pocketmine\resourcepacks\ResourcePackManager;
|
||||
|
||||
/**
|
||||
* Handler used for the resource packs sequence phase of the session. This handler takes care of downloading resource
|
||||
* packs to the client.
|
||||
*/
|
||||
class ResourcePacksSessionHandler extends SessionHandler{
|
||||
private const PACK_CHUNK_SIZE = 1048576; //1MB
|
||||
|
||||
/** @var Player */
|
||||
private $player;
|
||||
/** @var NetworkSession */
|
||||
private $session;
|
||||
/** @var ResourcePackManager */
|
||||
private $resourcePackManager;
|
||||
|
||||
public function __construct(Player $player, NetworkSession $session, ResourcePackManager $resourcePackManager){
|
||||
$this->player = $player;
|
||||
$this->session = $session;
|
||||
$this->resourcePackManager = $resourcePackManager;
|
||||
}
|
||||
|
||||
public function setUp() : void{
|
||||
$pk = new ResourcePacksInfoPacket();
|
||||
$pk->resourcePackEntries = $this->resourcePackManager->getResourceStack();
|
||||
$pk->mustAccept = $this->resourcePackManager->resourcePacksRequired();
|
||||
$this->session->sendDataPacket($pk);
|
||||
}
|
||||
|
||||
public function handleResourcePackClientResponse(ResourcePackClientResponsePacket $packet) : bool{
|
||||
switch($packet->status){
|
||||
case ResourcePackClientResponsePacket::STATUS_REFUSED:
|
||||
//TODO: add lang strings for this
|
||||
$this->player->close("", "You must accept resource packs to join this server.", true);
|
||||
break;
|
||||
case ResourcePackClientResponsePacket::STATUS_SEND_PACKS:
|
||||
foreach($packet->packIds as $uuid){
|
||||
$pack = $this->resourcePackManager->getPackById($uuid);
|
||||
if(!($pack instanceof ResourcePack)){
|
||||
//Client requested a resource pack but we don't have it available on the server
|
||||
$this->player->close("", "disconnectionScreen.resourcePack", true);
|
||||
$this->player->getServer()->getLogger()->debug("Got a resource pack request for unknown pack with UUID " . $uuid . ", available packs: " . implode(", ", $this->resourcePackManager->getPackIdList()));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$pk = new ResourcePackDataInfoPacket();
|
||||
$pk->packId = $pack->getPackId();
|
||||
$pk->maxChunkSize = self::PACK_CHUNK_SIZE; //1MB
|
||||
$pk->chunkCount = (int) ceil($pack->getPackSize() / self::PACK_CHUNK_SIZE);
|
||||
$pk->compressedPackSize = $pack->getPackSize();
|
||||
$pk->sha256 = $pack->getSha256();
|
||||
$this->session->sendDataPacket($pk);
|
||||
}
|
||||
|
||||
break;
|
||||
case ResourcePackClientResponsePacket::STATUS_HAVE_ALL_PACKS:
|
||||
$pk = new ResourcePackStackPacket();
|
||||
$pk->resourcePackStack = $this->resourcePackManager->getResourceStack();
|
||||
$pk->mustAccept = $this->resourcePackManager->resourcePacksRequired();
|
||||
$this->session->sendDataPacket($pk);
|
||||
break;
|
||||
case ResourcePackClientResponsePacket::STATUS_COMPLETED:
|
||||
$this->session->onResourcePacksDone();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleResourcePackChunkRequest(ResourcePackChunkRequestPacket $packet) : bool{
|
||||
$pack = $this->resourcePackManager->getPackById($packet->packId);
|
||||
if(!($pack instanceof ResourcePack)){
|
||||
$this->player->close("", "disconnectionScreen.resourcePack", true);
|
||||
$this->player->getServer()->getLogger()->debug("Got a resource pack chunk request for unknown pack with UUID " . $packet->packId . ", available packs: " . implode(", ", $this->resourcePackManager->getPackIdList()));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$pk = new ResourcePackChunkDataPacket();
|
||||
$pk->packId = $pack->getPackId();
|
||||
$pk->chunkIndex = $packet->chunkIndex;
|
||||
$pk->data = $pack->getPackChunk(self::PACK_CHUNK_SIZE * $packet->chunkIndex, self::PACK_CHUNK_SIZE);
|
||||
$pk->progress = (self::PACK_CHUNK_SIZE * $packet->chunkIndex);
|
||||
$this->session->sendDataPacket($pk);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
598
src/pocketmine/network/mcpe/handler/SessionHandler.php
Normal file
598
src/pocketmine/network/mcpe/handler/SessionHandler.php
Normal file
@ -0,0 +1,598 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\handler;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\AddBehaviorTreePacket;
|
||||
use pocketmine\network\mcpe\protocol\AddEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddHangingEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddItemEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddPaintingPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddPlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\AdventureSettingsPacket;
|
||||
use pocketmine\network\mcpe\protocol\AnimatePacket;
|
||||
use pocketmine\network\mcpe\protocol\AvailableCommandsPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\BookEditPacket;
|
||||
use pocketmine\network\mcpe\protocol\BossEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\CameraPacket;
|
||||
use pocketmine\network\mcpe\protocol\ChangeDimensionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientboundMapItemDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket;
|
||||
use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket;
|
||||
use pocketmine\network\mcpe\protocol\CommandOutputPacket;
|
||||
use pocketmine\network\mcpe\protocol\CommandRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerClosePacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerOpenPacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerSetDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\CraftingDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\CraftingEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\DisconnectPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityFallPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\EventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ExplodePacket;
|
||||
use pocketmine\network\mcpe\protocol\FullChunkDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\GameRulesChangedPacket;
|
||||
use pocketmine\network\mcpe\protocol\GuiDataPickItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\HurtArmorPacket;
|
||||
use pocketmine\network\mcpe\protocol\InteractPacket;
|
||||
use pocketmine\network\mcpe\protocol\InventoryContentPacket;
|
||||
use pocketmine\network\mcpe\protocol\InventorySlotPacket;
|
||||
use pocketmine\network\mcpe\protocol\InventoryTransactionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ItemFrameDropItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\LabTablePacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LoginPacket;
|
||||
use pocketmine\network\mcpe\protocol\MapInfoRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEffectPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\ModalFormRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ModalFormResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveEntityAbsolutePacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveEntityDeltaPacket;
|
||||
use pocketmine\network\mcpe\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\NpcRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\PhotoTransferPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerActionPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerHotbarPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerInputPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerListPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerSkinPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlaySoundPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayStatusPacket;
|
||||
use pocketmine\network\mcpe\protocol\PurchaseReceiptPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveObjectivePacket;
|
||||
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackDataInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePacksInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackStackPacket;
|
||||
use pocketmine\network\mcpe\protocol\RespawnPacket;
|
||||
use pocketmine\network\mcpe\protocol\RiderJumpPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerSettingsRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerSettingsResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerToClientHandshakePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetCommandsEnabledPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetDefaultGameTypePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetDifficultyPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetDisplayObjectivePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityLinkPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityMotionPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetHealthPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetLastHurtByPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetLocalPlayerAsInitializedPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetPlayerGameTypePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetScorePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetSpawnPositionPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetTimePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetTitlePacket;
|
||||
use pocketmine\network\mcpe\protocol\ShowCreditsPacket;
|
||||
use pocketmine\network\mcpe\protocol\ShowProfilePacket;
|
||||
use pocketmine\network\mcpe\protocol\ShowStoreOfferPacket;
|
||||
use pocketmine\network\mcpe\protocol\SimpleEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket;
|
||||
use pocketmine\network\mcpe\protocol\StartGamePacket;
|
||||
use pocketmine\network\mcpe\protocol\StopSoundPacket;
|
||||
use pocketmine\network\mcpe\protocol\StructureBlockUpdatePacket;
|
||||
use pocketmine\network\mcpe\protocol\SubClientLoginPacket;
|
||||
use pocketmine\network\mcpe\protocol\TakeItemEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\TextPacket;
|
||||
use pocketmine\network\mcpe\protocol\TransferPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateAttributesPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateBlockSyncedPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateEquipPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateTradePacket;
|
||||
use pocketmine\network\mcpe\protocol\WSConnectPacket;
|
||||
|
||||
/**
|
||||
* Handlers are attached to sessions to handle packets received from their associated clients. A handler
|
||||
* is mutable and may be removed/replaced at any time.
|
||||
*
|
||||
* This class is an automatically generated stub. Do not edit it manually.
|
||||
*/
|
||||
abstract class SessionHandler{
|
||||
|
||||
public function setUp() : void{
|
||||
|
||||
}
|
||||
|
||||
public function handleLogin(LoginPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlayStatus(PlayStatusPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleServerToClientHandshake(ServerToClientHandshakePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleClientToServerHandshake(ClientToServerHandshakePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleDisconnect(DisconnectPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePacksInfo(ResourcePacksInfoPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackStack(ResourcePackStackPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackClientResponse(ResourcePackClientResponsePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleText(TextPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetTime(SetTimePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleStartGame(StartGamePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddPlayer(AddPlayerPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddEntity(AddEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRemoveEntity(RemoveEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddItemEntity(AddItemEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddHangingEntity(AddHangingEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleTakeItemEntity(TakeItemEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMoveEntityAbsolute(MoveEntityAbsolutePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMovePlayer(MovePlayerPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRiderJump(RiderJumpPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleUpdateBlock(UpdateBlockPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddPainting(AddPaintingPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleExplode(ExplodePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleLevelSoundEvent(LevelSoundEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleLevelEvent(LevelEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBlockEvent(BlockEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleEntityEvent(EntityEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMobEffect(MobEffectPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleUpdateAttributes(UpdateAttributesPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleInventoryTransaction(InventoryTransactionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMobEquipment(MobEquipmentPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMobArmorEquipment(MobArmorEquipmentPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleInteract(InteractPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBlockPickRequest(BlockPickRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleEntityPickRequest(EntityPickRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlayerAction(PlayerActionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleEntityFall(EntityFallPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleHurtArmor(HurtArmorPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetEntityData(SetEntityDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetEntityMotion(SetEntityMotionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetEntityLink(SetEntityLinkPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetHealth(SetHealthPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetSpawnPosition(SetSpawnPositionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAnimate(AnimatePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRespawn(RespawnPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleContainerOpen(ContainerOpenPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleContainerClose(ContainerClosePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlayerHotbar(PlayerHotbarPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleInventoryContent(InventoryContentPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleInventorySlot(InventorySlotPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleContainerSetData(ContainerSetDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleCraftingData(CraftingDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleCraftingEvent(CraftingEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleGuiDataPickItem(GuiDataPickItemPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAdventureSettings(AdventureSettingsPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBlockEntityData(BlockEntityDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlayerInput(PlayerInputPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleFullChunkData(FullChunkDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetCommandsEnabled(SetCommandsEnabledPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetDifficulty(SetDifficultyPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleChangeDimension(ChangeDimensionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetPlayerGameType(SetPlayerGameTypePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlayerList(PlayerListPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSimpleEvent(SimpleEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleEvent(EventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSpawnExperienceOrb(SpawnExperienceOrbPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleClientboundMapItemData(ClientboundMapItemDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMapInfoRequest(MapInfoRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRequestChunkRadius(RequestChunkRadiusPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleChunkRadiusUpdated(ChunkRadiusUpdatedPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleItemFrameDropItem(ItemFrameDropItemPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleGameRulesChanged(GameRulesChangedPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleCamera(CameraPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBossEvent(BossEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleShowCredits(ShowCreditsPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAvailableCommands(AvailableCommandsPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleCommandRequest(CommandRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleCommandBlockUpdate(CommandBlockUpdatePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleCommandOutput(CommandOutputPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleUpdateTrade(UpdateTradePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleUpdateEquip(UpdateEquipPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackDataInfo(ResourcePackDataInfoPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackChunkData(ResourcePackChunkDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackChunkRequest(ResourcePackChunkRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleTransfer(TransferPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlaySound(PlaySoundPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleStopSound(StopSoundPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetTitle(SetTitlePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddBehaviorTree(AddBehaviorTreePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleStructureBlockUpdate(StructureBlockUpdatePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleShowStoreOffer(ShowStoreOfferPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePurchaseReceipt(PurchaseReceiptPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlayerSkin(PlayerSkinPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSubClientLogin(SubClientLoginPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleWSConnect(WSConnectPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetLastHurtBy(SetLastHurtByPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBookEdit(BookEditPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleNpcRequest(NpcRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePhotoTransfer(PhotoTransferPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleModalFormRequest(ModalFormRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleModalFormResponse(ModalFormResponsePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleServerSettingsRequest(ServerSettingsRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleServerSettingsResponse(ServerSettingsResponsePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleShowProfile(ShowProfilePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetDefaultGameType(SetDefaultGameTypePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRemoveObjective(RemoveObjectivePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetDisplayObjective(SetDisplayObjectivePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetScore(SetScorePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleLabTable(LabTablePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleUpdateBlockSynced(UpdateBlockSyncedPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMoveEntityDelta(MoveEntityDeltaPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetLocalPlayerAsInitialized(SetLocalPlayerAsInitializedPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
}
|
@ -21,11 +21,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe;
|
||||
namespace pocketmine\network\mcpe\handler;
|
||||
|
||||
|
||||
use pocketmine\event\server\DataPacketReceiveEvent;
|
||||
use pocketmine\event\server\DataPacketSendEvent;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\AdventureSettingsPacket;
|
||||
use pocketmine\network\mcpe\protocol\AnimatePacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
|
||||
@ -37,16 +35,14 @@ use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket;
|
||||
use pocketmine\network\mcpe\protocol\CommandRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerClosePacket;
|
||||
use pocketmine\network\mcpe\protocol\CraftingEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\DisconnectPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityFallPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\InteractPacket;
|
||||
use pocketmine\network\mcpe\protocol\InventoryTransactionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ItemFrameDropItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\LabTablePacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LoginPacket;
|
||||
use pocketmine\network\mcpe\protocol\MapInfoRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
|
||||
@ -57,90 +53,32 @@ use pocketmine\network\mcpe\protocol\PlayerHotbarPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerInputPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerSkinPacket;
|
||||
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerSettingsRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetLocalPlayerAsInitializedPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetPlayerGameTypePacket;
|
||||
use pocketmine\network\mcpe\protocol\ShowCreditsPacket;
|
||||
use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket;
|
||||
use pocketmine\network\mcpe\protocol\SubClientLoginPacket;
|
||||
use pocketmine\network\mcpe\protocol\TextPacket;
|
||||
use pocketmine\network\NetworkInterface;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\timings\Timings;
|
||||
|
||||
class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
/**
|
||||
* Temporary session handler implementation
|
||||
* TODO: split this up properly into different handlers
|
||||
*/
|
||||
class SimpleSessionHandler extends SessionHandler{
|
||||
|
||||
/** @var Server */
|
||||
private $server;
|
||||
/** @var Player */
|
||||
private $player;
|
||||
/** @var NetworkInterface */
|
||||
private $interface;
|
||||
|
||||
public function __construct(Server $server, Player $player, NetworkInterface $interface){
|
||||
$this->server = $server;
|
||||
public function __construct(Player $player){
|
||||
$this->player = $player;
|
||||
$this->interface = $interface;
|
||||
}
|
||||
|
||||
public function handleDataPacket(DataPacket $packet) : void{
|
||||
$timings = Timings::getReceiveDataPacketTimings($packet);
|
||||
$timings->startTiming();
|
||||
|
||||
$packet->decode();
|
||||
if(!$packet->feof() and !$packet->mayHaveUnreadBytes()){
|
||||
$remains = substr($packet->buffer, $packet->offset);
|
||||
$this->server->getLogger()->debug("Still " . strlen($remains) . " bytes unread in " . $packet->getName() . ": 0x" . bin2hex($remains));
|
||||
}
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this->player, $packet));
|
||||
if(!$ev->isCancelled() and !$packet->handle($this)){
|
||||
$this->server->getLogger()->debug("Unhandled " . $packet->getName() . " received from " . $this->player->getName() . ": 0x" . bin2hex($packet->buffer));
|
||||
}
|
||||
|
||||
$timings->stopTiming();
|
||||
}
|
||||
|
||||
public function sendDataPacket(DataPacket $packet, bool $immediate = false) : bool{
|
||||
$timings = Timings::getSendDataPacketTimings($packet);
|
||||
$timings->startTiming();
|
||||
try{
|
||||
$this->server->getPluginManager()->callEvent($ev = new DataPacketSendEvent($this->player, $packet));
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->interface->putPacket($this->player, $packet, false, $immediate);
|
||||
|
||||
return true;
|
||||
}finally{
|
||||
$timings->stopTiming();
|
||||
}
|
||||
}
|
||||
|
||||
public function serverDisconnect(string $reason, bool $notify = true) : void{
|
||||
if($notify){
|
||||
$pk = new DisconnectPacket();
|
||||
$pk->message = $reason;
|
||||
$pk->hideDisconnectionScreen = $reason === "";
|
||||
$this->sendDataPacket($pk, true);
|
||||
}
|
||||
$this->interface->close($this->player, $notify ? $reason : "");
|
||||
}
|
||||
|
||||
public function handleLogin(LoginPacket $packet) : bool{
|
||||
return $this->player->handleLogin($packet);
|
||||
}
|
||||
|
||||
public function handleClientToServerHandshake(ClientToServerHandshakePacket $packet) : bool{
|
||||
return false; //TODO
|
||||
}
|
||||
|
||||
public function handleResourcePackClientResponse(ResourcePackClientResponsePacket $packet) : bool{
|
||||
return $this->player->handleResourcePackClientResponse($packet);
|
||||
}
|
||||
|
||||
public function handleText(TextPacket $packet) : bool{
|
||||
if($packet->type === TextPacket::TYPE_CHAT){
|
||||
return $this->player->chat($packet->message);
|
||||
@ -166,7 +104,7 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
}
|
||||
|
||||
public function handleMobEquipment(MobEquipmentPacket $packet) : bool{
|
||||
return $this->player->handleMobEquipment($packet);
|
||||
return $this->player->equipItem($packet->hotbarSlot);
|
||||
}
|
||||
|
||||
public function handleMobArmorEquipment(MobArmorEquipmentPacket $packet) : bool{
|
||||
@ -174,11 +112,11 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
}
|
||||
|
||||
public function handleInteract(InteractPacket $packet) : bool{
|
||||
return $this->player->handleInteract($packet);
|
||||
return false; //TODO
|
||||
}
|
||||
|
||||
public function handleBlockPickRequest(BlockPickRequestPacket $packet) : bool{
|
||||
return $this->player->handleBlockPickRequest($packet);
|
||||
return $this->player->pickBlock(new Vector3($packet->blockX, $packet->blockY, $packet->blockZ), $packet->addUserData);
|
||||
}
|
||||
|
||||
public function handleEntityPickRequest(EntityPickRequestPacket $packet) : bool{
|
||||
@ -186,7 +124,58 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
}
|
||||
|
||||
public function handlePlayerAction(PlayerActionPacket $packet) : bool{
|
||||
return $this->player->handlePlayerAction($packet);
|
||||
$pos = new Vector3($packet->x, $packet->y, $packet->z);
|
||||
|
||||
switch($packet->action){
|
||||
case PlayerActionPacket::ACTION_START_BREAK:
|
||||
$this->player->startBreakBlock($pos, $packet->face);
|
||||
|
||||
break;
|
||||
|
||||
case PlayerActionPacket::ACTION_ABORT_BREAK:
|
||||
case PlayerActionPacket::ACTION_STOP_BREAK:
|
||||
$this->player->stopBreakBlock($pos);
|
||||
break;
|
||||
case PlayerActionPacket::ACTION_START_SLEEPING:
|
||||
//unused
|
||||
break;
|
||||
case PlayerActionPacket::ACTION_STOP_SLEEPING:
|
||||
$this->player->stopSleep();
|
||||
break;
|
||||
case PlayerActionPacket::ACTION_JUMP:
|
||||
$this->player->jump();
|
||||
return true;
|
||||
case PlayerActionPacket::ACTION_START_SPRINT:
|
||||
$this->player->toggleSprint(true);
|
||||
return true;
|
||||
case PlayerActionPacket::ACTION_STOP_SPRINT:
|
||||
$this->player->toggleSprint(false);
|
||||
return true;
|
||||
case PlayerActionPacket::ACTION_START_SNEAK:
|
||||
$this->player->toggleSneak(true);
|
||||
return true;
|
||||
case PlayerActionPacket::ACTION_STOP_SNEAK:
|
||||
$this->player->toggleSneak(false);
|
||||
return true;
|
||||
case PlayerActionPacket::ACTION_START_GLIDE:
|
||||
case PlayerActionPacket::ACTION_STOP_GLIDE:
|
||||
break; //TODO
|
||||
case PlayerActionPacket::ACTION_CONTINUE_BREAK:
|
||||
$this->player->continueBreakBlock($pos, $packet->face);
|
||||
break;
|
||||
case PlayerActionPacket::ACTION_START_SWIMMING:
|
||||
break; //TODO
|
||||
case PlayerActionPacket::ACTION_STOP_SWIMMING:
|
||||
//TODO: handle this when it doesn't spam every damn tick (yet another spam bug!!)
|
||||
break;
|
||||
default:
|
||||
$this->player->getServer()->getLogger()->debug("Unhandled/unknown player action type " . $packet->action . " from " . $this->player->getName());
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->player->setUsingItem(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleEntityFall(EntityFallPacket $packet) : bool{
|
||||
@ -194,11 +183,11 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
}
|
||||
|
||||
public function handleAnimate(AnimatePacket $packet) : bool{
|
||||
return $this->player->handleAnimate($packet);
|
||||
return $this->player->animate($packet->action);
|
||||
}
|
||||
|
||||
public function handleContainerClose(ContainerClosePacket $packet) : bool{
|
||||
return $this->player->handleContainerClose($packet);
|
||||
return $this->player->doCloseWindow($packet->windowId);
|
||||
}
|
||||
|
||||
public function handlePlayerHotbar(PlayerHotbarPacket $packet) : bool{
|
||||
@ -222,7 +211,12 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
}
|
||||
|
||||
public function handleSetPlayerGameType(SetPlayerGameTypePacket $packet) : bool{
|
||||
return $this->player->handleSetPlayerGameType($packet);
|
||||
if($packet->gamemode !== $this->player->getGamemode()){
|
||||
//Set this back to default. TODO: handle this properly
|
||||
$this->player->sendGamemode();
|
||||
$this->player->sendSettings();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleSpawnExperienceOrb(SpawnExperienceOrbPacket $packet) : bool{
|
||||
@ -259,14 +253,14 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
return false; //TODO
|
||||
}
|
||||
|
||||
public function handleResourcePackChunkRequest(ResourcePackChunkRequestPacket $packet) : bool{
|
||||
return $this->player->handleResourcePackChunkRequest($packet);
|
||||
}
|
||||
|
||||
public function handlePlayerSkin(PlayerSkinPacket $packet) : bool{
|
||||
return $this->player->changeSkin($packet->skin, $packet->newSkinName, $packet->oldSkinName);
|
||||
}
|
||||
|
||||
public function handleSubClientLogin(SubClientLoginPacket $packet) : bool{
|
||||
return false; //TODO
|
||||
}
|
||||
|
||||
public function handleBookEdit(BookEditPacket $packet) : bool{
|
||||
return $this->player->handleBookEdit($packet);
|
||||
}
|
||||
@ -278,4 +272,12 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
public function handleServerSettingsRequest(ServerSettingsRequestPacket $packet) : bool{
|
||||
return false; //TODO: GUI stuff
|
||||
}
|
||||
|
||||
public function handleLabTable(LabTablePacket $packet) : bool{
|
||||
return false; //TODO
|
||||
}
|
||||
|
||||
public function handleSetLocalPlayerAsInitialized(SetLocalPlayerAsInitializedPacket $packet) : bool{
|
||||
return false; //TODO
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class AddBehaviorTreePacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ADD_BEHAVIOR_TREE_PACKET;
|
||||
@ -41,7 +41,7 @@ class AddBehaviorTreePacket extends DataPacket{
|
||||
$this->putString($this->behaviorTreeJson);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAddBehaviorTree($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleAddBehaviorTree($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\entity\Attribute;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\EntityLink;
|
||||
|
||||
class AddEntityPacket extends DataPacket{
|
||||
@ -117,7 +117,7 @@ class AddEntityPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAddEntity($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleAddEntity($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class AddHangingEntityPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ADD_HANGING_ENTITY_PACKET;
|
||||
@ -57,7 +57,7 @@ class AddHangingEntityPacket extends DataPacket{
|
||||
$this->putVarInt($this->direction);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAddHangingEntity($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleAddHangingEntity($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class AddItemEntityPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ADD_ITEM_ENTITY_PACKET;
|
||||
@ -67,7 +67,7 @@ class AddItemEntityPacket extends DataPacket{
|
||||
$this->putBool($this->isFromFishing);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAddItemEntity($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleAddItemEntity($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class AddPaintingPacket extends AddHangingEntityPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ADD_PAINTING_PACKET;
|
||||
@ -44,7 +44,7 @@ class AddPaintingPacket extends AddHangingEntityPacket{
|
||||
$this->putString($this->title);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAddPainting($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleAddPainting($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\EntityLink;
|
||||
use pocketmine\utils\UUID;
|
||||
|
||||
@ -135,7 +135,7 @@ class AddPlayerPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAddPlayer($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleAddPlayer($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerPermissions;
|
||||
|
||||
class AdventureSettingsPacket extends DataPacket{
|
||||
@ -116,7 +116,7 @@ class AdventureSettingsPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAdventureSettings($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleAdventureSettings($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class AnimatePacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ANIMATE_PACKET;
|
||||
@ -59,7 +59,7 @@ class AnimatePacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAnimate($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleAnimate($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\CommandData;
|
||||
use pocketmine\network\mcpe\protocol\types\CommandEnum;
|
||||
use pocketmine\network\mcpe\protocol\types\CommandParameter;
|
||||
@ -336,7 +336,7 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAvailableCommands($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleAvailableCommands($this);
|
||||
}
|
||||
}
|
||||
|
@ -1,122 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkBinaryStream;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
#ifndef COMPILE
|
||||
use pocketmine\utils\Binary;
|
||||
#endif
|
||||
|
||||
class BatchPacket extends DataPacket{
|
||||
public const NETWORK_ID = 0xfe;
|
||||
|
||||
/** @var string */
|
||||
public $payload = "";
|
||||
/** @var int */
|
||||
protected $compressionLevel = 7;
|
||||
|
||||
public function canBeBatched() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function canBeSentBeforeLogin() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function decodeHeader() : void{
|
||||
$pid = $this->getByte();
|
||||
assert($pid === static::NETWORK_ID);
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$data = $this->getRemaining();
|
||||
try{
|
||||
$this->payload = zlib_decode($data, 1024 * 1024 * 64); //Max 64MB
|
||||
}catch(\ErrorException $e){ //zlib decode error
|
||||
$this->payload = "";
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodeHeader() : void{
|
||||
$this->putByte(static::NETWORK_ID);
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->put(zlib_encode($this->payload, ZLIB_ENCODING_DEFLATE, $this->compressionLevel));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataPacket $packet
|
||||
*/
|
||||
public function addPacket(DataPacket $packet) : void{
|
||||
if(!$packet->canBeBatched()){
|
||||
throw new \InvalidArgumentException(get_class($packet) . " cannot be put inside a BatchPacket");
|
||||
}
|
||||
if(!$packet->isEncoded){
|
||||
$packet->encode();
|
||||
}
|
||||
|
||||
$this->payload .= Binary::writeUnsignedVarInt(strlen($packet->buffer)) . $packet->buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Generator
|
||||
*/
|
||||
public function getPackets() : \Generator{
|
||||
$stream = new NetworkBinaryStream($this->payload);
|
||||
while(!$stream->feof()){
|
||||
yield $stream->getString();
|
||||
}
|
||||
}
|
||||
|
||||
public function getCompressionLevel() : int{
|
||||
return $this->compressionLevel;
|
||||
}
|
||||
|
||||
public function setCompressionLevel(int $level) : void{
|
||||
$this->compressionLevel = $level;
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
if($this->payload === ""){
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach($this->getPackets() as $buf){
|
||||
$pk = PacketPool::getPacket($buf);
|
||||
|
||||
if(!$pk->canBeBatched()){
|
||||
throw new \InvalidArgumentException("Received invalid " . get_class($pk) . " inside BatchPacket");
|
||||
}
|
||||
|
||||
$session->handleDataPacket($pk);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class BlockEntityDataPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::BLOCK_ENTITY_DATA_PACKET;
|
||||
@ -50,7 +50,7 @@ class BlockEntityDataPacket extends DataPacket{
|
||||
$this->put($this->namedtag);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleBlockEntityData($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleBlockEntityData($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class BlockEventPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::BLOCK_EVENT_PACKET;
|
||||
@ -54,7 +54,7 @@ class BlockEventPacket extends DataPacket{
|
||||
$this->putVarInt($this->eventData);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleBlockEvent($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleBlockEvent($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class BlockPickRequestPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::BLOCK_PICK_REQUEST_PACKET;
|
||||
@ -55,7 +55,7 @@ class BlockPickRequestPacket extends DataPacket{
|
||||
$this->putByte($this->hotbarSlot);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleBlockPickRequest($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleBlockPickRequest($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class BookEditPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::BOOK_EDIT_PACKET;
|
||||
@ -113,7 +113,7 @@ class BookEditPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleBookEdit($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleBookEdit($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class BossEventPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::BOSS_EVENT_PACKET;
|
||||
@ -126,7 +126,7 @@ class BossEventPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleBossEvent($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleBossEvent($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class CameraPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CAMERA_PACKET;
|
||||
@ -45,7 +45,7 @@ class CameraPacket extends DataPacket{
|
||||
$this->putEntityUniqueId($this->playerUniqueId);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleCamera($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleCamera($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class ChangeDimensionPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CHANGE_DIMENSION_PACKET;
|
||||
@ -51,7 +51,7 @@ class ChangeDimensionPacket extends DataPacket{
|
||||
$this->putBool($this->respawn);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleChangeDimension($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleChangeDimension($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class ChunkRadiusUpdatedPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CHUNK_RADIUS_UPDATED_PACKET;
|
||||
@ -42,7 +42,7 @@ class ChunkRadiusUpdatedPacket extends DataPacket{
|
||||
$this->putVarInt($this->radius);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleChunkRadiusUpdated($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleChunkRadiusUpdated($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class ClientToServerHandshakePacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CLIENT_TO_SERVER_HANDSHAKE_PACKET;
|
||||
@ -43,7 +43,7 @@ class ClientToServerHandshakePacket extends DataPacket{
|
||||
//No payload
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleClientToServerHandshake($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleClientToServerHandshake($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\DimensionIds;
|
||||
use pocketmine\network\mcpe\protocol\types\MapTrackedObject;
|
||||
use pocketmine\utils\Color;
|
||||
@ -194,7 +194,7 @@ class ClientboundMapItemDataPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleClientboundMapItemData($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleClientboundMapItemData($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class CommandBlockUpdatePacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::COMMAND_BLOCK_UPDATE_PACKET;
|
||||
@ -99,7 +99,7 @@ class CommandBlockUpdatePacket extends DataPacket{
|
||||
$this->putBool($this->shouldTrackOutput);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleCommandBlockUpdate($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleCommandBlockUpdate($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\CommandOriginData;
|
||||
use pocketmine\network\mcpe\protocol\types\CommandOutputMessage;
|
||||
|
||||
@ -95,7 +95,7 @@ class CommandOutputPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleCommandOutput($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleCommandOutput($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\CommandOriginData;
|
||||
|
||||
class CommandRequestPacket extends DataPacket{
|
||||
@ -50,7 +50,7 @@ class CommandRequestPacket extends DataPacket{
|
||||
$this->putBool($this->isInternal);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleCommandRequest($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleCommandRequest($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class ContainerClosePacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CONTAINER_CLOSE_PACKET;
|
||||
@ -42,7 +42,7 @@ class ContainerClosePacket extends DataPacket{
|
||||
$this->putByte($this->windowId);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleContainerClose($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleContainerClose($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class ContainerOpenPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CONTAINER_OPEN_PACKET;
|
||||
@ -58,7 +58,7 @@ class ContainerOpenPacket extends DataPacket{
|
||||
$this->putEntityUniqueId($this->entityUniqueId);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleContainerOpen($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleContainerOpen($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class ContainerSetDataPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CONTAINER_SET_DATA_PACKET;
|
||||
@ -60,7 +60,7 @@ class ContainerSetDataPacket extends DataPacket{
|
||||
$this->putVarInt($this->value);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleContainerSetData($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleContainerSetData($this);
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ use pocketmine\inventory\FurnaceRecipe;
|
||||
use pocketmine\inventory\ShapedRecipe;
|
||||
use pocketmine\inventory\ShapelessRecipe;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\network\mcpe\NetworkBinaryStream;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class CraftingDataPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CRAFTING_DATA_PACKET;
|
||||
@ -215,7 +215,7 @@ class CraftingDataPacket extends DataPacket{
|
||||
$this->putBool($this->cleanRecipes);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleCraftingData($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleCraftingData($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\utils\UUID;
|
||||
|
||||
class CraftingEventPacket extends DataPacket{
|
||||
@ -81,7 +81,7 @@ class CraftingEventPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleCraftingEvent($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleCraftingEvent($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\network\mcpe\NetworkBinaryStream;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\utils\Utils;
|
||||
|
||||
abstract class DataPacket extends NetworkBinaryStream{
|
||||
@ -49,10 +49,6 @@ abstract class DataPacket extends NetworkBinaryStream{
|
||||
return (new \ReflectionClass($this))->getShortName();
|
||||
}
|
||||
|
||||
public function canBeBatched() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canBeSentBeforeLogin() : bool{
|
||||
return false;
|
||||
}
|
||||
@ -109,16 +105,20 @@ abstract class DataPacket extends NetworkBinaryStream{
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs handling for this packet. Usually you'll want an appropriately named method in the NetworkSession for this.
|
||||
* Performs handling for this packet. Usually you'll want an appropriately named method in the session handler for
|
||||
* this.
|
||||
*
|
||||
* This method returns a bool to indicate whether the packet was handled or not. If the packet was unhandled, a debug message will be logged with a hexdump of the packet.
|
||||
* Typically this method returns the return value of the handler in the supplied NetworkSession. See other packets for examples how to implement this.
|
||||
* This method returns a bool to indicate whether the packet was handled or not. If the packet was unhandled, a
|
||||
* debug message will be logged with a hexdump of the packet.
|
||||
*
|
||||
* @param NetworkSession $session
|
||||
* Typically this method returns the return value of the handler in the supplied SessionHandler. See other packets
|
||||
* for examples how to implement this.
|
||||
*
|
||||
* @param SessionHandler $handler
|
||||
*
|
||||
* @return bool true if the packet was handled successfully, false if not.
|
||||
*/
|
||||
abstract public function handle(NetworkSession $session) : bool;
|
||||
abstract public function handle(SessionHandler $handler) : bool;
|
||||
|
||||
public function clean(){
|
||||
$this->buffer = null;
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class DisconnectPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::DISCONNECT_PACKET;
|
||||
@ -54,7 +54,7 @@ class DisconnectPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleDisconnect($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleDisconnect($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class EntityEventPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ENTITY_EVENT_PACKET;
|
||||
@ -102,7 +102,7 @@ class EntityEventPacket extends DataPacket{
|
||||
$this->putVarInt($this->data);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleEntityEvent($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleEntityEvent($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class EntityFallPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ENTITY_FALL_PACKET;
|
||||
@ -50,7 +50,7 @@ class EntityFallPacket extends DataPacket{
|
||||
$this->putBool($this->isInVoid);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleEntityFall($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleEntityFall($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class EntityPickRequestPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ENTITY_PICK_REQUEST_PACKET;
|
||||
@ -45,7 +45,7 @@ class EntityPickRequestPacket extends DataPacket{
|
||||
$this->putByte($this->hotbarSlot);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleEntityPickRequest($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleEntityPickRequest($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class EventPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::EVENT_PACKET;
|
||||
@ -64,7 +64,7 @@ class EventPacket extends DataPacket{
|
||||
//TODO: also nice confusing mess
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleEvent($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleEvent($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class ExplodePacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::EXPLODE_PACKET;
|
||||
@ -66,7 +66,7 @@ class ExplodePacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleExplode($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleExplode($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class FullChunkDataPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::FULL_CHUNK_DATA_PACKET;
|
||||
@ -50,7 +50,7 @@ class FullChunkDataPacket extends DataPacket{
|
||||
$this->putString($this->data);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleFullChunkData($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleFullChunkData($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class GameRulesChangedPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::GAME_RULES_CHANGED_PACKET;
|
||||
@ -41,7 +41,7 @@ class GameRulesChangedPacket extends DataPacket{
|
||||
$this->putGameRules($this->gameRules);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleGameRulesChanged($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleGameRulesChanged($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class GuiDataPickItemPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::GUI_DATA_PICK_ITEM_PACKET;
|
||||
@ -41,7 +41,7 @@ class GuiDataPickItemPacket extends DataPacket{
|
||||
$this->putLInt($this->hotbarSlot);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleGuiDataPickItem($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleGuiDataPickItem($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class HurtArmorPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::HURT_ARMOR_PACKET;
|
||||
@ -42,7 +42,7 @@ class HurtArmorPacket extends DataPacket{
|
||||
$this->putVarInt($this->health);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleHurtArmor($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleHurtArmor($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class InteractPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::INTERACT_PACKET;
|
||||
@ -71,7 +71,7 @@ class InteractPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleInteract($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleInteract($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class InventoryContentPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::INVENTORY_CONTENT_PACKET;
|
||||
@ -52,7 +52,7 @@ class InventoryContentPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleInventoryContent($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleInventoryContent($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class InventorySlotPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::INVENTORY_SLOT_PACKET;
|
||||
@ -50,7 +50,7 @@ class InventorySlotPacket extends DataPacket{
|
||||
$this->putSlot($this->item);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleInventorySlot($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleInventorySlot($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\NetworkInventoryAction;
|
||||
|
||||
class InventoryTransactionPacket extends DataPacket{
|
||||
@ -151,7 +151,7 @@ class InventoryTransactionPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleInventoryTransaction($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleInventoryTransaction($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class ItemFrameDropItemPacket extends DataPacket{
|
||||
|
||||
@ -46,7 +46,7 @@ class ItemFrameDropItemPacket extends DataPacket{
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleItemFrameDropItem($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleItemFrameDropItem($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class LabTablePacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::LAB_TABLE_PACKET;
|
||||
@ -55,7 +55,7 @@ class LabTablePacket extends DataPacket{
|
||||
$this->putByte($this->reactionType);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleLabTable($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleLabTable($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class LevelEventPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::LEVEL_EVENT_PACKET;
|
||||
@ -130,7 +130,7 @@ class LevelEventPacket extends DataPacket{
|
||||
$this->putVarInt($this->data);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleLevelEvent($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleLevelEvent($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class LevelSoundEventPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::LEVEL_SOUND_EVENT_PACKET;
|
||||
@ -275,7 +275,7 @@ class LevelSoundEventPacket extends DataPacket{
|
||||
$this->putBool($this->disableRelativeVolume);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleLevelSoundEvent($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleLevelSoundEvent($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\entity\Skin;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\utils\BinaryStream;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use pocketmine\utils\Utils;
|
||||
@ -52,6 +53,8 @@ class LoginPacket extends DataPacket{
|
||||
public $serverAddress;
|
||||
/** @var string */
|
||||
public $locale;
|
||||
/** @var Skin|null */
|
||||
public $skin;
|
||||
|
||||
/** @var array (the "chain" index contains one or more JWTs) */
|
||||
public $chainData = [];
|
||||
@ -136,14 +139,22 @@ class LoginPacket extends DataPacket{
|
||||
$this->clientId = $this->clientData["ClientRandomId"] ?? null;
|
||||
$this->serverAddress = $this->clientData["ServerAddress"] ?? null;
|
||||
|
||||
$this->locale = $this->clientData["LanguageCode"] ?? null;
|
||||
$this->locale = $this->clientData["LanguageCode"] ?? "en_US";
|
||||
|
||||
$this->skin = new Skin(
|
||||
$this->clientData["SkinId"] ?? "",
|
||||
base64_decode($this->clientData["SkinData"] ?? ""),
|
||||
base64_decode($this->clientData["CapeData"] ?? ""),
|
||||
$this->clientData["SkinGeometryName"] ?? "",
|
||||
base64_decode($this->clientData["SkinGeometry"] ?? "")
|
||||
);
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
//TODO
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleLogin($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleLogin($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class MapInfoRequestPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MAP_INFO_REQUEST_PACKET;
|
||||
@ -43,7 +43,7 @@ class MapInfoRequestPacket extends DataPacket{
|
||||
$this->putEntityUniqueId($this->mapId);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleMapInfoRequest($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleMapInfoRequest($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class MobArmorEquipmentPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET;
|
||||
@ -51,7 +51,7 @@ class MobArmorEquipmentPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleMobArmorEquipment($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleMobArmorEquipment($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class MobEffectPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MOB_EFFECT_PACKET;
|
||||
@ -66,7 +66,7 @@ class MobEffectPacket extends DataPacket{
|
||||
$this->putVarInt($this->duration);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleMobEffect($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleMobEffect($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class MobEquipmentPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MOB_EQUIPMENT_PACKET;
|
||||
@ -59,7 +59,7 @@ class MobEquipmentPacket extends DataPacket{
|
||||
$this->putByte($this->windowId);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleMobEquipment($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleMobEquipment($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class ModalFormRequestPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MODAL_FORM_REQUEST_PACKET;
|
||||
@ -45,7 +45,7 @@ class ModalFormRequestPacket extends DataPacket{
|
||||
$this->putString($this->formData);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleModalFormRequest($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleModalFormRequest($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class ModalFormResponsePacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MODAL_FORM_RESPONSE_PACKET;
|
||||
@ -45,7 +45,7 @@ class ModalFormResponsePacket extends DataPacket{
|
||||
$this->putString($this->formData);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleModalFormResponse($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleModalFormResponse($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class MoveEntityAbsolutePacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MOVE_ENTITY_ABSOLUTE_PACKET;
|
||||
@ -66,7 +66,7 @@ class MoveEntityAbsolutePacket extends DataPacket{
|
||||
$this->putByteRotation($this->zRot);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleMoveEntityAbsolute($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleMoveEntityAbsolute($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class MoveEntityDeltaPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MOVE_ENTITY_DELTA_PACKET;
|
||||
@ -98,7 +98,7 @@ class MoveEntityDeltaPacket extends DataPacket{
|
||||
$this->maybeWriteRotation(self::FLAG_HAS_ROT_Z, $this->zRot);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleMoveEntityDelta($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleMoveEntityDelta($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class MovePlayerPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MOVE_PLAYER_PACKET;
|
||||
@ -88,7 +88,7 @@ class MovePlayerPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleMovePlayer($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleMovePlayer($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class NpcRequestPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::NPC_REQUEST_PACKET;
|
||||
@ -53,7 +53,7 @@ class NpcRequestPacket extends DataPacket{
|
||||
$this->putByte($this->actionType);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleNpcRequest($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleNpcRequest($this);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\utils\Binary;
|
||||
|
||||
class PacketPool{
|
||||
/** @var \SplFixedArray<DataPacket> */
|
||||
protected static $pool = null;
|
||||
@ -30,7 +32,6 @@ class PacketPool{
|
||||
public static function init() : void{
|
||||
static::$pool = new \SplFixedArray(256);
|
||||
|
||||
//Normal packets
|
||||
static::registerPacket(new LoginPacket());
|
||||
static::registerPacket(new PlayStatusPacket());
|
||||
static::registerPacket(new ServerToClientHandshakePacket());
|
||||
@ -143,8 +144,6 @@ class PacketPool{
|
||||
static::registerPacket(new UpdateBlockSyncedPacket());
|
||||
static::registerPacket(new MoveEntityDeltaPacket());
|
||||
static::registerPacket(new SetLocalPlayerAsInitializedPacket());
|
||||
|
||||
static::registerPacket(new BatchPacket());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,8 +166,9 @@ class PacketPool{
|
||||
* @return DataPacket
|
||||
*/
|
||||
public static function getPacket(string $buffer) : DataPacket{
|
||||
$pk = static::getPacketById(ord($buffer{0}));
|
||||
$pk->setBuffer($buffer);
|
||||
$offset = 0;
|
||||
$pk = static::getPacketById(Binary::readUnsignedVarInt($buffer, $offset));
|
||||
$pk->setBuffer($buffer, $offset);
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class PhotoTransferPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::PHOTO_TRANSFER_PACKET;
|
||||
@ -49,7 +49,7 @@ class PhotoTransferPacket extends DataPacket{
|
||||
$this->putString($this->bookId);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handlePhotoTransfer($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handlePhotoTransfer($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class PlaySoundPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::PLAY_SOUND_PACKET;
|
||||
@ -62,7 +62,7 @@ class PlaySoundPacket extends DataPacket{
|
||||
$this->putLFloat($this->pitch);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handlePlaySound($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handlePlaySound($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class PlayStatusPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::PLAY_STATUS_PACKET;
|
||||
@ -69,7 +69,7 @@ class PlayStatusPacket extends DataPacket{
|
||||
$this->putInt($this->status);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handlePlayStatus($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handlePlayStatus($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class PlayerActionPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::PLAYER_ACTION_PACKET;
|
||||
@ -84,7 +84,7 @@ class PlayerActionPacket extends DataPacket{
|
||||
$this->putVarInt($this->face);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handlePlayerAction($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handlePlayerAction($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\ContainerIds;
|
||||
|
||||
/**
|
||||
@ -53,7 +53,7 @@ class PlayerHotbarPacket extends DataPacket{
|
||||
$this->putBool($this->selectHotbarSlot);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handlePlayerHotbar($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handlePlayerHotbar($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class PlayerInputPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::PLAYER_INPUT_PACKET;
|
||||
@ -54,7 +54,7 @@ class PlayerInputPacket extends DataPacket{
|
||||
$this->putBool($this->sneaking);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handlePlayerInput($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handlePlayerInput($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
|
||||
use pocketmine\entity\Skin;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerListEntry;
|
||||
|
||||
class PlayerListPacket extends DataPacket{
|
||||
@ -105,7 +105,7 @@ class PlayerListPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handlePlayerList($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handlePlayerList($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\entity\Skin;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\utils\UUID;
|
||||
|
||||
class PlayerSkinPacket extends DataPacket{
|
||||
@ -68,7 +68,7 @@ class PlayerSkinPacket extends DataPacket{
|
||||
$this->putString($this->skin->getGeometryData());
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handlePlayerSkin($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handlePlayerSkin($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class PurchaseReceiptPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::PURCHASE_RECEIPT_PACKET;
|
||||
@ -47,7 +47,7 @@ class PurchaseReceiptPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handlePurchaseReceipt($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handlePurchaseReceipt($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class RemoveEntityPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::REMOVE_ENTITY_PACKET;
|
||||
@ -42,7 +42,7 @@ class RemoveEntityPacket extends DataPacket{
|
||||
$this->putEntityUniqueId($this->entityUniqueId);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleRemoveEntity($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleRemoveEntity($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class RemoveObjectivePacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::REMOVE_OBJECTIVE_PACKET;
|
||||
@ -41,7 +41,7 @@ class RemoveObjectivePacket extends DataPacket{
|
||||
$this->putString($this->objectiveName);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleRemoveObjective($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleRemoveObjective($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class RequestChunkRadiusPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET;
|
||||
@ -42,7 +42,7 @@ class RequestChunkRadiusPacket extends DataPacket{
|
||||
$this->putVarInt($this->radius);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleRequestChunkRadius($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleRequestChunkRadius($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class ResourcePackChunkDataPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_CHUNK_DATA_PACKET;
|
||||
@ -56,7 +56,7 @@ class ResourcePackChunkDataPacket extends DataPacket{
|
||||
$this->put($this->data);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleResourcePackChunkData($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleResourcePackChunkData($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class ResourcePackChunkRequestPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_CHUNK_REQUEST_PACKET;
|
||||
@ -47,7 +47,7 @@ class ResourcePackChunkRequestPacket extends DataPacket{
|
||||
$this->putLInt($this->chunkIndex);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleResourcePackChunkRequest($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleResourcePackChunkRequest($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class ResourcePackClientResponsePacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_CLIENT_RESPONSE_PACKET;
|
||||
@ -57,7 +57,7 @@ class ResourcePackClientResponsePacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleResourcePackClientResponse($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleResourcePackClientResponse($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class ResourcePackDataInfoPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_DATA_INFO_PACKET;
|
||||
@ -59,7 +59,7 @@ class ResourcePackDataInfoPacket extends DataPacket{
|
||||
$this->putString($this->sha256);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleResourcePackDataInfo($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleResourcePackDataInfo($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\resourcepacks\ResourcePack;
|
||||
|
||||
class ResourcePackStackPacket extends DataPacket{
|
||||
@ -76,7 +76,7 @@ class ResourcePackStackPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleResourcePackStack($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleResourcePackStack($this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
use pocketmine\resourcepacks\ResourcePack;
|
||||
|
||||
class ResourcePacksInfoPacket extends DataPacket{
|
||||
@ -81,7 +81,7 @@ class ResourcePacksInfoPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleResourcePacksInfo($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleResourcePacksInfo($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class RespawnPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::RESPAWN_PACKET;
|
||||
@ -43,7 +43,7 @@ class RespawnPacket extends DataPacket{
|
||||
$this->putVector3($this->position);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleRespawn($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleRespawn($this);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class RiderJumpPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::RIDER_JUMP_PACKET;
|
||||
@ -43,7 +43,7 @@ class RiderJumpPacket extends DataPacket{
|
||||
$this->putVarInt($this->jumpStrength);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleRiderJump($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleRiderJump($this);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\handler\SessionHandler;
|
||||
|
||||
class ServerSettingsRequestPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::SERVER_SETTINGS_REQUEST_PACKET;
|
||||
@ -38,7 +38,7 @@ class ServerSettingsRequestPacket extends DataPacket{
|
||||
//No payload
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleServerSettingsRequest($this);
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleServerSettingsRequest($this);
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user