Commit Graph

237 Commits

Author SHA1 Message Date
Aikar 9c1521a456 Implement Bukkit Description for /help 2019-03-14 23:18:41 -04:00
Aikar e9857cb8b3 Adjust default parameter help output 2019-03-14 23:07:37 -04:00
Aikar 4e103adca4 Add Proper support for Default Completion Handlers 2019-03-14 22:34:56 -04:00
Aikar aa2e6ad1f8 Don't repeat last command completion unless its prefixed repeat 2019-03-12 21:52:50 -04:00
Aikar 23dd046b8e Improve parameter permissions and fix RC permission check 2019-03-09 11:27:58 -05:00
Kévin Jimenez d2754b99c9 Add support for CommandPermission annotation as parameter for permiss… (#197)
…ions by Optional annotation

In the past we could not handle a permission in relation to the presence of an optional argument, it forced us to manage it in the body of the command, and could be repetitive and boring, note that it also works with the annotation Default
2019-03-09 11:03:04 -05:00
Aikar ced74bc5d3 Support private methods too on local class.
we stil inherit public methods as previous
2019-03-03 11:11:58 -05:00
JOO200 7670224d81 Set default help page to one. (#196)
Fix for empty helps with CommandManager#generateCommandHelp()
2019-02-27 17:40:15 -05:00
Aikar 1b799355c5 fix command completions for aliases too 2019-02-25 23:00:31 -05:00
Aikar 6a7766e35d Fix command routing for forwarding commands
completions still funky, but least get execution working
2019-02-25 22:46:48 -05:00
Aikar 5d11925813 Fix NPE in help - Fixes #162 2019-02-25 22:27:03 -05:00
Aikar 67d631d47c Move to an improved CommandRouter, improve routing logic
now supports splitting commands over multiple BaseCommands better
should now only match probable @Default handlers, so @CatchUnknown
can still work in obviously wrong scenarios.

@HelpCommand no longer implies @Default as @CatchUnknown will pick it up
2019-02-25 21:45:12 -05:00
Aikar 9032570ca2 Fix getFirstElement to not care if there is more than 1 2019-02-24 13:19:25 -05:00
Aikar 4ef33613fc Do deep lookups on Private annotations
Added method to help do parent/enclosing based lookups
2019-02-23 22:32:05 -05:00
Aikar 115861be9a Fix Default handlers that consume input - #192 Fixed 2019-02-23 21:55:30 -05:00
Aikar a23ff21abf Improve code for scope lookup 2019-02-23 21:43:55 -05:00
JOO200 f235281112 Improve command handling from unknown commands (#195)
Currently there has to be the `@CatchUnknown` method in the same class as the `@Default` method.
Without finding any methods for handling unknown commands the default fallback method is the first registered or the class with `@Default` annotated method inside.

Maybe the solution to throw an exception for an unknown command is better.
The BaseCommand tries to execute the command context and if it's not possible it will throw an UnknownCommandException or smth like that.
2019-02-23 21:39:32 -05:00
JOO200 f893e37c97 Added Method-Getter in RegisteredCommand class (#193)
I want to use own annotations for help implementations (link, tooltips, short description etc.)
I can't access the method directly for the annotations, please add the getter ;)
2019-02-21 19:14:58 -05:00
Aikar 7282dade69 fix arg limit on completion context lookup and remove debug 2019-02-21 18:28:21 -05:00
Aikar 6303cce395 use better exception and reformat completions 2019-02-21 18:28:02 -05:00
Xavier 8db8d8b183 Fixed an issue where RegisteredCommand mutates the scopes required pe… (#190)
…rmissions and added caching to RegisteredCommand permissions
2019-02-14 16:33:34 -05:00
Xavier b96baaedac BaseCommand#hasPermission checks the required permissions (#188)
Currently the BaseCommand#hasPermission method doesn't actually check if the user has all the required permissions to execute a command, resulting in the following issue:

If user has permission permission.a they can execute:
/example
/example test
/example sub
/example sub testsub

Which is proper but if the user doesn't have permission.a they can only execute:
/example sub testsub

Example code:
```java
@CommandAlias("example")
@CommandPermission("permission.a")
public class ExampleCommand extends BaseCommand {

    @HelpCommand
    public void help(CommandHelp help) {
        help.showHelp();
    }

    @Subcommand("test")
    public void test(CommandSender sender) {
        sender.sendMessage("has permission to test?");
    }

    @Subcommand("sub")
    public class ExampleBCommand extends BaseCommand {

        @Subcommand("testsub")
        public void testSub(CommandSender sender) {
            sender.sendMessage("has permission to testSub?");
        }

    }

    @Subcommand("othersub")
    @CommandPermission("permission.b")
    public class ExampleCCommand extends BaseCommand {

        @Subcommand("othersub")
        public void otherSub(CommandSender sender) {
            sender.sendMessage("has permission to otherSub?");
        }

    }
}
```
2019-02-12 17:00:31 -05:00
Aikar 6481f22ea4 Fix last context for forwarding commands - Closes #179 2019-02-11 20:10:46 -05:00
Aikar 999c803091 Improve permission resolution of RootCommand's
ACF's permission tree can go more complex where a single root command
may have multiple dependent perm nodes.

So essentially ACF does not assign permission nodes to root in bukkit
and the such in a reasonable manner.

With this commit, we try to identify a single unique permission node,
and assign that permission node as the node to use where applicable.

In Bukkit/Sponge, we implement testPermission instead, which does a smarter
look up of all potential commands that root command might execute for the
given issuer, and if they have permission to any of them, then pass as true.

This is much more accurate, so if the issuer has access to no subcommand
then the root command should not be revealed anymore in Bukkit or Sponge.

In bungee, we are best guess at the unique perm node, and if there is
any ambiguity, it will be null and seen by everyone (but still enforces
permission checks)
2019-02-05 00:56:08 -05:00
Aikar 227052f6a2 Fix getContextValue resolving too many args 2019-02-05 00:52:55 -05:00
Aikar ebd60df1f4 Formatting changes 2019-02-05 00:52:44 -05:00
Aikar 2f8b21d865 Fix tabComplete isAsync 2019-02-04 21:23:49 -05:00
Aikar 375648e50b Fix Forwarded Commands completion and misc improvements 2019-02-03 19:15:55 -05:00
Aikar c5ca1ac731 Fix issues with Paper Async Tab Completion
Works in 1.12, but 1.13 has problems at paper level, I will fix there.
2019-02-02 11:20:30 -05:00
MrMicky bf6788c072 Add French translation (#176) 2019-01-18 22:07:34 -05:00
Aikar 71d0416f10 CommandIssuer should be IssuerOnly context
Likely fixes #170
2018-09-09 20:59:00 -04:00
Diego Arias 82aaf9b701 Register SubClasses before Command register() (#169)
This is so the SubCommands from the SubClasses get added to the SubCommand map before calling **addChild()**
2018-09-01 20:27:55 -04:00
Gabik21MC 370e1047d2 Fixes #165 (#166)
This seems kind of wrong to me. Somone calling RegisteredCommand#getHelpText out of context will run into the same issue.
2018-08-27 14:05:57 -04:00
Aikar 6c7ccbd6da Register CommandIssuer context 2018-08-19 10:27:26 -04:00
Niklas Eicker 0aa4cfd457 Improve logging concerning command replacements (#161)
The code is now checking for placeholders, that are not replaced. This would also warn the dev if he completely forgets to register a replacement. 
The downside of this is, that any %.* kind of pattern, that is NOT supposed to be a replacement will cause an error message. But since I couldn't come up for a reason to include % in any of the Annotation values other than a replacement, I decided this is much easier than checking all "old" commands when a replacement is registered.
Alternatively, I could collect all these unreplaced replacements and check against the collection when a new one is registered. This would not warn a dev that forgot to register the replacement, but on the other hand still allows the use of %. Please tell me what you think.

resolves #160
2018-08-06 15:52:31 -04:00
Mark Vainomaa 65ff5a5500 Replace Guava Iterables (#158)
Goes under #120

After this, only MultiMaps remain.
2018-08-03 09:57:38 -04:00
Osip Fatkullin 3c979a9ef2 Drop trivial Guava usages (#142)
#120, #127
2018-07-19 19:43:17 -04:00
Aikar 9aac7d7809 Enable ability to disable logging of uncaught exceptions
You must pass your own exception handler in order to do this.

Implementors need to be sure to log if its not a desired throw or
otherwise you will have silent command failures.
2018-06-18 21:31:46 -04:00
Gabik21MC 7c75cdd48c Improvements (#143)
Improve help output for commands split over multiple base commands
Fix help last page detection
Fix missing argument on Player Context Resolve
Expose registered root commands
2018-06-18 15:15:03 -04:00
Osip Fatkullin 444212ade5 Add russian translation (#141) 2018-06-17 12:03:36 -04:00
Aikar eb639427d2 Use collections instead of lists for static completions 2018-06-12 22:33:06 -04:00
Aikar 59c45f12ce Add support for static command completions 2018-06-12 22:23:38 -04:00
Aikar 27eb9fa733 More Documentation 2018-05-31 19:33:48 -04:00
Proximyst 0be34242db Updated JavaDocs from PR #116 2018-05-31 19:33:28 -04:00
Gabik21MC 961009a77c Support old user names (#133)
Recently a player with a two letter account joined on my server and I noticed that the context resolver for the player interface does not work. This PR also fixes crazy names like these:
https://de.namemc.com/profile/%24.1
https://de.namemc.com/profile/u.1
2018-05-29 11:04:14 -04:00
Aikar d57dbcefab Update Maven Plugins, hopefully will fix #129 2018-05-27 12:43:32 -04:00
Aikar cbc01b8b41 Set Annotation Targets on all the annotations
Fixes Kotlin for Dependency
2018-05-27 12:11:26 -04:00
chickeneer 88130a5574 Replace incorrect usage of MIN_VALUE with -MAX_VALUE
The javadocs for Float and Double specify this for the MIN_VALUE:
A constant holding the smallest positive nonzero value of type...

So the true minimum value must be calculated by the negative max value.
2018-05-24 09:38:26 -05:00
MiniDigger 6bd101ac30 leftover from #124 (#125) 2018-04-20 11:38:37 -04:00
MiniDigger 95fe4577be add a new annotation to hide commands from tabcompletion and help (#124)
* add a new annotation to hide commands from tabcompletion and help (implements #123)

* do the annotation lookup once
2018-04-20 11:28:22 -04:00