When I try to reconnect a player to a server, this happens:
I let players reconnect to the server if they are stuck or something.
No it isn't reproducable without plugins. but this isnt a plugin error..
public function transfer(Player $player, string $identifier, $msg = ""){
$pk = new TransferPacket();
$pk->address = $this->getAddress(); //server ip
$pk->port = $this->getPortByIdentifier($identifier); //server port
$player->directDataPacket($pk);
if($msg != "") $this->addTransferMessage($player, $msg);
$player->close();
}
UPDATE: It doesn't do this anymore with Player->kick(), but I still think this is unexpected behavior..? Shouldn't crash.
You should not be using $player->close() it is an internal function.
..shouldn't it be private then? or somehow prevented to be used by plugins?
@mal0ne-23 Private cannot prevent use by plugins. The correct way is to mark the method as @internal.
Actually, close() is not forbidden for plugins. It's just something different from kick(), but still meaningful if used correctly.
backtrace?
I create portal with transfer (Check location player in PlayerMoveEvent)
[Server thread/INFO]: Ganselot[/192.168.1.81:1037] logged out due to transfer
[Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerMoveEvent' to 'RegionGuard v1.0.0': Call to a member function getName() on null on RegionGuard\EventListener
[Server thread/CRITICAL]: Error: "Call to a member function getName() on null" (EXCEPTION) in "plugins/Z_RegionGuard/src/RegionGuard/EventListener" at line 123
[Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerMoveEvent' to 'SkyWars v0.7dev': Call to a member function getName() on null on svile\sw\SWlistener
[Server thread/CRITICAL]: Error: "Call to a member function getName() on null" (EXCEPTION) in "plugins/Z_SkyWars/src/svile/sw/SWlistener" at line 257
[Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerMoveEvent' to 'ToolsPro v1.0.0': Trying to get permissions of closed player on ToolsPro\EventListener
[Server thread/CRITICAL]: InvalidStateException: "Trying to get permissions of closed player" (EXCEPTION) in "src/pocketmine/Player" at line 559
[Server thread/CRITICAL]: Could not tick level "lobby": Call to a member function addEntityMovement() on null
[Server thread/CRITICAL]: Error: "Call to a member function addEntityMovement() on null" (EXCEPTION) in "src/pocketmine/Player" at line 1567
This is not a support forum for defective plugins.
Funny, but such errors do not have even a poor fork. It only happens with PocketMine-MP
Example:
public function onPlayerMoveEvent(PlayerMoveEvent $event)
{
$player = $event->getPlayer();
$x = $player->x;
$y = $player->y;
$z = $player->z;
foreach ($this->portals->getAll() as $name => $area) {
if ($area['world'] == $player->getLevel()->getName()) {
if (($area['pos1'][0] <= $x and $x <= $area['pos2'][0]) and ($area['pos1'][1] <= $y and $y <= $area['pos2'][1]) and ($area['pos1'][2] <= $z and $z <= $area['pos2'][2])) {
$addr = $area['ip'];
$addr = explode(":", $addr);
$ip = $addr[0];
$port = $addr[1];
$player->transfer($ip, $port);
}
}
}
}
This is not a support forum for defective plugins. You fail to realize, like every other irritating person on this issue tracker who doesn't think, that PocketMine-MP's API is undergoing substantial changes. Therefore your experience on spoons is irrelevant.
@zKoz210 Funny but without anyone supporting this repository, all spoons would just collapse _(oh wait, haven't most of them already collapsed and have a bunch of people fighting for the spoon ownership?)_.
The transfer bug you are referring is a client bug. If you try transferring a moving player, they will get "Disconnected" like as if they turned off their WiFi.
@Muqsit it can hardly be considered a client bug when the server is still processing it and crashing.
Are you using just close() that makes it impossible to use the transfer in events.
Reproduce:
1) one plugin with PlayerInteractEvent (RegionGuard)
2) plugin with this event
public function onPlayerInteractEvent(PlayerInteractEvent $event) {
$event->getPlayer()->transfer('play.simplexland.ru', 19132);
}
[12:48:37] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerInteractEvent' to 'RegionGuard v1.0.0': Call to a member function getItemInHand() on null on RegionGuard\EventListener
[12:48:37] [Server thread/CRITICAL]: Error: "Call to a member function getItemInHand() on null" (EXCEPTION) in "plugins/Z_RegionGuard/src/RegionGuard/EventListener" at line 33
[12:48:37] [Server thread/CRITICAL]: Error: "Call to a member function sendHeldItem() on null" (EXCEPTION) in "src/pocketmine/Player" at line 2387
[12:48:37] [Server thread/CRITICAL]: [Network] Stopped interface pocketmine\network\mcpe\RakLibInterface due to Undefined index: 192.168.1.81:32286
@dktapps I'm some commits behind and it has happened to me ever since MCPE brought the transfer packet back. This bug isn't exactly related to the OP's issue, just a note for anyone who it's trying to transfer a moving player. I have a sign-tapping system to transfer players, and this bug happens even if the player slightly moves along the yaw-pitch axis. They have to stand stationery while tapping the sign to get successfully transferred.
The problem is that no additional checks are performed for the player being dead or closed if a plugin does something during PlayerMoveEvent. This problem extends to a wide range of other events:
I've been trying to come up with a way to solve this issue for a while. My best solution is to throw an exception at the end of close() to interrupt any execution that might be taking place. This exception would then need to be caught by the packet handler or the onUpdate() function. However, this would be a radical API break, and lots of plugins would no doubt start crashing for no apparent reasons.
This issue is also somewhat related to #1226 . The only clean way I can think of to solve this issue is to create an exception throw. It also doesn't help that Player and network are currently hopelessly tangled together.
Example of what I'm talking about
public function onUpdate($currentTick){
if($this->closed){
return false;
}
$this->someFunctionThatMightCloseMeWithoutNotifyingMe();
$this->updateMovement(); //crash
return true;
}
With exception throw, Entity->close() could throw an EntityClosedException:
public function onUpdate($currentTick){
if($this->closed){
return false;
}
try{
$this->someFunctionThatMightCloseMeWithoutNotifyingMe();
$this->updateMovement(); //never reached if the above call causes the entity to be closed
}catch(EntityClosedException $e){
return false;
//ok, don't try and do anything else with garbage entity
}
return true;
}
Temporary fix. If you don't care message (logged out due to transfer), you can simply remove $this->close("", $ev->getMessage(), false); or create your own function without it
/**
* Transfers a player to another server.
*
* @param string $address The IP address or hostname of the destination server
* @param int $port The destination port, defaults to 19132
* @param string $message Message to show in the console when closing the player
*
* @return bool if transfer was successful.
*/
public function transfer(string $address, int $port = 19132, string $message = "transfer") : bool{
$this->server->getPluginManager()->callEvent($ev = new PlayerTransferEvent($this, $address, $port, $message));
if(!$ev->isCancelled()){
$pk = new TransferPacket();
$pk->address = $ev->getAddress();
$pk->port = $ev->getPort();
$this->directDataPacket($pk);
$this->close("", $ev->getMessage(), false);
return true;
}
return false;
}
how do i backtrace ..? i provided the code it happened with. directly send a transfer packet to the player and then close them right after
same happening with me too:- [Server] Server thread/CRITICAL Stopped interface pocketmine\network\mcpe\RakLibInterface due to Undefined index: 208.188.113.205:41019
25.07 12:32:35 [Server] Server thread/CRITICAL Error: "Call to a member function addChunkPacket() on null" (EXCEPTION) in "src/pocketmine/Player" at line 2153
comming version :- db12657
enable debug output? come on dude, you're a long-time user...
ok I am doing
yeah yeah, give me a sec
I tested api3/blocks version . everything works awesome .. instead of this and alwys spawn which has chunck generation problem on player join.
It isn't happening anymore .. Using the same code.
It just disconnects them due to "generic reason" (because using Player->close()) and then they're reconnected, like I intended it to do before. But last time it crashed.
I removed transfer server slapper .its no more happening .. I think it was crashing due to transfer..
I submitted a crash dumb report .. see if that helps.
I'm also using 'api3/blocks' branch and experienced this issue when hitting a Slapper which executes a 'transferserver' command for the player (rca {player} transferserver xxx.xxx.xxx.xxx). When I use the command directly without the Slapper everything works fine.
I can confirm that removing the line $this->close("", $ev->getMessage(), false); in Player::transfer() solves the issue. Maybe it helps to reproduce the issue.
The problem is that no additional checks are performed for the player being dead or closed if a plugin does something during PlayerMoveEvent. This problem extends to a wide range of other events.
Should the unconfirmed tag be changed to debugged?
I still don't know the cause of your specific issue @mal0ne-23 and haven't reproduced it, so it remains unconfirmed.
I figured out how to reproduce it. If you're moving while you get transferred, that error occurs
What is this supposed to do with sound? I have basically the same problem but not with the player moving. Here's the full debug level 2, is there anything to improve this? The address is not even the same as you guys say..
[17:54:42] [Server thread/INFO]: LCR[/175.208.218.76:33451] logged out due to quit game
[17:54:42] [Server thread/DEBUG]: Packet pocketmine\network\mcpe\protocol\BatchPacket 0xfe78da63d66162129654bb23fbdfe9fa620bc72d07af3b31fe63616060068a972a33000123030e20f0868dc99f818b81818b9d2125b3b82027b1928385c12f3137d59ce1d0f2b4e84733971d5a9e736879b26f69514a6ad1a1e5409406148c5538b43c3524a328bf5ca1245fa1b034b344a1242355c11da811642cb70a1313e37f20e06764e0546162f8c7c8798d9109c85281b08425812efae704b4df9181e19ad3114626a06b15592018e86a10cd66c42000348a4d9e89e13f07030046d537e0
[17:54:42] [Server thread/CRITICAL]: Error: "Call to a member function addChunkPacket() on null" (EXCEPTION) in "src/pocketmine/Player" at line 2143
[17:54:42] [Server thread/DEBUG]: #0 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(126): pocketmine\Player->handleLevelSoundEvent(pocketmine\network\mcpe\protocol\LevelSoundEventPacket object)
[17:54:42] [Server thread/DEBUG]: #1 src/pocketmine/network/mcpe/protocol/LevelSoundEventPacket(170): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleLevelSoundEvent(pocketmine\network\mcpe\protocol\LevelSoundEventPacket object)
[17:54:42] [Server thread/DEBUG]: #2 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(94): pocketmine\network\mcpe\protocol\LevelSoundEventPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
[17:54:42] [Server thread/DEBUG]: #3 src/pocketmine/network/mcpe/protocol/BatchPacket(106): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\LevelSoundEventPacket object)
[17:54:42] [Server thread/DEBUG]: #4 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(94): pocketmine\network\mcpe\protocol\BatchPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
[17:54:42] [Server thread/DEBUG]: #5 src/pocketmine/Player(3198): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object)
[17:54:42] [Server thread/DEBUG]: #6 src/pocketmine/network/mcpe/RakLibInterface(139): pocketmine\Player->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object)
[17:54:42] [Server thread/DEBUG]: #7 src/raklib/server/ServerHandler(97): pocketmine\network\mcpe\RakLibInterface->handleEncapsulated(string 175.208.218.76:33451, raklib\protocol\EncapsulatedPacket object, integer 0)
[17:54:42] [Server thread/DEBUG]: #8 src/pocketmine/network/mcpe/RakLibInterface(80): raklib\server\ServerHandler->handlePacket()
[17:54:42] [Server thread/DEBUG]: #9 src/pocketmine/network/Network(86): pocketmine\network\mcpe\RakLibInterface->process()
[17:54:42] [Server thread/DEBUG]: #10 src/pocketmine/Server(2447): pocketmine\network\Network->processInterfaces()
[17:54:42] [Server thread/DEBUG]: #11 src/pocketmine/Server(2221): pocketmine\Server->tick()
[17:54:42] [Server thread/DEBUG]: #12 src/pocketmine/Server(2100): pocketmine\Server->tickProcessor()
[17:54:42] [Server thread/DEBUG]: #13 src/pocketmine/Server(1682): pocketmine\Server->start()
[17:54:42] [Server thread/DEBUG]: #14 src/pocketmine/PocketMine(501): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string phar://C:/Users/murder/Desktop/md/italy/italy1/PocketMine-MP.phar/, string C:\Users\murder\Desktop\md\italy\italy1\, string C:\Users\murder\Desktop\md\italy\italy1\plugins\)
[17:54:42] [Server thread/DEBUG]: #15 C:/Users/murder/Desktop/md/italy/italy1/PocketMine-MP.phar(1): require(string phar://C:/Users/murder/Desktop/md/italy/italy1/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
[17:54:42] [Server thread/CRITICAL]: ErrorException: "Undefined index: 175.208.218.76:33451" (EXCEPTION) in "src/pocketmine/network/mcpe/RakLibInterface" at line 146
[17:54:42] [Server thread/DEBUG]: #0 src/pocketmine/network/mcpe/RakLibInterface(146): pocketmine\{closure}(integer 8, string Undefined index: 175.208.218.76:33451, string phar://C:/Users/murder/Desktop/md/italy/italy1/PocketMine-MP.phar/src/pocketmine/network/mcpe/RakLibInterface.php, integer 146, array Array())
[17:54:42] [Server thread/DEBUG]: #1 src/raklib/server/ServerHandler(97): pocketmine\network\mcpe\RakLibInterface->handleEncapsulated(string 175.208.218.76:33451, raklib\protocol\EncapsulatedPacket object, integer 0)
[17:54:42] [Server thread/DEBUG]: #2 src/pocketmine/network/mcpe/RakLibInterface(80): raklib\server\ServerHandler->handlePacket()
[17:54:42] [Server thread/DEBUG]: #3 src/pocketmine/network/Network(86): pocketmine\network\mcpe\RakLibInterface->process()
[17:54:42] [Server thread/DEBUG]: #4 src/pocketmine/Server(2447): pocketmine\network\Network->processInterfaces()
[17:54:42] [Server thread/DEBUG]: #5 src/pocketmine/Server(2221): pocketmine\Server->tick()
[17:54:42] [Server thread/DEBUG]: #6 src/pocketmine/Server(2100): pocketmine\Server->tickProcessor()
[17:54:42] [Server thread/DEBUG]: #7 src/pocketmine/Server(1682): pocketmine\Server->start()
[17:54:42] [Server thread/DEBUG]: #8 src/pocketmine/PocketMine(501): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string phar://C:/Users/murder/Desktop/md/italy/italy1/PocketMine-MP.phar/, string C:\Users\murder\Desktop\md\italy\italy1\, string C:\Users\murder\Desktop\md\italy\italy1\plugins\)
[17:54:42] [Server thread/DEBUG]: #9 C:/Users/murder/Desktop/md/italy/italy1/PocketMine-MP.phar(1): require(string phar://C:/Users/murder/Desktop/md/italy/italy1/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
[17:54:42] [Server thread/CRITICAL]: [Network] Stopped interface pocketmine\network\mcpe\RakLibInterface due to Undefined index: 175.208.218.76:33451
Work is underway on the network-nuke branch to resolve this issue. The high-level overview is basically this:
close() has been abused by a lot of things for a long time, including for disconnecting players. A new disconnect() method is being introduced, which will do the light things like sending packets, and then schedule the player entity for close()ing at the end of the tick.close() will no longer be an appropriate way to get rid of a player - instead things should use disconnect() for graceful cleanup and disconnection.
Most helpful comment
Work is underway on the
network-nukebranch to resolve this issue. The high-level overview is basically this:close()has been abused by a lot of things for a long time, including for disconnecting players. A newdisconnect()method is being introduced, which will do the light things like sending packets, and then schedule the player entity forclose()ing at the end of the tick.close()will no longer be an appropriate way to get rid of a player - instead things should usedisconnect()for graceful cleanup and disconnection.