PaperMC / Waterfall

BungeeCord fork that aims to improve performance and stability.
https://papermc.io
MIT License
736 stars 295 forks source link

Proof methods in Plugin, PluginManager against concurrent access #812

Open A248 opened 10 months ago

A248 commented 10 months ago

Coming up on the 3-year anniversary of the stale BungeeCord PR https://github.com/SpigotMC/BungeeCord/pull/2945, I decided to re-implement the solutions with some enhancements and PR them to Waterfall instead.

Compared to the old PR, PluginManager's commandMap is now a concurrent map. Synchronization is limited to mutative operations, which supports non-blocking command execution and tab completion. Moreover, using the concurrent map maintains thread safety while allowing us to preserve the longstanding bug in PluginManager whereby plugins can mutate the return value of getCommands. A separate PR could address that bug if desired, but such is outside the scope of this one.

Retrieving plugin instances continues to be synchronized, but only where necessary; by assumption plugins do not load other plugins in onLoad.