Error: PHP: [19:59:22] [Server thread/CRITICAL]: ErrorException: "Undefined property: pocketmine\network\mcpe\protocol\AddEntityPacket::$getEntityUniqueId" (EXCEPTION) in "MysteryCrate_v3/src/MysteryCrates/DespawnText" at line 23 [19:59:22] [Server thread/DEBUG]: #0 MysteryCrate_v3/src/MysteryCrates/DespawnText(23): pocketmine\error_handler(integer 8, string Undefined property: pocketmine\network\mcpe\protocol\AddEntityPacket::$getEntityUniqueId, string /home/arma/plugins/MysteryCrate_v3/src/MysteryCrates/DespawnText.php, integer 23, array Array())public function onRun($currentTick) { $players = $this->plugin->getServer()->getOnlinePlayers(); $pk = new RemoveEntityPacket(); $pk->entityUniqueId = $this->pk->getEntityUniqueId; foreach ($players as $pl) { $pl->directDataPacket($pk); } $this->plugin->getServer()->getScheduler()->cancelTask($this->getTaskId()); }
Oups sorry PHP: public function __construct(Main $plugin, Player $player, AddEntityPacket $pk){ parent::__construct($plugin); $this->plugin = $plugin; $this->player = $player; $this->pk = $pk; }
PHP: [Server thread/DEBUG]: #8 /home/arma/PocketMine-MP.phar(1): require(string phar:///home/arma/PocketMine-MP.phar/src/pocketmine/PocketMine.php) object(pocketmine\network\mcpe\protocol\AddEntityPacket)#14800 (15) { ["entityUniqueId"]=> NULL ["entityRuntimeId"]=> int(18) ["type"]=> int(66) ["position"]=> string(29) "Vector3(x=118.5,y=10,z=235.5)" ["motion"]=> NULL ["yaw"]=> int(0) ["pitch"]=> int(0) ["attributes"]=> array(0) { } ["metadata"]=> array(2) { [2]=> array(2) { [0]=> int(4) [1]=> string(44) "§8[§a+§8]§7 DiamondSword " } [15]=> array(2) { [0]=> int(2) [1]=> int(0) } } ["links"]=> array(0) { } ["isEncoded"]=> bool(true) ["extraByte1"]=> int(0) ["extraByte2"]=> int(0) ["offset"]=> int(0) ["buffer"]=> string(182) "0d00002412420000ed420000204100806b430000000000000000000000000000000000000000000202042cc2a7385bc2a7612bc2a7385dc2a73720457370616461206465204469616d616e746520456e63616e746164610f020000"}
The error is telling you that Pocketmine can't find a property called $getEntityUniqueId in AddEntityPacket; You mean the function getEntityUniqueId(), and made the same mistake for RemoveEntityPacket in the code you posted.
I have change by Spoiler PHP: $pk->entityUniqueId = $this->pk->entityRuntimeId; I got that PHP: [20:56:58] [Server thread/CRITICAL]: Could not execute task MysteryCrates\DespawnText: Trying to get property 'entityRuntimeId' of non-object
We can't help when the code you posted doesn't correspond to the errors, we can't see where that $pk comes from, and you didn't use getEntityUniqueId(). You should put the plugin on github, then you might get some help.
I will do that later but maybe this is the cause PHP: public function spawnNamedText(Chest $chest, Player $player, String $text){ $pk = new AddEntityPacket(); $players = $this->getServer()->getOnlinePlayers(); $pk->type = self::NETWORK_ID; $pk->entityRuntimeId = Entity::$entityCount++; $pk->metadata = [ 2 => [4, "§8[§a+§8]§7 " . $text ], 15 => [2, 0], ]; $pk->yaw = 0; $pk->pitch = 0; $pk->position = new \pocketmine\math\Vector3($chest->getX() + 0.5, $chest->getY() + 1.5, $chest->getZ() + 0.5); foreach ($players as $pl) { $pl->dataPacket($pk); } $this->getServer()->getScheduler()->scheduleDelayedTask(new DespawnText($this, $player, $pk), 15 * 3); }
You still haven't even posted the full code of your DespawnText Task. If you want help, please try to provide the information people need. Assuming you passed a reference to the packet to your DespawnText constructor, and we have to assume because you haven't shown us... then correcting the code in your first snippet to: PHP: $pk->entityUniqueId = $this->pk->getEntityUniqueId(); should have fixed the problem. What friscowz is trying to say is that if you pass the entityRuntimeId to your DespawnText constructor, which we unfortunately haven't seen yet (did I mention how important it is to make life easy for people who try to help you?), then you can use it to set the correct $pk->entityUniqueId for the RemoveEntityPacket().