-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recursive GUI inventories do not work for low-latency users #74
Comments
This code works fine for me $menu = InvMenu::create(InvMenu::TYPE_CHEST);
$menu->readonly();
$menu->getInventory()->setContents([Item::get(Item::EMERALD)]);
$menu->setListener(function(Player $player, Item $out, Item $in, SlotChangeAction $action) use($menu) : void{
if($out->getId() === Item::EMERALD){
$menu2 = InvMenu::create(InvMenu::TYPE_CHEST);
$menu2->readonly();
$menu2->getInventory()->setContents([Item::get(Item::EMERALD)]);
$menu2->setListener(function(Player $player, Item $out, Item $in, SlotChangeAction $action) use($menu) : void{
if($out->getId() === Item::EMERALD){
$menu->send($player);
}
});
$menu2->send($player);
}
});
$menu->send($sender); |
It works but not as expected.. I am trying to get a single chest as first menu and then a double chest as second menu Basically i need to close the first one and open a new gui example: https://youtu.be/bGvYAQW3XtI |
This is working fine as well, are you sure you're using the latest InvMenu build? $menu = InvMenu::create(InvMenu::TYPE_CHEST);
$menu->readonly();
$menu->getInventory()->setContents([Item::get(Item::EMERALD)]);
$menu->setListener(function(Player $player, Item $out, Item $in, SlotChangeAction $action) use($menu) : void{
if($out->getId() === Item::EMERALD){
$menu2 = InvMenu::create(InvMenu::TYPE_DOUBLE_CHEST);
$menu2->readonly();
$menu2->getInventory()->setContents([Item::get(Item::EMERALD)]);
$menu2->setListener(function(Player $player, Item $out, Item $in, SlotChangeAction $action) use($menu) : void{
if($out->getId() === Item::EMERALD){
$menu->send($player);
}
});
$menu2->send($player);
}
});
$menu->send($sender); |
Just to be sure.. have you registered the InvMenuHandler? |
Yes i registed InvMenuHandler I can open guis but i cant close one and open another one (only single chest to single chest worked but the menu did not close and reopen it just change name of the menu and items) I want from single chest to double chest though |
Your code works fine for me, you're probably using an old InvMenu build is all I can say. |
So what i did for that (yesterday). Note that foreach of my gui plugins there is the folder after src on each plugin and the folder on the other plugins has an old version! |
Also i was testing it and sometimes it was working there is something like a coinflip if it will work or not (Note that i am win10 use) |
how do i do this "Inject the virion into your plugin phar by running bin/php7/bin/php path/to/InvMenu.phar path/to/yourplugin.phar" Also after i remove the invmenu folder from the plugin all the invmenu lines has this error |
Run the
command in your command line. Make sure you are in pocketmine's root directory (the directory containing The warning in your IDE means there are multiple InvMenu folders or phars in your project directory, so the IDE isn't sure from which InvMenu folder/phar to pick the class from. |
It looks like you are running your plugin from source. In that case you'd want to follow the Running InvMenu from .phar > In a development environment. |
So i did what In a development environment sayed todo but what hapenned is that Also i added on the server dev tools, test GUI and then i added the latest invmenu folder in the testGUI plugin and that worked. I am 100% sure that its the latest because the inventory was spawning behind the player which i see first time (nice idea) Only that way worked for me... Also i am using server pro test server and bluestar host (in server pro only first menu opened and in bluestar was 50% chance to open the second menu) my local host doesnt show the server on mc so i cant test it there.. |
Btw both chests spawn but sometimes they disappear (spawn and instantly dissapear) thats the problem maybe a bigger delay?? |
Delays are long gone, that used to be a bug in older versions. You probably should update InvMenu if you haven't updated it in the past month, some visual bugs were fixed. |
Not sure what I'm doing wrong, but the example code (literally copy pasted the one Muqsit sent above) doesn't work for me either. I'm using the latest build with DEVirion on pm 3.13.0 and the inventory just disappears after clicking on the emerald. |
Where is the virion located? I mean where have you put the virion? Also you can use VirionTools to inject a virion into a plugin. |
Could be that some other plugin might be interfering with it. Try without any other plugins. And make sure the handler is registered. |
Also remove invmenu folder from the plugin if you haven't already |
i dont think thats the problem... Like inventories work everything works with that way... Maybe add a check if the chest has spawned then return false else spawn chest again |
Code doesn't care about your or anyone's theories. Practically testing is all that matters here.
Maybe try removing the invmenu folder. Again, this isn't a bug with InvMenu. This is a you-bug. |
Okay and i will have to use devirion every time i want to add the plugin somewhere or how that works? |
If the plugin that is using invmenu is running from source, you need the devirion plugin and the InvMenu virion phar in your virions folder. If the plugin that is using invmenu is in phar format, inject the virion into your plugin.phar by executing this from the command line:
|
You will be using DEViriron regardless of virion being in .phar form or folder. The virion should always be present in the virions folder and not anywhere else unless its shaded. But, like Muqsit said, its sounding more like a you-problem and not a problem with the plugin. Anyways remove the virion from everywhere except the virions folder. Secondly you can use what Muqsit suggested for injecting the virion into your plugin or you can use the VirionTools plugin to do the same. |
Btw, if you are publishing the plugin on poggit, poggit can take care of injecting virions in the plugin. projects:
libs:
- src: muqsit/InvMenu/InvMenu
version: ^3.1.0 |
If you're on discord, join the pmmp discord server https://discord.gg/XDugAkJ, we can communicate faster there. |
According to the conversation on discord, this seems like a certain case with locally hosted servers. Not sure whether it is the lack of latency between packets because I have never tested InvMenu on a server with less than 150ms latency and neither have I ever experienced this bug ever since the NetworkStackLatencyPacket handling. |
Can confirm after a test on a non-local server, a friend with >150ms ping could open menus and I could not with <100. |
Can you fix this though :/ |
So i had an issue like that where when clicking on an item opens another window, however the second window doesn't open, the first window closes, this was all done in my local server hence low-latency, the way i fixed is, adding an delay, i don't know the exact but i tried with 2 tick, 5 tick, it didn't work, so i did 20 ticks, and it worked. |
@Itzdvbravo The delay-by-ticks mechanism works most of the time only for low latency. This usually isn't the case in production servers, hence destructive. $menu->setListener(function(...) : InvMenuResult{
if($item->getId() === ItemIds::APPLE){
return InvMenuResult::REDIRECT($second_menu);
}
return InvMenuResult::CANCEL();
}); |
Ah i see, ye prolly, also it's not only for low-latency, it'll work for high-latency players as well but ye it's destructive |
I mean as in, the higher your latency, the higher is the chance of it not working. |
I can't think of a proper solution for this. I'm thinking of replacing |
Can someone test this plugin? Use (The .zip file contains a .phar) |
Seems to be working on my local pm3 test server. (With the addition of InvCrashFix) |
Seems to be working on my local server too 👍 |
public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args): bool { if ($cmd->getName() == "test") { if ($sender instanceof Player) { $this->firstMenu($sender); } } return true; }
This calls...
`public function firstMenu(Player $player){
$this->menu= InvMenu::create(InvMenu::TYPE_CHEST);
$this->menu->readonly();
$this->menu->setName(C::BOLD . "Bruh Menu");
and it has to go on this once the diamond is clicked
`public function secondMenu(Player $player){
$this->menu2= InvMenu::create(InvMenu::TYPE_CHEST);
$this->menu2->readonly();
$this->menu2->setName("Second Menu");
So what happens is that diamond gets error
and if i try to add this:
$this->secondMenu($player);
The menu just close the nothing opens :/
I tried adding the code from your examples but it didnt work
Can you tell me how to open a GUI from a command and then once player clicks an item this windows closes and another one opens
The text was updated successfully, but these errors were encountered: