new perms and suggestions

This commit is contained in:
hyperdefined
2025-05-06 18:42:52 -04:00
parent f71d079e23
commit 5373792480
2 changed files with 27 additions and 0 deletions

View File

@@ -39,6 +39,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
public class CommandToolStats implements TabExecutor { public class CommandToolStats implements TabExecutor {
@@ -1114,12 +1115,32 @@ public class CommandToolStats implements TabExecutor {
if (sender.hasPermission("toolstats.givetokens")) { if (sender.hasPermission("toolstats.givetokens")) {
suggestions.add("givetokens"); suggestions.add("givetokens");
} }
if (sender.hasPermission("toolstats.edit")) {
suggestions.add("edit");
}
if (sender.hasPermission("toolstats.remove")) {
suggestions.add("remove");
}
return suggestions.isEmpty() ? null : suggestions; return suggestions.isEmpty() ? null : suggestions;
} }
if (args.length == 2 && args[0].equalsIgnoreCase("reset") && sender.hasPermission("toolstats.reset.confirm")) { if (args.length == 2 && args[0].equalsIgnoreCase("reset") && sender.hasPermission("toolstats.reset.confirm")) {
return Collections.singletonList("confirm"); return Collections.singletonList("confirm");
} }
if (args.length == 2 && args[0].equalsIgnoreCase("edit") && sender.hasPermission("toolstats.edit")) {
// yes I am lazy
return toolStats.tokenCrafting.getTokenTypes().stream()
.filter(s -> !s.equals("remove") && !s.equals("reset"))
.map(s -> s.equals("crops-mined") ? "crops-harvested" : s)
.collect(Collectors.toList());
}
if (args.length == 2 && args[0].equalsIgnoreCase("remove") && sender.hasPermission("toolstats.remove")) {
// yes I am lazy
return toolStats.tokenCrafting.getTokenTypes().stream()
.filter(s -> !s.equals("remove") && !s.equals("reset"))
.map(s -> s.equals("crops-mined") ? "crops-harvested" : s)
.collect(Collectors.toList());
}
if (args.length == 3 && args[0].equalsIgnoreCase("givetokens") && sender.hasPermission("toolstats.givetokens")) { if (args.length == 3 && args[0].equalsIgnoreCase("givetokens") && sender.hasPermission("toolstats.givetokens")) {
return toolStats.tokenCrafting.getTokenTypes(); return toolStats.tokenCrafting.getTokenTypes();
} }

View File

@@ -25,4 +25,10 @@ permissions:
default: true default: true
toolstats.givetokens: toolstats.givetokens:
description: Allows the usage of /toolstats givetoken. description: Allows the usage of /toolstats givetoken.
default: op
toolstats.edit:
description: Allows the usage of /toolstats edit.
default: op
toolstats.remove:
description: Allows the usage of /toolstats remove.
default: op default: op