diff --git a/.travis.yml b/.travis.yml index 2525a1f80..dcc2e1298 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ before_script: - echo | pecl install channel://pecl.php.net/yaml-2.0.4 - git clone https://github.com/pmmp/pthreads.git - cd pthreads - - git checkout 6ca019c58b4fa09ee2ff490f2444e34bef0773d0 + - git checkout 1b7da492b944146fa9680f6399bd9c6c6c6095e0 - phpize - ./configure - make diff --git a/build/php b/build/php index 8666ae5ad..185d74199 160000 --- a/build/php +++ b/build/php @@ -1 +1 @@ -Subproject commit 8666ae5add7a8b5213d68b491ebf0de211998cc9 +Subproject commit 185d7419914005530298bd5e069449bdf4c0be56 diff --git a/phpstan.neon b/phpstan.neon index f5178b81c..eeae576fe 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,6 +2,9 @@ parameters: level: 1 + autoload_files: + - tests/phpstan/bootstrap.php + - src/pocketmine/PocketMine.php paths: - src reportUnmatchedIgnoredErrors: false #no other way to silence platform-specific non-warnings @@ -10,61 +13,6 @@ parameters: message: "#^pocketmine\\\\Player\\:\\:__construct\\(\\) does not call parent constructor from pocketmine\\\\entity\\\\Human\\.$#" path: src/pocketmine/Player.php - - - message: "#^Function pocketmine\\\\critical_error not found while trying to analyse it \\- autoloading is probably not configured properly\\.$#" - count: 1 - path: src/pocketmine/PocketMine.php - - - - message: "#^Function pocketmine\\\\check_platform_dependencies not found while trying to analyse it \\- autoloading is probably not configured properly\\.$#" - count: 1 - path: src/pocketmine/PocketMine.php - - - - message: "#^Function pocketmine\\\\emit_performance_warnings not found while trying to analyse it \\- autoloading is probably not configured properly\\.$#" - count: 1 - path: src/pocketmine/PocketMine.php - - - - message: "#^Function pocketmine\\\\set_ini_entries not found while trying to analyse it \\- autoloading is probably not configured properly\\.$#" - count: 1 - path: src/pocketmine/PocketMine.php - - - - message: "#^Function pocketmine\\\\server not found while trying to analyse it \\- autoloading is probably not configured properly\\.$#" - count: 1 - path: src/pocketmine/PocketMine.php - - - - message: "#^Function check_platform_dependencies not found\\.$#" - count: 1 - path: src/pocketmine/PocketMine.php - - - - message: "#^Function critical_error not found\\.$#" - count: 6 - path: src/pocketmine/PocketMine.php - - - - message: "#^Function set_ini_entries not found\\.$#" - count: 1 - path: src/pocketmine/PocketMine.php - - - - message: "#^Function emit_performance_warnings not found\\.$#" - count: 1 - path: src/pocketmine/PocketMine.php - - - - message: "#^Function pocketmine\\\\server not found\\.$#" - count: 1 - path: src/pocketmine/PocketMine.php - - - - message: "#^Constant MIN_PHP_VERSION not found\\.$#" - count: 2 - path: src/pocketmine/PocketMine.php - - message: "#^pocketmine\\\\block\\\\[A-Za-z\\d]+\\:\\:__construct\\(\\) does not call parent constructor from pocketmine\\\\block\\\\Block\\.$#" path: src/pocketmine/block diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index bf01d54fa..bf3912e9e 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -291,5 +291,7 @@ namespace pocketmine { exit($exitCode); } - \pocketmine\server(); + if(!defined('pocketmine\_PHPSTAN_ANALYSIS')){ + \pocketmine\server(); + } } diff --git a/src/pocketmine/network/mcpe/NetworkBinaryStream.php b/src/pocketmine/network/mcpe/NetworkBinaryStream.php index 7d969dd0d..890a57a19 100644 --- a/src/pocketmine/network/mcpe/NetworkBinaryStream.php +++ b/src/pocketmine/network/mcpe/NetworkBinaryStream.php @@ -437,7 +437,7 @@ class NetworkBinaryStream extends BinaryStream{ } /** - * Writes an EntityUniqueID + * Writes an EntityRuntimeID * * @param int $eid */ diff --git a/src/pocketmine/network/mcpe/NetworkSession.php b/src/pocketmine/network/mcpe/NetworkSession.php index 207d0c6ca..19a5a14ba 100644 --- a/src/pocketmine/network/mcpe/NetworkSession.php +++ b/src/pocketmine/network/mcpe/NetworkSession.php @@ -34,6 +34,7 @@ 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\AnvilDamagePacket; use pocketmine\network\mcpe\protocol\AutomationClientConnectPacket; use pocketmine\network\mcpe\protocol\AvailableActorIdentifiersPacket; use pocketmine\network\mcpe\protocol\AvailableCommandsPacket; @@ -62,6 +63,8 @@ use pocketmine\network\mcpe\protocol\CraftingDataPacket; use pocketmine\network\mcpe\protocol\CraftingEventPacket; use pocketmine\network\mcpe\protocol\DataPacket; use pocketmine\network\mcpe\protocol\DisconnectPacket; +use pocketmine\network\mcpe\protocol\EducationSettingsPacket; +use pocketmine\network\mcpe\protocol\EmotePacket; use pocketmine\network\mcpe\protocol\EventPacket; use pocketmine\network\mcpe\protocol\GameRulesChangedPacket; use pocketmine\network\mcpe\protocol\GuiDataPickItemPacket; @@ -90,12 +93,15 @@ use pocketmine\network\mcpe\protocol\ModalFormResponsePacket; use pocketmine\network\mcpe\protocol\MoveActorAbsolutePacket; use pocketmine\network\mcpe\protocol\MoveActorDeltaPacket; use pocketmine\network\mcpe\protocol\MovePlayerPacket; +use pocketmine\network\mcpe\protocol\MultiplayerSettingsPacket; use pocketmine\network\mcpe\protocol\NetworkChunkPublisherUpdatePacket; +use pocketmine\network\mcpe\protocol\NetworkSettingsPacket; use pocketmine\network\mcpe\protocol\NetworkStackLatencyPacket; use pocketmine\network\mcpe\protocol\NpcRequestPacket; use pocketmine\network\mcpe\protocol\OnScreenTextureAnimationPacket; use pocketmine\network\mcpe\protocol\PhotoTransferPacket; use pocketmine\network\mcpe\protocol\PlayerActionPacket; +use pocketmine\network\mcpe\protocol\PlayerAuthInputPacket; use pocketmine\network\mcpe\protocol\PlayerHotbarPacket; use pocketmine\network\mcpe\protocol\PlayerInputPacket; use pocketmine\network\mcpe\protocol\PlayerListPacket; @@ -134,6 +140,7 @@ use pocketmine\network\mcpe\protocol\SetScoreboardIdentityPacket; use pocketmine\network\mcpe\protocol\SetScorePacket; use pocketmine\network\mcpe\protocol\SetSpawnPositionPacket; use pocketmine\network\mcpe\protocol\SetTimePacket; +use pocketmine\network\mcpe\protocol\SettingsCommandPacket; use pocketmine\network\mcpe\protocol\SetTitlePacket; use pocketmine\network\mcpe\protocol\ShowCreditsPacket; use pocketmine\network\mcpe\protocol\ShowProfilePacket; @@ -144,11 +151,12 @@ use pocketmine\network\mcpe\protocol\SpawnParticleEffectPacket; use pocketmine\network\mcpe\protocol\StartGamePacket; use pocketmine\network\mcpe\protocol\StopSoundPacket; use pocketmine\network\mcpe\protocol\StructureBlockUpdatePacket; -use pocketmine\network\mcpe\protocol\StructureTemplateDataExportRequestPacket; -use pocketmine\network\mcpe\protocol\StructureTemplateDataExportResponsePacket; +use pocketmine\network\mcpe\protocol\StructureTemplateDataRequestPacket; +use pocketmine\network\mcpe\protocol\StructureTemplateDataResponsePacket; use pocketmine\network\mcpe\protocol\SubClientLoginPacket; use pocketmine\network\mcpe\protocol\TakeItemActorPacket; use pocketmine\network\mcpe\protocol\TextPacket; +use pocketmine\network\mcpe\protocol\TickSyncPacket; use pocketmine\network\mcpe\protocol\TransferPacket; use pocketmine\network\mcpe\protocol\UpdateAttributesPacket; use pocketmine\network\mcpe\protocol\UpdateBlockPacket; @@ -247,6 +255,10 @@ abstract class NetworkSession{ return false; } + public function handleTickSync(TickSyncPacket $packet) : bool{ + return false; + } + public function handleLevelSoundEventPacketV1(LevelSoundEventPacketV1 $packet) : bool{ return false; } @@ -675,11 +687,11 @@ abstract class NetworkSession{ return false; } - public function handleStructureTemplateDataExportRequest(StructureTemplateDataExportRequestPacket $packet) : bool{ + public function handleStructureTemplateDataRequest(StructureTemplateDataRequestPacket $packet) : bool{ return false; } - public function handleStructureTemplateDataExportResponse(StructureTemplateDataExportResponsePacket $packet) : bool{ + public function handleStructureTemplateDataResponse(StructureTemplateDataResponsePacket $packet) : bool{ return false; } @@ -695,7 +707,35 @@ abstract class NetworkSession{ return false; } + public function handleEducationSettings(EducationSettingsPacket $packet) : bool{ + return false; + } + + public function handleEmote(EmotePacket $packet) : bool{ + return false; + } + + public function handleMultiplayerSettings(MultiplayerSettingsPacket $packet) : bool{ + return false; + } + + public function handleSettingsCommand(SettingsCommandPacket $packet) : bool{ + return false; + } + + public function handleAnvilDamage(AnvilDamagePacket $packet) : bool{ + return false; + } + public function handleCompletedUsingItem(CompletedUsingItemPacket $packet) : bool{ return false; } + + public function handleNetworkSettings(NetworkSettingsPacket $packet) : bool{ + return false; + } + + public function handlePlayerAuthInput(PlayerAuthInputPacket $packet) : bool{ + return false; + } } diff --git a/src/pocketmine/network/mcpe/protocol/AnvilDamagePacket.php b/src/pocketmine/network/mcpe/protocol/AnvilDamagePacket.php new file mode 100644 index 000000000..f43c596e4 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/AnvilDamagePacket.php @@ -0,0 +1,78 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class AnvilDamagePacket extends DataPacket/* implements ServerboundPacket*/{ + public const NETWORK_ID = ProtocolInfo::ANVIL_DAMAGE_PACKET; + + /** @var int */ + private $x; + /** @var int */ + private $y; + /** @var int */ + private $z; + /** @var int */ + private $damageAmount; + + public static function create(int $x, int $y, int $z, int $damageAmount) : self{ + $result = new self; + [$result->x, $result->y, $result->z] = [$x, $y, $z]; + $result->damageAmount = $damageAmount; + return $result; + } + + public function getDamageAmount() : int{ + return $this->damageAmount; + } + + public function getX() : int{ + return $this->x; + } + + public function getY() : int{ + return $this->y; + } + + public function getZ() : int{ + return $this->z; + } + + protected function decodePayload() : void{ + $this->damageAmount = $this->getByte(); + $this->getBlockPosition($this->x, $this->y, $this->z); + } + + protected function encodePayload() : void{ + $this->putByte($this->damageAmount); + $this->putBlockPosition($this->x, $this->y, $this->z); + } + + public function handle(NetworkSession $handler) : bool{ + return $handler->handleAnvilDamage($this); + } +} diff --git a/src/pocketmine/network/mcpe/protocol/DataPacket.php b/src/pocketmine/network/mcpe/protocol/DataPacket.php index 7d074d515..f2e60caa5 100644 --- a/src/pocketmine/network/mcpe/protocol/DataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/DataPacket.php @@ -143,7 +143,7 @@ abstract class DataPacket extends NetworkBinaryStream{ public function __debugInfo(){ $data = []; - foreach($this as $k => $v){ + foreach((array) $this as $k => $v){ if($k === "buffer" and is_string($v)){ $data[$k] = bin2hex($v); }elseif(is_string($v) or (is_object($v) and method_exists($v, "__toString"))){ diff --git a/src/pocketmine/network/mcpe/protocol/EducationSettingsPacket.php b/src/pocketmine/network/mcpe/protocol/EducationSettingsPacket.php new file mode 100644 index 000000000..684904bb6 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/EducationSettingsPacket.php @@ -0,0 +1,44 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class EducationSettingsPacket extends DataPacket{ + public const NETWORK_ID = ProtocolInfo::EDUCATION_SETTINGS_PACKET; + + protected function decodePayload() : void{ + //TODO + } + + protected function encodePayload() : void{ + //TODO + } + + public function handle(NetworkSession $handler) : bool{ + return $handler->handleEducationSettings($this); + } +} diff --git a/src/pocketmine/network/mcpe/protocol/EmotePacket.php b/src/pocketmine/network/mcpe/protocol/EmotePacket.php new file mode 100644 index 000000000..b973b39bd --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/EmotePacket.php @@ -0,0 +1,81 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class EmotePacket extends DataPacket/* implements ClientboundPacket, ServerboundPacket*/{ + public const NETWORK_ID = ProtocolInfo::EMOTE_PACKET; + + private const FLAG_SERVER = 1 << 0; + + /** @var int */ + private $entityRuntimeId; + /** @var string */ + private $emoteId; + /** @var int */ + private $flags; + + public static function create(int $entityRuntimeId, string $emoteId, int $flags) : self{ + $result = new self; + $result->entityRuntimeId = $entityRuntimeId; + $result->emoteId = $emoteId; + $result->flags = $flags; + return $result; + } + + /** + * TODO: we can't call this getEntityRuntimeId() because of base class collision (crap architecture, thanks Shoghi) + * @return int + */ + public function getEntityRuntimeIdField() : int{ + return $this->entityRuntimeId; + } + + public function getEmoteId() : string{ + return $this->emoteId; + } + + public function getFlags() : int{ + return $this->flags; + } + + protected function decodePayload() : void{ + $this->entityRuntimeId = $this->getEntityRuntimeId(); + $this->emoteId = $this->getString(); + $this->flags = $this->getByte(); + } + + protected function encodePayload() : void{ + $this->putEntityRuntimeId($this->entityRuntimeId); + $this->putString($this->emoteId); + $this->putByte($this->flags); + } + + public function handle(NetworkSession $handler) : bool{ + return $handler->handleEmote($this); + } +} diff --git a/src/pocketmine/network/mcpe/protocol/MultiplayerSettingsPacket.php b/src/pocketmine/network/mcpe/protocol/MultiplayerSettingsPacket.php new file mode 100644 index 000000000..28a0d9145 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/MultiplayerSettingsPacket.php @@ -0,0 +1,44 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class MultiplayerSettingsPacket extends DataPacket{ + public const NETWORK_ID = ProtocolInfo::MULTIPLAYER_SETTINGS_PACKET; + + protected function decodePayload() : void{ + //TODO + } + + protected function encodePayload() : void{ + //TODO + } + + public function handle(NetworkSession $handler) : bool{ + return $handler->handleMultiplayerSettings($this); + } +} diff --git a/src/pocketmine/network/mcpe/protocol/NetworkSettingsPacket.php b/src/pocketmine/network/mcpe/protocol/NetworkSettingsPacket.php new file mode 100644 index 000000000..f37292129 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/NetworkSettingsPacket.php @@ -0,0 +1,60 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class NetworkSettingsPacket extends DataPacket/* implements ClientboundPacket*/{ + public const NETWORK_ID = ProtocolInfo::NETWORK_SETTINGS_PACKET; + + public const COMPRESS_NOTHING = 0; + public const COMPRESS_EVERYTHING = 1; + + /** @var int */ + private $compressionThreshold; + + public static function create(int $compressionThreshold) : self{ + $result = new self; + $result->compressionThreshold = $compressionThreshold; + return $result; + } + + public function getCompressionThreshold() : int{ + return $this->compressionThreshold; + } + + protected function decodePayload() : void{ + $this->compressionThreshold = $this->getLShort(); + } + + protected function encodePayload() : void{ + $this->putLShort($this->compressionThreshold); + } + + public function handle(NetworkSession $handler) : bool{ + return $handler->handleNetworkSettings($this); + } +} diff --git a/src/pocketmine/network/mcpe/protocol/PacketPool.php b/src/pocketmine/network/mcpe/protocol/PacketPool.php index 4c9f09d9e..3ca054104 100644 --- a/src/pocketmine/network/mcpe/protocol/PacketPool.php +++ b/src/pocketmine/network/mcpe/protocol/PacketPool.php @@ -54,6 +54,7 @@ class PacketPool{ static::registerPacket(new RiderJumpPacket()); static::registerPacket(new UpdateBlockPacket()); static::registerPacket(new AddPaintingPacket()); + static::registerPacket(new TickSyncPacket()); static::registerPacket(new LevelSoundEventPacketV1()); static::registerPacket(new LevelEventPacket()); static::registerPacket(new BlockEventPacket()); @@ -161,12 +162,19 @@ class PacketPool{ static::registerPacket(new ClientCacheStatusPacket()); static::registerPacket(new OnScreenTextureAnimationPacket()); static::registerPacket(new MapCreateLockedCopyPacket()); - static::registerPacket(new StructureTemplateDataExportRequestPacket()); - static::registerPacket(new StructureTemplateDataExportResponsePacket()); + static::registerPacket(new StructureTemplateDataRequestPacket()); + static::registerPacket(new StructureTemplateDataResponsePacket()); static::registerPacket(new UpdateBlockPropertiesPacket()); static::registerPacket(new ClientCacheBlobStatusPacket()); static::registerPacket(new ClientCacheMissResponsePacket()); + static::registerPacket(new EducationSettingsPacket()); + static::registerPacket(new EmotePacket()); + static::registerPacket(new MultiplayerSettingsPacket()); + static::registerPacket(new SettingsCommandPacket()); + static::registerPacket(new AnvilDamagePacket()); static::registerPacket(new CompletedUsingItemPacket()); + static::registerPacket(new NetworkSettingsPacket()); + static::registerPacket(new PlayerAuthInputPacket()); } /** diff --git a/src/pocketmine/network/mcpe/protocol/PlayerAuthInputPacket.php b/src/pocketmine/network/mcpe/protocol/PlayerAuthInputPacket.php new file mode 100644 index 000000000..26b018f5c --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/PlayerAuthInputPacket.php @@ -0,0 +1,44 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class PlayerAuthInputPacket extends DataPacket{ + public const NETWORK_ID = ProtocolInfo::PLAYER_AUTH_INPUT_PACKET; + + protected function decodePayload() : void{ + //TODO + } + + protected function encodePayload() : void{ + //TODO + } + + public function handle(NetworkSession $handler) : bool{ + return $handler->handlePlayerAuthInput($this); + } +} diff --git a/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php b/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php index a0b459a55..242fe0695 100644 --- a/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php +++ b/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php @@ -180,8 +180,8 @@ interface ProtocolInfo{ public const CLIENT_CACHE_STATUS_PACKET = 0x81; public const ON_SCREEN_TEXTURE_ANIMATION_PACKET = 0x82; public const MAP_CREATE_LOCKED_COPY_PACKET = 0x83; - public const STRUCTURE_TEMPLATE_DATA_EXPORT_REQUEST_PACKET = 0x84; - public const STRUCTURE_TEMPLATE_DATA_EXPORT_RESPONSE_PACKET = 0x85; + public const STRUCTURE_TEMPLATE_DATA_REQUEST_PACKET = 0x84; + public const STRUCTURE_TEMPLATE_DATA_RESPONSE_PACKET = 0x85; public const UPDATE_BLOCK_PROPERTIES_PACKET = 0x86; public const CLIENT_CACHE_BLOB_STATUS_PACKET = 0x87; public const CLIENT_CACHE_MISS_RESPONSE_PACKET = 0x88; diff --git a/src/pocketmine/network/mcpe/protocol/ResourcePackStackPacket.php b/src/pocketmine/network/mcpe/protocol/ResourcePackStackPacket.php index 8ec61a229..41fd445e7 100644 --- a/src/pocketmine/network/mcpe/protocol/ResourcePackStackPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ResourcePackStackPacket.php @@ -44,6 +44,8 @@ class ResourcePackStackPacket extends DataPacket{ /** @var bool */ public $isExperimental = false; + /** @var string */ + public $baseGameVersion = ProtocolInfo::MINECRAFT_VERSION_NETWORK; protected function decodePayload(){ $this->mustAccept = $this->getBool(); @@ -62,6 +64,7 @@ class ResourcePackStackPacket extends DataPacket{ } $this->isExperimental = $this->getBool(); + $this->baseGameVersion = $this->getString(); } protected function encodePayload(){ @@ -82,6 +85,7 @@ class ResourcePackStackPacket extends DataPacket{ } $this->putBool($this->isExperimental); + $this->putString($this->baseGameVersion); } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/SettingsCommandPacket.php b/src/pocketmine/network/mcpe/protocol/SettingsCommandPacket.php new file mode 100644 index 000000000..d0ac8f5f5 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/SettingsCommandPacket.php @@ -0,0 +1,66 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class SettingsCommandPacket extends DataPacket/* implements ServerboundPacket*/{ + public const NETWORK_ID = ProtocolInfo::SETTINGS_COMMAND_PACKET; + + /** @var string */ + private $command; + /** @var bool */ + private $suppressOutput; + + public static function create(string $command, bool $suppressOutput) : self{ + $result = new self; + $result->command = $command; + $result->suppressOutput = $suppressOutput; + return $result; + } + + public function getCommand() : string{ + return $this->command; + } + + public function getSuppressOutput() : bool{ + return $this->suppressOutput; + } + + protected function decodePayload() : void{ + $this->command = $this->getString(); + $this->suppressOutput = $this->getBool(); + } + + protected function encodePayload() : void{ + $this->putString($this->command); + $this->putBool($this->suppressOutput); + } + + public function handle(NetworkSession $handler) : bool{ + return $handler->handleSettingsCommand($this); + } +} diff --git a/src/pocketmine/network/mcpe/protocol/StructureTemplateDataExportRequestPacket.php b/src/pocketmine/network/mcpe/protocol/StructureTemplateDataRequestPacket.php similarity index 92% rename from src/pocketmine/network/mcpe/protocol/StructureTemplateDataExportRequestPacket.php rename to src/pocketmine/network/mcpe/protocol/StructureTemplateDataRequestPacket.php index 6ae16cec4..ba100bb60 100644 --- a/src/pocketmine/network/mcpe/protocol/StructureTemplateDataExportRequestPacket.php +++ b/src/pocketmine/network/mcpe/protocol/StructureTemplateDataRequestPacket.php @@ -28,8 +28,8 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\protocol\types\StructureSettings; -class StructureTemplateDataExportRequestPacket extends DataPacket{ - public const NETWORK_ID = ProtocolInfo::STRUCTURE_TEMPLATE_DATA_EXPORT_REQUEST_PACKET; +class StructureTemplateDataRequestPacket extends DataPacket{ + public const NETWORK_ID = ProtocolInfo::STRUCTURE_TEMPLATE_DATA_REQUEST_PACKET; public const TYPE_ALWAYS_LOAD = 1; public const TYPE_CREATE_AND_LOAD = 2; @@ -62,6 +62,6 @@ class StructureTemplateDataExportRequestPacket extends DataPacket{ } public function handle(NetworkSession $handler) : bool{ - return $handler->handleStructureTemplateDataExportRequest($this); + return $handler->handleStructureTemplateDataRequest($this); } } diff --git a/src/pocketmine/network/mcpe/protocol/StructureTemplateDataExportResponsePacket.php b/src/pocketmine/network/mcpe/protocol/StructureTemplateDataResponsePacket.php similarity index 90% rename from src/pocketmine/network/mcpe/protocol/StructureTemplateDataExportResponsePacket.php rename to src/pocketmine/network/mcpe/protocol/StructureTemplateDataResponsePacket.php index 2ff52b116..98afaaed7 100644 --- a/src/pocketmine/network/mcpe/protocol/StructureTemplateDataExportResponsePacket.php +++ b/src/pocketmine/network/mcpe/protocol/StructureTemplateDataResponsePacket.php @@ -27,8 +27,8 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\network\mcpe\NetworkSession; -class StructureTemplateDataExportResponsePacket extends DataPacket{ - public const NETWORK_ID = ProtocolInfo::STRUCTURE_TEMPLATE_DATA_EXPORT_RESPONSE_PACKET; +class StructureTemplateDataResponsePacket extends DataPacket{ + public const NETWORK_ID = ProtocolInfo::STRUCTURE_TEMPLATE_DATA_RESPONSE_PACKET; /** @var string */ public $structureTemplateName; @@ -51,6 +51,6 @@ class StructureTemplateDataExportResponsePacket extends DataPacket{ } public function handle(NetworkSession $handler) : bool{ - return $handler->handleStructureTemplateDataExportResponse($this); + return $handler->handleStructureTemplateDataResponse($this); } } diff --git a/src/pocketmine/network/mcpe/protocol/TickSyncPacket.php b/src/pocketmine/network/mcpe/protocol/TickSyncPacket.php new file mode 100644 index 000000000..4c14fc8aa --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/TickSyncPacket.php @@ -0,0 +1,73 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class TickSyncPacket extends DataPacket/* implements ClientboundPacket, ServerboundPacket*/{ + public const NETWORK_ID = ProtocolInfo::TICK_SYNC_PACKET; + + /** @var int */ + private $clientSendTime; + /** @var int */ + private $serverReceiveTime; + + public static function request(int $clientTime) : self{ + $result = new self; + $result->clientSendTime = $clientTime; + $result->serverReceiveTime = 0; //useless + return $result; + } + + public static function response(int $clientSendTime, int $serverReceiveTime) : self{ + $result = new self; + $result->clientSendTime = $clientSendTime; + $result->serverReceiveTime = $serverReceiveTime; + return $result; + } + + public function getClientSendTime() : int{ + return $this->clientSendTime; + } + + public function getServerReceiveTime() : int{ + return $this->serverReceiveTime; + } + + protected function decodePayload() : void{ + $this->clientSendTime = $this->getLLong(); + $this->serverReceiveTime = $this->getLLong(); + } + + protected function encodePayload() : void{ + $this->putLLong($this->clientSendTime); + $this->putLLong($this->serverReceiveTime); + } + + public function handle(NetworkSession $handler) : bool{ + return $handler->handleTickSync($this); + } +} diff --git a/tests/phpstan/bootstrap.php b/tests/phpstan/bootstrap.php new file mode 100644 index 000000000..10b2da0fc --- /dev/null +++ b/tests/phpstan/bootstrap.php @@ -0,0 +1,24 @@ +