Skip to content

Commit

Permalink
Fix /estools tab complete displaying error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
CoPokBl committed May 23, 2024
1 parent a8fdab3 commit 0cb0c76
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.serble.EsTools</groupId>
<artifactId>EsTools</artifactId>
<version>4.3.0</version>
<version>4.3.1</version>
<packaging>jar</packaging>

<name>EsTools</name>
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/serble/estools/Commands/EsTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ public List<String> tabComplete(CommandSender sender, String[] args, String lArg
List<String> tab = new ArrayList<>();

if (args.length == 1) {
if (checkPerms(sender, "reload")) tab.add("reload");
if (checkPerms(sender, "version")) tab.add("version");
if (checkPerms(sender, "reset")) tab.add("reset");
if (checkPerms(sender, "test")) tab.add("test");
if (checkPerms(sender, "update")) {
if (hasPerm(sender, "reload")) tab.add("reload");
if (hasPerm(sender, "version")) tab.add("version");
if (hasPerm(sender, "reset")) tab.add("reset");
if (hasPerm(sender, "test")) tab.add("test");
if (hasPerm(sender, "update")) {
tab.add("update");
tab.add("forceupdate");
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/net/serble/estools/EsToolsCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ public static double tryParseDouble(String obj, double defaultValue) {
return defaultValue;
}
}

// This is different from checkPerms because it doesn't display any messages
public static boolean hasPerm(CommandSender sender, String perm) {
return sender.hasPermission("estools." + perm);
}

public static boolean checkPerms(CommandSender sender, String perm) {
if (!sender.hasPermission("estools." + perm)) {
Expand Down

0 comments on commit 0cb0c76

Please sign in to comment.