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.
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 ofgetCommands
. 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
.