Skip to content

Commit 5bc666c

Browse files
committed
Added optional permission to tab completer
1 parent 096c67e commit 5bc666c

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

.github/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ To add this project as a dependency to your project, add the following to your p
3939
<dependency>
4040
<groupId>com.github.Despical</groupId>
4141
<artifactId>CommandFramework</artifactId>
42-
<version>1.1.7</version>
42+
<version>1.1.8</version>
4343
<scope>compile</scope>
4444
</dependency>
4545
```
@@ -52,7 +52,7 @@ repositories {
5252
```
5353
```
5454
dependencies {
55-
compileOnly group: "com.github.Despical", name: "CommandFramework", version: "1.1.7";
55+
compileOnly group: "com.github.Despical", name: "CommandFramework", version: "1.1.8";
5656
}
5757
```
5858

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>me.despical</groupId>
55
<artifactId>command-framework</artifactId>
6-
<version>1.1.7</version>
6+
<version>1.1.8</version>
77

88
<properties>
99
<java.version>8</java.version>
@@ -48,7 +48,7 @@
4848
<dependency>
4949
<groupId>com.github.Despical</groupId>
5050
<artifactId>Commons</artifactId>
51-
<version>1.6.0</version>
51+
<version>1.6.1</version>
5252
</dependency>
5353
</dependencies>
5454

src/main/java/me/despical/commandframework/CommandFramework.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull org.bu
337337

338338
if (entry == null) return null;
339339

340+
final String permission = entry.getKey().permission();
341+
342+
if (!permission.isEmpty() && !sender.hasPermission(permission)) return null;
343+
340344
try {
341345
final Object instance = entry.getValue().getKey().invoke(entry.getValue().getValue(), new CommandArguments(sender, cmd, label, args));
342346

src/main/java/me/despical/commandframework/Completer.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import java.lang.annotation.Target;
2424

2525
/**
26-
* An utility class in framework to create argument completions
26+
* A utility class in framework to create argument completions
2727
* for commands.
2828
*
2929
* @author Despical
@@ -42,6 +42,13 @@
4242
*/
4343
String name();
4444

45+
/**
46+
* The permission that sender must have to receive tab complete.
47+
*
48+
* @return name of the permission
49+
*/
50+
String permission() default "";
51+
4552
/**
4653
* An alternative name list of command. Check {@link #name()}
4754
* to understand how command names work.

0 commit comments

Comments
 (0)