@@ -34,7 +34,7 @@ To add this project as a dependency to your project, add the following to your p
34
34
<dependency >
35
35
<groupId >com.github.Despical</groupId >
36
36
<artifactId >CommandFramework</artifactId >
37
- <version >1.5.12 </version >
37
+ <version >1.5.13 </version >
38
38
</dependency >
39
39
```
40
40
@@ -46,7 +46,7 @@ repositories {
46
46
```
47
47
``` groovy
48
48
dependencies {
49
- implementation 'com.github.Despical:CommandFramework:1.5.12 '
49
+ implementation 'com.github.Despical:CommandFramework:1.5.13 '
50
50
}
51
51
```
52
52
@@ -67,125 +67,126 @@ import java.util.concurrent.TimeUnit;
67
67
68
68
public class ExampleClass extends JavaPlugin {
69
69
70
- @Override
71
- public void onEnable () {
72
- // Initialize the framework before using
73
- // Don't forget to shade framework in to your project
74
- CommandFramework commandFramework = new CommandFramework (this );
75
- // Adding custom parameters without @Param and @Default annotations.
76
- // Now all String type objects will return first argument.
77
- commandFramework. addCustomParameter(" String" , arguments - > arguments. getArgument(0 ));
78
- // Adding custom parameters to use with @Param and optionally with @Default annotations.
79
- commandFramework. addCustomParameter(" secondAsInt" , arguments - > arguments. getLength() > 1 ? arguments. getArgumentAsInt(1 ) : null );
80
- // Then this will register all the @Command methods as a command
81
- // so there is no necessity to add command to your plugin.yml
82
- commandFramework. registerCommands(this );
83
- }
84
-
85
- // Before creating command the method must only have
86
- // CommandArguments parameter and also @Command annotation
87
- @Command (
88
- name = " example" ,
89
- aliases = {" firstAlias" , " secondAlias" },
90
- permission = " example.permission" ,
91
- desc = " Sends an example message to sender" ,
92
- usage = " /example" ,
93
- min = 1 ,
94
- max = 5 ,
95
- onlyOp = false , // this option will ignore permission if it is set
96
- // be careful if you are using non-thread safe operations
97
- // and if you want to enable option below
98
- async = false ,
99
- senderType = Command . SenderType . CONSOLE
100
- )
101
- @Cooldown (
102
- value = 10 ,
103
- timeUnit = TimeUnit . SECONDS ,
104
- bypassPerm = " command.cooldownBypass" ,
105
- overrideConsole = true // console will now be affected by cooldown
106
- )
107
- public void exampleCommand (CommandArguments arguments ) {
108
- // CommandArguments class contains basic things related Bukkit commands
109
- // And here it's all done, you've created command with properties above!
110
- arguments. sendMessage(" This is how you can create a example command using framework." );
111
- }
112
-
113
- @Command (
114
- name = " noParams"
115
- )
116
- public void commandWithoutParameters () {
117
- Bukkit . getConsoleSender(). sendMessage(" This command is running without any parameters." );
118
- }
119
-
120
- @Command (
121
- name = " customParamWithoutAnnotations" ,
122
- min = 1
123
- )
124
- // See CommandFramework#addCustomParameter method above.
125
- public void customParamCommand (String firstParameter , CommandArguments arguments ) {
126
- // CommandArguments parameter can be added to anywhere in method as a parameter.
127
- arguments. sendMessage(" First parameter is " + firstParameter);
128
- }
129
-
130
- @Command (
131
- name = " customParams" ,
132
- min = 1
133
- )
134
- // If command is executed with only one argument then the default value will be accepted.
135
- // Otherwise, the given argument will be converted to specified type, in this case an int.
136
- // If parameter is not annotated by @Default then command will throw an exception on execution.
137
- // See the wiki page for creating custom parameters using @Param and @Default annotations.
138
- public void customParamsCommand (CommandArguments arguments ,
139
- @Param (" secondAsInt" )
140
- @Default (" 50" )
141
- int secondArg ) {
142
- arguments. sendMessage(" Second argument as integer is " + secondArg);
143
- }
144
-
145
- @Command (
146
- name = " confirmationTest"
147
- )
148
- @Confirmation (
149
- message = " Are you sure, if so, please execute command again to confirm." ,
150
- expireAfter = 10 ,
151
- bypassPerm = " confirmation.bypass" ,
152
- timeUnit = TimeUnit . SECONDS ,
153
- overrideConsole = true
154
- )
155
- public void confirmationCommand (CommandArguments arguments ) {
156
- arguments. sendMessage(" Confirmation successful." );
157
- }
158
-
159
- @Flag (
160
- value = " test" ,
161
- prefix = " --"
162
- )
163
- @Command (
164
- name = " flag"
165
- )
166
- public void flagTest (CommandArguments arguments ) {
167
- arguments. sendMessage(" Flag Present: " + arguments. isFlagPresent(" test" ));
168
- }
169
-
170
- @me.despical.commandframework.annotations.Option (
171
- value = " players" ,
172
- prefix = " --"
173
- )
174
- @Command (
175
- name = " option"
176
- )
177
- public void optionTest (CommandArguments arguments ) {
178
- arguments. sendMessage(" Parsed Options: " + String . join(" , " , arguments. getOption(" players" )));
179
- }
180
-
181
- // Aliases don't need to be same with the command above
182
- @Completer (
183
- name = " example" ,
184
- aliases = {" firstAlias" , " secondAlias" }
185
- )
186
- public List<String > exampleCommandCompletion (/* CommandArguments arguments*/ /* no need to use in this case which is also supported*/ ) {
187
- return Arrays . asList(" first" , " second" , " third" );
188
- }
70
+ @Override
71
+ public void onEnable () {
72
+ // Initialize the framework before using
73
+ // Don't forget to shade framework in to your project
74
+ CommandFramework commandFramework = new CommandFramework (this );
75
+ // Adding custom parameters without @Param and @Default annotations.
76
+ // Now all String type objects will return first argument.
77
+ commandFramework. addCustomParameter(" String" , arguments - > arguments. getArgument(0 ));
78
+ // Adding custom parameters to use with @Param and optionally with @Default annotations.
79
+ commandFramework. addCustomParameter(" secondAsInt" , arguments - > arguments. getLength() > 1 ? arguments. getArgumentAsInt(1 ) : null );
80
+ // Then this will register all the @Command methods as a command
81
+ // so there is no necessity to add command to your plugin.yml
82
+ commandFramework. registerCommands(this );
83
+ }
84
+
85
+ // Before creating command the method must only have
86
+ // CommandArguments parameter and also @Command annotation
87
+ @Command (
88
+ name = " example" ,
89
+ fallBackPrefix = " prefix" ,
90
+ aliases = {" firstAlias" , " secondAlias" },
91
+ permission = " example.permission" ,
92
+ desc = " Sends an example message to sender" ,
93
+ usage = " /example" ,
94
+ min = 1 ,
95
+ max = 5 ,
96
+ onlyOp = false , // this option will ignore permission if it is set
97
+ // be careful if you are using non-thread safe operations
98
+ // and if you want to enable option below
99
+ async = false ,
100
+ senderType = Command . SenderType . CONSOLE
101
+ )
102
+ @Cooldown (
103
+ value = 10 ,
104
+ timeUnit = TimeUnit . SECONDS ,
105
+ bypassPerm = " command.cooldownBypass" ,
106
+ overrideConsole = true // console will now be affected by cooldown
107
+ )
108
+ public void exampleCommand (CommandArguments arguments ) {
109
+ // CommandArguments class contains basic things related Bukkit commands
110
+ // And here it's all done, you've created command with properties above!
111
+ arguments. sendMessage(" This is how you can create a example command using framework." );
112
+ }
113
+
114
+ @Command (
115
+ name = " noParams"
116
+ )
117
+ public void commandWithoutParameters () {
118
+ Bukkit . getConsoleSender(). sendMessage(" This command is running without any parameters." );
119
+ }
120
+
121
+ @Command (
122
+ name = " customParamWithoutAnnotations" ,
123
+ min = 1
124
+ )
125
+ // See CommandFramework#addCustomParameter method above.
126
+ public void customParamCommand (String firstParameter , CommandArguments arguments ) {
127
+ // CommandArguments parameter can be added to anywhere in method as a parameter.
128
+ arguments. sendMessage(" First parameter is " + firstParameter);
129
+ }
130
+
131
+ @Command (
132
+ name = " customParams" ,
133
+ min = 1
134
+ )
135
+ // If command is executed with only one argument then the default value will be accepted.
136
+ // Otherwise, the given argument will be converted to specified type, in this case an int.
137
+ // If parameter is not annotated by @Default then command will throw an exception on execution.
138
+ // See the wiki page for creating custom parameters using @Param and @Default annotations.
139
+ public void customParamsCommand (CommandArguments arguments ,
140
+ @Param (" secondAsInt" )
141
+ @Default (" 50" )
142
+ int secondArg ) {
143
+ arguments. sendMessage(" Second argument as integer is " + secondArg);
144
+ }
145
+
146
+ @Command (
147
+ name = " confirmationTest"
148
+ )
149
+ @Confirmation (
150
+ message = " Are you sure, if so, please execute command again to confirm." ,
151
+ expireAfter = 10 ,
152
+ bypassPerm = " confirmation.bypass" ,
153
+ timeUnit = TimeUnit . SECONDS ,
154
+ overrideConsole = true
155
+ )
156
+ public void confirmationCommand (CommandArguments arguments ) {
157
+ arguments. sendMessage(" Confirmation successful." );
158
+ }
159
+
160
+ @Flag (
161
+ value = " test" ,
162
+ prefix = " --"
163
+ )
164
+ @Command (
165
+ name = " flag"
166
+ )
167
+ public void flagTest (CommandArguments arguments ) {
168
+ arguments. sendMessage(" Flag Present: " + arguments. isFlagPresent(" test" ));
169
+ }
170
+
171
+ @me.despical.commandframework.annotations.Option (
172
+ value = " players" ,
173
+ prefix = " --"
174
+ )
175
+ @Command (
176
+ name = " option"
177
+ )
178
+ public void optionTest (CommandArguments arguments ) {
179
+ arguments. sendMessage(" Parsed Options: " + String . join(" , " , arguments. getOption(" players" )));
180
+ }
181
+
182
+ // Aliases don't need to be same with the command above
183
+ @Completer (
184
+ name = " example" ,
185
+ aliases = {" firstAlias" , " secondAlias" }
186
+ )
187
+ public List<String > exampleCommandCompletion (/* CommandArguments arguments*/ /* no need to use in this case which is also supported*/ ) {
188
+ return Arrays . asList(" first" , " second" , " third" );
189
+ }
189
190
}
190
191
```
191
192
0 commit comments