Skip to content

Commit 832156c

Browse files
committed
Update README
1 parent 912eccb commit 832156c

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

.github/README.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ To add this project as a dependency to your project, add the following to your p
3737
<dependency>
3838
<groupId>com.github.Despical</groupId>
3939
<artifactId>CommandFramework</artifactId>
40-
<version>1.2.9</version>
40+
<version>1.3.0</version>
4141
<scope>compile</scope>
4242
</dependency>
4343
```
@@ -50,12 +50,17 @@ repositories {
5050
```
5151
```
5252
dependencies {
53-
compileOnly group: "com.github.Despical", name: "CommandFramework", version: "1.2.9";
53+
compileOnly group: "com.github.Despical", name: "CommandFramework", version: "1.3.0";
5454
}
5555
```
5656

5757
## Example usage
58+
5859
```java
60+
import me.despical.commandframework.Command;
61+
import me.despical.commandframework.CommandArguments;
62+
import me.despical.commandframework.CustomParameters;
63+
5964
public class ExampleClass extends JavaPlugin {
6065

6166
// Don't forget to shade framework in to your project
@@ -65,6 +70,9 @@ public class ExampleClass extends JavaPlugin {
6570
public void onEnable() {
6671
// Initialize the framework before using
6772
commandFramework = new CommandFramework(this);
73+
// Adding custom parameters
74+
// Now all String type objects will return first argument.
75+
commandFramework.addCustomParameter(String.class, arguments -> arguments.getArgument(0));
6876

6977
// Then this will register all the @Command methods as a command
7078
// so there is no necessity to add command to your plugin.yml
@@ -73,9 +81,9 @@ public class ExampleClass extends JavaPlugin {
7381
if (arguments.isArgumentsEmpty()) return false;
7482

7583
String label = arguments.getLabel(), arg = arguments.getArgument(0);
76-
84+
7785
// StringMatcher is an external class from Despical's Commons library which is not in this framework
78-
ListStringMatcher.Match> matches = StringMatcher.match(arg, commandFramework.getCommands().stream().map(cmd -> cmd.name().replace(label + ".", "")).collect(Collectors.toList()));
86+
ListStringMatcher.Match > matches = StringMatcher.match(arg, commandFramework.getCommands().stream().map(cmd -> cmd.name().replace(label + ".", "")).collect(Collectors.toList()));
7987

8088
if (!matches.isEmpty()) {
8189
arguments.sendMessage("Did you mean %command%?".replace("%command%", label + " " + matches.get(0).getMatch()));
@@ -119,10 +127,21 @@ public class ExampleClass extends JavaPlugin {
119127
Logger.getLogger(this.getClass().getSimpleName()).info("This command is annotated with @NoCommandArguments to run without required parameters.");
120128
}
121129

130+
@Command(
131+
name = "customargs",
132+
min = 1
133+
)
134+
// Do not forget to annotate with @CustomParameters; otherwise, the method won't be registered.
135+
@CustomParameters
136+
public void customParamCommand(String firstParameter, CommandArguments arguments) {
137+
// CommandArguments parameter can be added to anywhere in method as a parameter.
138+
arguments.sendMessage("First parameter is " + firstParameter);
139+
}
140+
122141
// Aliases don't need to be same with the command above
123142
@Completer(
124-
name = "example",
125-
aliases = {"firstAlias", "secondAlias"}
143+
name = "example",
144+
aliases = {"firstAlias", "secondAlias"}
126145
)
127146
public List<String> exampleCommandCompletion(CommandArguments arguments) {
128147
// And you've created a tab completion for the command above

0 commit comments

Comments
 (0)