Commit Graph

527 Commits

Author SHA1 Message Date
McLive f4a5d6f705 Move OnlinePlayer to own packages and deprecate at old locations (#194) 2019-02-23 17:35:37 -05:00
Aikar cadeacaf93 (DEPLOYED ACF) Updated JavaDocs 2019-02-21 19:17:08 -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 59b4392de1 (DEPLOYED ACF) Updated JavaDocs 2019-02-21 18:29:11 -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
Aikar 7c8cd834c6 Update project 2019-02-21 18:27:27 -05:00
Aikar a44d711996 Add more example stuff 2019-02-21 18:16:30 -05:00
Crypnotic 9ad64975bc Added Velocity support (#182)
This PR adds support for the upcoming proxy Velocity.
https://www.velocitypowered.org/

A few note worthy issues:
 - Velocity does not provide a static method for its ProxyServer instance, so the instance has to be passed in by the plugin with `new VelocityCommandManager(proxy, this)`

- Velocity does not provide a way to get the Plugin logger with the provided Plugin or PluginContainer, so it must be fetched using `Logger logger = LoggerFactory.getLogger(plugin.getClass());` UNTESTED

- Velocity uses an annotation to signify the main class, meaning it can't be passed around like the Bukkit and Bungeecord JavaPlugin and Plugin. An Object has to be passed in which the PluginContainer is extracted from it using the Proxy's PluginManager 
`proxy.getPluginManager().getPlugin(plugin.getClass().getAnnotation(Plugin.class).id()).get();`

Any and all feedback is welcomed and appreciated.

*This implementation is essentially a copy/paste/rename. All code belongs to the original author, except the `ACFVelocityUtil#matchPlayer` which was originally written by md_5 and modified to use Velocity classes.*
2019-02-19 21:15:05 -05:00
Aikar 02230709ab (DEPLOYED ACF) Updated JavaDocs 2019-02-14 19:44:04 -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
Aikar 40b1acebde (DEPLOYED ACF) Updated JavaDocs 2019-02-12 17:02:11 -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
Xavier 952e15ba68 Switched getField to getDeclaredField for the locale field in BukkitCommandManager (#189)
This resolves an issue where CraftBukkit has the locale field as private.
2019-02-12 16:49:36 -05:00
Aikar 7ce24aa2e8 (DEPLOYED ACF) Updated JavaDocs 2019-02-11 20:41:30 -05:00
Aikar a140f2dd4a forgot replacement string 2019-02-11 20:41:05 -05:00
Aikar f7c1cc7102 (DEPLOYED ACF) Updated JavaDocs 2019-02-11 20:39:34 -05:00
Aikar 94ee929d0f add User context for Sponge 2019-02-11 20:19:26 -05:00
Aikar 6481f22ea4 Fix last context for forwarding commands - Closes #179 2019-02-11 20:10:46 -05:00
Aikar 1a12993a92 (DEPLOYED ACF) Updated JavaDocs 2019-02-05 01:01:02 -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 a0b9fb637d (DEPLOYED ACF) Updated JavaDocs 2019-02-03 19:16:24 -05:00
Aikar 375648e50b Fix Forwarded Commands completion and misc improvements 2019-02-03 19:15:55 -05:00
Il'ya adf5de40b9 Improvements to Russian translation (#185) 2019-02-03 19:13:29 -05:00
Aikar b88b664dc2 (DEPLOYED ACF) Updated JavaDocs 2019-02-02 11:20:59 -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
Aikar 3fa9fdca65 add acf-example to project, switch to paper 2019-02-02 11:20:30 -05:00
Zollerboy1 77d091956b Complete German translation (#184)
I added missing German translations and improved some older ones.
2019-01-19 12:11:02 -05:00
MrMicky bf6788c072 Add French translation (#176) 2019-01-18 22:07:34 -05:00
Aikar 10f3202d51 (DEPLOYED ACF) Updated JavaDocs 2018-12-21 06:54:31 -05:00
simpleauthority aa6fa281cc Add unregister method for JDA (#174)
This PR is to allow users to unregister commands from the `JDACommandManager`

Currently slightly flawed, needs research. When re-registering it spits out a load of messages like so:
```
SEVERE: [ACF] ACF Error: settings registered subcommand boss role for root command settings - but it is already defined in settings
Sep 20, 2018 3:58:31 AM com.algorithmjunkie.freelance.gachapon.acf.JDACommandManager log
SEVERE: [ACF] 2 subcommands of the same prefix may not be spread over 2 different classes. Ignoring this.
```

Not sure if this is just for me, or if it's for all.
2018-10-23 11:00:11 -04:00
Aikar 01d1496c18 (DEPLOYED ACF) Updated JavaDocs 2018-09-09 20:59:53 -04:00
Aikar 71d0416f10 CommandIssuer should be IssuerOnly context
Likely fixes #170
2018-09-09 20:59:00 -04:00
Aikar 1d778b986f (DEPLOYED ACF) Updated JavaDocs 2018-09-01 20:29:30 -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
MrPowerGamerBR 9568e654e9 Fix typo (#164) 2018-08-27 14:06:15 -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 5858c1ecec (DEPLOYED ACF) Updated JavaDocs 2018-08-19 10:27: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
Aikar a51333112e (DEPLOYED ACF) Updated JavaDocs 2018-08-03 14:18:09 -04:00
Mark Vainomaa 7742dc3238 Deny permissions if command is issued by a webhook (#156) 2018-08-03 13:57:20 -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
Aikar 8fda944311 (DEPLOYED ACF) Updated JavaDocs 2018-07-25 01:44:47 -04:00
simpleauthority 7a2e547766 Make Users optional arguments (#139)
This PR allows `User`s to be optional command arguments similar to how the annotation operates on Bukkit's `Player`.
2018-07-24 21:42:54 -04:00
Gabik21MC e181a2fabe fix compilation of example plugin (#154) 2018-07-24 17:41:08 -04:00
Osip Fatkullin 3c979a9ef2 Drop trivial Guava usages (#142)
#120, #127
2018-07-19 19:43:17 -04:00