Last active
November 12, 2022 21:13
-
-
Save DavyCraft648/e0c53467ded1a90a7522fa14c6a2dfd0 to your computer and use it in GitHub Desktop.
A plugin that helps you to fix "Typed property (packet)::$syncedProperties must not be accessed before initialization" error which actually occurs because one of your plugins is outdated, but the plugin is not detected in the crashdump. This plugin will tell you which plugins you should update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace DavyCraft648\UninitializedSyncedPropertiesFix; | |
| use pocketmine\event\EventPriority; | |
| use pocketmine\event\server\DataPacketSendEvent; | |
| use pocketmine\network\mcpe\protocol\AddActorPacket; | |
| use pocketmine\network\mcpe\protocol\AddPlayerPacket; | |
| use pocketmine\network\mcpe\protocol\SetActorDataPacket; | |
| use pocketmine\network\mcpe\protocol\types\entity\PropertySyncData; | |
| use pocketmine\plugin\PluginBase; | |
| use function get_class; | |
| /** | |
| * @name UninitializedSyncedPropertiesFix | |
| * @version 0.0.1 | |
| * @main DavyCraft648\UninitializedSyncedPropertiesFix\Main | |
| * @api 4.0.0 | |
| * @prefix USPF | |
| */ | |
| class Main extends PluginBase{ | |
| protected function onEnable() : void{ | |
| $this->getServer()->getPluginManager()->registerEvent(DataPacketSendEvent::class, function(DataPacketSendEvent $event) : void{ | |
| foreach($event->getPackets() as $packet){ | |
| if($packet instanceof AddActorPacket || $packet instanceof AddPlayerPacket || $packet instanceof SetActorDataPacket){ | |
| if(!isset($packet->syncedProperties)){ | |
| $trace = debug_backtrace(); | |
| $info = $trace[3]; // NetworkSession->sendDataPacket() | |
| if($info['class'] === "pocketmine\Server"){ | |
| $info = $trace[5]; // Server->broadcastPackets() | |
| } | |
| $this->getLogger()->error("Uninitialized " . get_class($packet) . "::\$syncedProperties found, called from: {$info['file']} on line: {$info['line']}"); | |
| $packet->syncedProperties = new PropertySyncData([], []); | |
| } | |
| } | |
| } | |
| }, EventPriority::LOWEST, $this); | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First, you can either download or copy paste this code into a something.php file (create the file first, whatever the name is) and put it in the plugins folder. done.
when you get the error again, this plugin will tell you which file the error is from.