@@ -37,8 +37,7 @@ To add this project as a dependency to your project, add the following to your p
37
37
<dependency >
38
38
<groupId >com.github.Despical</groupId >
39
39
<artifactId >CommandFramework</artifactId >
40
- <version >1.5.0</version >
41
- <scope >compile</scope >
40
+ <version >1.5.1</version >
42
41
</dependency >
43
42
```
44
43
@@ -50,7 +49,7 @@ repositories {
50
49
```
51
50
``` groovy
52
51
dependencies {
53
- implementation 'com.github.Despical:CommandFramework:1.5.0 '
52
+ implementation 'com.github.Despical:CommandFramework:1.5.1 '
54
53
}
55
54
```
56
55
@@ -89,24 +88,24 @@ public class ExampleClass extends JavaPlugin {
89
88
// Before creating command the method must only have
90
89
// CommandArguments parameter and also @Command annotation
91
90
@Command (
92
- name = " example" ,
93
- aliases = {" firstAlias" , " secondAlias" },
94
- permission = " example.permission" ,
95
- desc = " Sends an example message to sender" ,
96
- usage = " /example" ,
97
- min = 1 ,
98
- max = 5 ,
99
- onlyOp = false , // this option will ignore permission if it is set
100
- // be careful if you are using non-thread safe operations
101
- // and if you want to enable option below
102
- async = false ,
103
- senderType = Command . SenderType . CONSOLE
91
+ name = " example" ,
92
+ aliases = {" firstAlias" , " secondAlias" },
93
+ permission = " example.permission" ,
94
+ desc = " Sends an example message to sender" ,
95
+ usage = " /example" ,
96
+ min = 1 ,
97
+ max = 5 ,
98
+ onlyOp = false , // this option will ignore permission if it is set
99
+ // be careful if you are using non-thread safe operations
100
+ // and if you want to enable option below
101
+ async = false ,
102
+ senderType = Command . SenderType . CONSOLE
104
103
)
105
104
@Cooldown (
106
- cooldown = 10 ,
107
- timeUnit = TimeUnit . SECONDS ,
108
- bypassPerm = " command.cooldownBypass" ,
109
- overrideConsole = true // console will now be affected by cooldown
105
+ value = 10 ,
106
+ timeUnit = TimeUnit . SECONDS ,
107
+ bypassPerm = " command.cooldownBypass" ,
108
+ overrideConsole = true // console will now be affected by cooldown
110
109
)
111
110
public void exampleCommand (CommandArguments arguments ) {
112
111
// CommandArguments class contains basic things related Bukkit commands
@@ -115,15 +114,15 @@ public class ExampleClass extends JavaPlugin {
115
114
}
116
115
117
116
@Command (
118
- name = " noParams"
117
+ name = " noParams"
119
118
)
120
119
public void commandWithoutParameters () {
121
120
Bukkit . getConsoleSender(). sendMessage(" This command is running without any parameters." );
122
121
}
123
122
124
123
@Command (
125
- name = " customParamWithoutAnnotations" ,
126
- min = 1
124
+ name = " customParamWithoutAnnotations" ,
125
+ min = 1
127
126
)
128
127
// See CommandFramework#addCustomParameter method above.
129
128
public void customParamCommand (String firstParameter , CommandArguments arguments ) {
@@ -132,38 +131,60 @@ public class ExampleClass extends JavaPlugin {
132
131
}
133
132
134
133
@Command (
135
- name = " customParams" ,
136
- min = 1
134
+ name = " customParams" ,
135
+ min = 1
137
136
)
138
137
// If command is executed with only one argument then the default value will be accepted.
139
138
// Otherwise, the given argument will be converted to specified type, in this case an int.
140
139
// If parameter is not annotated by @Default then command will throw an exception on execution.
141
140
// See the wiki page for creating custom parameters using @Param and @Default annotations.
142
141
public void customParamsCommand (CommandArguments arguments ,
143
- @Param (" secondAsInt" )
144
- @Default (" 50" )
145
- int secondArg ) {
142
+ @Param (" secondAsInt" )
143
+ @Default (" 50" )
144
+ int secondArg ) {
146
145
arguments. sendMessage(" Second argument as integer is " + secondArg);
147
146
}
148
147
149
148
@Command (
150
- name = " confirmationTest"
149
+ name = " confirmationTest"
151
150
)
152
151
@Confirmation (
153
- message = " Are you sure, if so, please execute command again to confirm." ,
154
- expireAfter = 10 ,
155
- bypassPerm = " confirmation.bypass" ,
156
- timeUnit = TimeUnit . SECONDS ,
157
- overrideConsole = true
152
+ message = " Are you sure, if so, please execute command again to confirm." ,
153
+ expireAfter = 10 ,
154
+ bypassPerm = " confirmation.bypass" ,
155
+ timeUnit = TimeUnit . SECONDS ,
156
+ overrideConsole = true
158
157
)
159
158
public void confirmationCommand (CommandArguments arguments ) {
160
159
arguments. sendMessage(" Confirmation successful." );
161
160
}
162
161
162
+ @Flag (
163
+ value = " test" ,
164
+ prefix = " --"
165
+ )
166
+ @Command (
167
+ name = " flag"
168
+ )
169
+ public void flagTest (CommandArguments arguments ) {
170
+ arguments. sendMessage(" Flag Present: " + arguments. isFlagPresent(" test" ));
171
+ }
172
+
173
+ @me.despical.commandframework.annotations.Option (
174
+ value = " players" ,
175
+ prefix = " --"
176
+ )
177
+ @Command (
178
+ name = " option"
179
+ )
180
+ public void optionTest (CommandArguments arguments ) {
181
+ arguments. sendMessage(" Parsed Options: " + String . join(" , " , arguments. getOption(" players" )));
182
+ }
183
+
163
184
// Aliases don't need to be same with the command above
164
185
@Completer (
165
- name = " example" ,
166
- aliases = {" firstAlias" , " secondAlias" }
186
+ name = " example" ,
187
+ aliases = {" firstAlias" , " secondAlias" }
167
188
)
168
189
public List<String > exampleCommandCompletion (/* CommandArguments arguments*/ /* no need to use in this case which is also supported*/ ) {
169
190
return Arrays . asList(" first" , " second" , " third" );
@@ -204,4 +225,4 @@ mvn clean package -DskipTests -Dmaven.javadoc.skip=true
204
225
```
205
226
206
227
> [ !IMPORTANT]
207
- > ** [ Maven] ( https://maven.apache.org/ ) ** must be installed to build Command Framework .
228
+ > ** [ Maven] ( https://maven.apache.org/ ) ** must be installed to build this project .
0 commit comments