|
2 | 2 | A plugin framework for Spigot and Bukkit. |
3 | 3 |
|
4 | 4 | # Features |
5 | | -* Parametric Command Framework |
6 | | -* Automated command registering |
7 | | -* Automated /help registering |
8 | | -* More coming soon(tm) |
| 5 | +* Parametric Command Framework - easily register commands, without all the hassle! |
| 6 | +* Automated command registering - automatically register those commands under Bukkit/Spigot! |
| 7 | +* Automated /help registering - registers commands in Bukkit's /help. |
| 8 | +* Dynamic configuration creation and injection - create configurations with classes, then inject them with updated values! |
| 9 | +* Dynamic hook injection (with availability check) - create hooks for other plugins, and only provide them if the plugin is available. |
| 10 | +* Automated listener registering - lets you use Bukkit event listeners in a module. |
| 11 | + |
| 12 | +# Installation |
| 13 | +1. [Grab the latest build of Frame]() and drop it into your plugins folder. |
| 14 | +2. You're all set! All of your Frame-enabled plugins should now run perfectly. |
| 15 | + |
| 16 | +# Developer Usage |
| 17 | +[Grab the latest build of Frame]() and add it as a library dependency. |
| 18 | + |
| 19 | +The first thing you'll need to do is create a **module**. Modules are the core part of Frame; they can listen for Bukkit events and commands, use hooks and use configurations. |
| 20 | +Modules don't need to implement an interface, so the following is valid: |
| 21 | + |
| 22 | +```java |
| 23 | +public class MyModule { |
| 24 | +} |
| 25 | +``` |
| 26 | + |
| 27 | +To register this module, you simply need to call `Frame.addModule()`, like so: |
| 28 | +```java |
| 29 | +Frame.addModule(MyModule.class); |
| 30 | +``` |
| 31 | + |
| 32 | +Frame handles all module instantiation in order to have a unified instance across the framework. If you wish to get hold of this instance, you can use `ModuleLoader.getInstance(<Module Class>)`. |
| 33 | + |
| 34 | +It's time to register our first command! Add the following to your module class: |
| 35 | + |
| 36 | +```java |
| 37 | +public class MyModule { |
| 38 | + @Command(aliases = "hello", desc = "Hello, world!", usage = "/hello") |
| 39 | + @Permission("myplugin.hello") |
| 40 | + public void helloWorld(@Sender CommandSender sender) { |
| 41 | + sender.sendMessage("Hello, world!"); |
| 42 | + } |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +Here we've introduced several new things: |
| 47 | +* `@Command`: this annotation tells Frame to register the method as a command. It takes three parameters: |
| 48 | + * `aliases`, which are the names for the command (e.g. an alias of `hello` results in the command "/hello" in Minecraft). It is a String[]. |
| 49 | + * `desc`: this is used for the /help description. |
| 50 | + * `usage`: this is used for the /help usage. |
| 51 | +* `@Permission`: this is an optional annotation, letting you specify a required permission node for this command. |
| 52 | +* `@Sender`: this is our first parameter annotation (there are more!). This annotation tells the dispatcher that this parameter should be the sender object (the person who sent the command). Can be any subclass of CommandSender, but currently doesn't check the type (may be implemented in future). |
| 53 | + |
| 54 | +We've now registered a command! If you built your plugin into a JAR and ran it on a server alongside Frame, running "/hello" would respond "Hello, world!" |
| 55 | + |
| 56 | +In future I'll write more into this section... |
0 commit comments