Nukkit
Nukkit copied to clipboard
Setting own gamemode to creative causes all nearby inventories to close.
Expected Behavior
- Player 1 Opens their inventory
- Player 2 changes their own game mode to creative
- Player 1's inventory stays open. (The vanilla behaviour)
(Affects all forms of the player inventory)
Actual Behavior
- Player 1 Opens their inventory
- Player 2 changes their own game mode to creative
- Player 1's inventory closes.
From testing, it appears the inventory is closed with this like in setGamemode()
this.inventory.sendContents(this.getViewers().values());
In the case that this behaviour is intended, shouldn't an alternative be found? It's pretty obnoxious to close all inventories to every player nearby just because of a game mode change.
Steps to Reproduce
Get two accounts. Have one open their inventory first and then have the other update its own gamemode. The inventory on for the player which had it initially open should then close.
Debug information
- Debug link: https://hastebin.com/ifeyedureb
- Timings link (if relevant):
Checklist:
- [x] I included a
/debugpaste
link - [x] I made sure there aren't duplicates of this report (Use Search)
- [x] I made sure I am using an up-to-date version of Nukkit
- [x] I Made sure the bug/error is not caused by a plugin
I did try removing the line which seemed to have no impact initially but I imagine there's something I'm not seeing here.
Expected Behavior
- Player 1 Opens their inventory
- Player 2 changes their own game mode to creative
- Player 1's inventory stays open. (The vanilla behaviour)
(Affects all forms of the player inventory)
Actual Behavior
- Player 1 Opens their inventory
- Player 2 changes their own game mode to creative
- Player 1's inventory closes.
From testing, it appears the inventory is closed with this like in setGamemode()
this.inventory.sendContents(this.getViewers().values());
In the case that this behaviour is intended, shouldn't an alternative be found? It's pretty obnoxious to close all inventories to every player nearby just because of a game mode change.
Steps to Reproduce
Get two accounts. Have one open their inventory first and then have the other update its own gamemode. The inventory on for the player which had it initially open should then close.
Debug information
- Debug link: https://hastebin.com/ifeyedureb
- Timings link (if relevant):
Checklist:
- [x] I included a
/debugpaste
link- [x] I made sure there aren't duplicates of this report (Use Search)
- [x] I made sure I am using an up-to-date version of Nukkit
- [x] I Made sure the bug/error is not caused by a plugin
I have seen these errors before and I think the solution is a FixInventory code. I have seen these errors before and I think the solution is a FixInventory code. Here is the code, I hope it works perfectly.
private boolean cancel_send = true;
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onFixCrash(DataPacketSendEvent e) {
if(cancel_send && e.getPacket() instanceof ContainerClosePacket) {
e.setCancelled();
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onDataPacketReceive(DataPacketReceiveEvent e) {
if(e.getPacket() instanceof ContainerClosePacket){
cancel_send = false;
e.getPlayer().dataPacket(e.getPacket(), false);
cancel_send = true;
}
}