Add 'addCheck' method to CommandManager
See original GitHub issueIn my opinion, the main problem with command frameworks is that you never have full control over them, which can result in either having to do some hacky methods to get it to do what you want, or just not using the framework but your own solution.
Issue #57 is a good example of this. If you want to add a default cooldown/per command cooldown, you’ll have to modify ACF for it to work. My idea is to add a method to the CommandManager, something along the lines of CommandManager#addCheck(Check)
, where Check
is a functional interface which looks like this:
interface Check {
boolean check(Sender sender, String name, String[] args, Method method);
}
Again, using Issue #57 as an example, you can do this:
myCommandManager.addCheck((sender, name, args, method) -> {
boolean hasCooldown; //check if sender has cooldown
if(hasCooldown) return false; //Command will not be executed
int cooldown = method.getAnnotation(CommandCooldown.class).value(); //get cooldown (or default cooldown)
//set cooldown for sender
return true; //Command will be executed
});
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:11 (7 by maintainers)
Top Results From Across the Web
CommandManager - 2021 - SOLIDWORKS Help
Right-click the CommandManager tab and click Customize. In the Customize dialog box, on the Commands tab, select a category that contains tool buttons...
Read more >CommandManager Class (System.Windows.Input)
Provides command related utility methods that register CommandBinding and InputBinding objects for class owners and commands, add and remove command event ...
Read more >CHANGES — OpenStackClient CLI Base 2.7.0.dev6 ...
Add check for sdk_connection ... Remove commandmanager subclass ... Add test methods to compare formattable column values.
Read more >SOLIDWORKS - How to Customize the Command Manager
Customization of the Command Manager and Toolbars is a great way to optimize your design workspace for part, assembly, and drawing.
Read more >The CommandManager in SolidWorks - YouTube
The CommandManager is a context-sensitive toolbar that dynamically updates based on the toolbar you want to access.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m trying to move away from Override style stuff. Precommand is close, but I am working on something for this, but the name will be Preconditions
https://github.com/aikar/commands/blob/f900a739df7bfc0c1b6779be196541937209ddaf/core/src/main/java/co/aikar/commands/BaseCommand.java#L415
In the current version of ACF, one can override this method from BaseCommand to accomplish some of these ideas. The method is called here: https://github.com/aikar/commands/blob/8168122241d56fc6278ef4ab2197b0ef5ddd1dc0/core/src/main/java/co/aikar/commands/RegisteredCommand.java#L133
(Just giving the context for how this would fit into existing code).