Skip to content

Commit 5373792

Browse files
committed
new perms and suggestions
1 parent f71d079 commit 5373792

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/main/java/lol/hyper/toolstats/commands/CommandToolStats.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.jetbrains.annotations.Nullable;
4040

4141
import java.util.*;
42+
import java.util.stream.Collectors;
4243

4344
public class CommandToolStats implements TabExecutor {
4445

@@ -1114,12 +1115,32 @@ public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Comman
11141115
if (sender.hasPermission("toolstats.givetokens")) {
11151116
suggestions.add("givetokens");
11161117
}
1118+
if (sender.hasPermission("toolstats.edit")) {
1119+
suggestions.add("edit");
1120+
}
1121+
if (sender.hasPermission("toolstats.remove")) {
1122+
suggestions.add("remove");
1123+
}
11171124
return suggestions.isEmpty() ? null : suggestions;
11181125
}
11191126

11201127
if (args.length == 2 && args[0].equalsIgnoreCase("reset") && sender.hasPermission("toolstats.reset.confirm")) {
11211128
return Collections.singletonList("confirm");
11221129
}
1130+
if (args.length == 2 && args[0].equalsIgnoreCase("edit") && sender.hasPermission("toolstats.edit")) {
1131+
// yes I am lazy
1132+
return toolStats.tokenCrafting.getTokenTypes().stream()
1133+
.filter(s -> !s.equals("remove") && !s.equals("reset"))
1134+
.map(s -> s.equals("crops-mined") ? "crops-harvested" : s)
1135+
.collect(Collectors.toList());
1136+
}
1137+
if (args.length == 2 && args[0].equalsIgnoreCase("remove") && sender.hasPermission("toolstats.remove")) {
1138+
// yes I am lazy
1139+
return toolStats.tokenCrafting.getTokenTypes().stream()
1140+
.filter(s -> !s.equals("remove") && !s.equals("reset"))
1141+
.map(s -> s.equals("crops-mined") ? "crops-harvested" : s)
1142+
.collect(Collectors.toList());
1143+
}
11231144
if (args.length == 3 && args[0].equalsIgnoreCase("givetokens") && sender.hasPermission("toolstats.givetokens")) {
11241145
return toolStats.tokenCrafting.getTokenTypes();
11251146
}

src/main/resources/plugin.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,10 @@ permissions:
2525
default: true
2626
toolstats.givetokens:
2727
description: Allows the usage of /toolstats givetoken.
28+
default: op
29+
toolstats.edit:
30+
description: Allows the usage of /toolstats edit.
31+
default: op
32+
toolstats.remove:
33+
description: Allows the usage of /toolstats remove.
2834
default: op

0 commit comments

Comments
 (0)