lucko / commodore

Utility for using Minecraft's 1.13 'brigadier' library in Bukkit plugins.
MIT License
176 stars 15 forks source link

Reliably detect CommandDispatcher synchronisation #3

Closed Pante closed 5 years ago

Pante commented 5 years ago

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.