Muqsit / InvMenu

A PocketMine-MP virion to create and manage virtual inventories!
https://poggit.pmmp.io/ci/Muqsit/InvMenu/~
GNU General Public License v3.0
203 stars 76 forks source link

fix(player): fix timestamp notify pm4 #218

Closed aabstractt closed 1 year ago

aabstractt commented 1 year ago

Fix the menu dont send... Quickfix: multitply 1000000 for the stored timestamp

Muqsit commented 1 year ago

The change must be made to the registered default handler in PlayerNetworkHandlerRegistry instead. PlayStation (and I suspect other OSes) have different offset value and this would affect them.

$this->registerDefault(new ClosurePlayerNetworkHandler(static function(Closure $then) : NetworkStackLatencyEntry{
+   $timestamp = mt_rand();
+   return new NetworkStackLatencyEntry($timestamp * 1000000, $then, $timestamp);
-   return new NetworkStackLatencyEntry(mt_rand() * 1000 /* TODO: remove this hack */, $then);
}));
Muqsit commented 1 year ago

Addressed in https://github.com/Muqsit/InvMenu/commit/363c2119b5a61549b0556bacfe9183d05d55ed72

MateusBlackyOFC commented 1 year ago

What is the solution for this error for players playing on console? Well, I tried that one, and it didn't work!

Addressed in 363c211

Muqsit commented 1 year ago

What is the solution for this error for players playing on console? Well, I tried that one, and it didn't work!

Addressed in 363c211

I've highlighted this in https://github.com/Muqsit/InvMenu/issues/216#issuecomment-1635025775. At the moment, I do not have access to a PlayStation and therefore cannot test a solution. I would suggest trying the same fix for Windows 10 users to see if it works for PlayStation users as well:

protected function onEnable() : void{
    if(!InvMenuHandler::isRegistered()){
        InvMenuHandler::register($this);
    }
+   // possible solution for playstation users:
+   $registry = InvMenuHandler::getPlayerManager()->getNetworkHandlerRegistry();
+   $registry->register(DeviceOS::PLAYSTATION, $registry->get(DeviceOS::WINDOWS_10));
}
dadodasyra commented 1 year ago

What is the solution for this error for players playing on console? Well, I tried that one, and it didn't work!

Addressed in 363c211

I've highlighted this in #216 (comment). At the moment, I do not have access to a PlayStation and therefore cannot test a solution. I would suggest trying the same fix for Windows 10 users to see if it works for PlayStation users as well:

protected function onEnable() : void{
  if(!InvMenuHandler::isRegistered()){
      InvMenuHandler::register($this);
  }
+ // possible solution for playstation users:
+ $registry = InvMenuHandler::getPlayerManager()->getNetworkHandlerRegistry();
+ $registry->register(DeviceOS::PLAYSTATION, $registry->get(DeviceOS::WINDOWS_10));
}

So, I tried multiple situations with a PS4 player.

We all love mojang weird protocol changes..

Muqsit commented 1 year ago

What is the solution for this error for players playing on console? Well, I tried that one, and it didn't work!

Addressed in 363c211

I've highlighted this in #216 (comment). At the moment, I do not have access to a PlayStation and therefore cannot test a solution. I would suggest trying the same fix for Windows 10 users to see if it works for PlayStation users as well:

protected function onEnable() : void{
    if(!InvMenuHandler::isRegistered()){
        InvMenuHandler::register($this);
    }
+   // possible solution for playstation users:
+   $registry = InvMenuHandler::getPlayerManager()->getNetworkHandlerRegistry();
+   $registry->register(DeviceOS::PLAYSTATION, $registry->get(DeviceOS::WINDOWS_10));
}

So, I tried multiple situations with a PS4 player.

  • With your actual pushed fixed it doesn't work, nothing opens
  • With the possible fix just ahead it doesnt work
  • By adding * 1000000 to the playstation thing (line 26) it works !!

We all love mojang weird protocol changes..

Thank you for testing, I expected the fix to be something like that. You're welcome to open a PR that addresses the issue on PlayStation🙂