lucko/commodore

Reliably detect CommandDispatcher synchronisation

Closed this issue · 0 comments

Pante commented

I glanced through the source code and saw that each registration was potentially re-obtaining a CommandDispatcher instance and scheduling a new task which seems hacky and is detrimental to performance.

May I suggest adding a listener for a ServerLoadEvent in the CommandoreImpl instead? The event is called after the server is loaded/reloaded and CommandDispatcher synchronisation by Spigot has been completed. That way the CommandDispatcher instance can be cached and the register method won't have to schedule a task to register the commands.