EbonJaeger / PerWorldInventory

Spigot multi-world inventory management
GNU General Public License v3.0
21 stars 17 forks source link

Incompatibility with other plugins due to 1-tick delay on gamemode changes #274

Open blablubbabc opened 6 years ago

blablubbabc commented 6 years ago

Assume some minigame plugin does the following in this order when players enter/leave the minigame:

Player entering the minigame:

Player leaving the minigame:

Note: The order has been chosen this way to be (hopefully) most likely compatible with other plugins reacting to world and gamemode changes, while not having to introduce (and handle) additional delays in there: It first teleports, then changes the gamemode, and then applies its store and clear inventory logic. So any plugins reacting to world or gamemode changes are hopefully done with 'their thing' before the minigame plugin does its inventory saving/clearing. And on leaving the minigame, the order is exactly reversed.

However, PerWorldInventory has a 1 tick delay between saving the inventory and then setting the new inventory when handling gamemode changes: https://github.com/Gnat008/PerWorldInventory/blob/master/src/main/java/me/gnat008/perworldinventory/listeners/player/PlayerGameModeChangeListener.java#L63

I can see the following potential issues with this:

In case PerWorldInventories has to load the player data from database first, there might by an additional delay before the inventory gets set, resulting in similar issues, but with arbitrary delay (instead of 1 tick).

An other issue I see in regards to mingame plugins: If the minigame involves dynamic gamemode changes, PerWorldInventories will store and restore inventories while the player participates in the minigame..

And here is an other 1-tick delay which is possibly not needed when changing the gamemode after a world change: https://github.com/Gnat008/PerWorldInventory/blob/5f1ddd7bafe9dcd69d044a40589692a74b07e071/src/main/java/me/gnat008/perworldinventory/process/InventoryChangeProcess.java#L144

So my questions/ideas on how to improve potential compatibility issues with minigame plugins:

Edit: Just found another potential issue fitting into this as well: There seems to be a repeating task which saves and removes cached player inventories, potentially adding a delay due to async inventory load at a later point. https://github.com/Gnat008/PerWorldInventory/blob/master/src/main/java/me/gnat008/perworldinventory/data/players/PWIPlayerManager.java#L368 It might make sense to keep the data of all online players cached until they leave. Because any delay related to inventory loading can result in compatibility issues as pointed out above.

ScuroK commented 6 years ago

@Gnat008 i suffer from inventory lost whrn players use Paintball. Before we didnt have any problems for years. Could you fix this pls?

EbonJaeger commented 6 years ago

This is being address in the rewrite.