lucko / commodore

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

Add getBukkitSender API #5

Closed Rickyboy320 closed 5 years ago

Rickyboy320 commented 5 years ago

Adds a getBukkitSender API function to provide translation between vanilla's CommandWrapperListener and Bukkit's CommandSender.

The main targeted use case of this method is be ArgumentBuilder#requires. When the command tree is traversed by vanilla, the \<S> type is CommandWrapperListener, but plugins cannot do anything with that since they are not aware of that class. This method allows conversion of that object to a CommandSender so that normal Bukkit calls can be performed (such as checking for permissions or checking whether the executer isOp).

Tested with my own plugin, and seems to work like a charm. For example: builder.requires((sender) -> commodore.getBukkitSender(sender).isOp()); will be a node only sent to players that are op.

lucko commented 5 years ago

Perfect, thanks!