Skip to content

Commit

Permalink
Register /tool with sub-command permission gen
Browse files Browse the repository at this point in the history
  • Loading branch information
octylFractal committed Jun 11, 2020
1 parent 5132c5e commit 2f41403
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Expand Up @@ -39,6 +39,7 @@
import com.sk89q.worldedit.command.tool.TreePlanter;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.SubCommandPermissionCondition;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
Expand Down Expand Up @@ -111,6 +112,8 @@ public static void register(CommandRegistrationHandler registration,
.required()
.build());
command.description(TextComponent.of("Binds a tool to the item in your hand"));

command.condition(new SubCommandPermissionCondition.Generator(nonGlobalCommands).build());
});
}

Expand Down
Expand Up @@ -19,10 +19,12 @@

package com.sk89q.worldedit.command.util;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import org.enginehub.piston.Command;
import org.enginehub.piston.inject.InjectedValueAccess;

import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Set;
Expand All @@ -45,8 +47,8 @@ public boolean satisfied(InjectedValueAccess context) {
public static class Generator {
private final List<Command> subCommands;

public Generator(List<Command> subCommands) {
this.subCommands = subCommands;
public Generator(Collection<? extends Command> subCommands) {
this.subCommands = ImmutableList.copyOf(subCommands);
}

public Command.Condition build() {
Expand Down

0 comments on commit 2f41403

Please sign in to comment.