Merge pull request #43 from Setadokalo/fix-permisson-suggestions

Fix permissions suggestions to only suggest completions of already typed text
This commit is contained in:
Flemmli97 2021-04-04 12:10:30 +02:00 committed by GitHub
commit ebc3fc690c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,6 +37,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.Collection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@ -495,14 +496,15 @@ public class CommandClaim {
ServerWorld world = context.getSource().getWorld();
Claim claim = ClaimStorage.get(world).getClaimAt(new BlockPos(context.getSource().getPosition()));
boolean admin = claim != null && claim.isAdminClaim();
List<String> allowedPerms = new ArrayList<>();
for (ClaimPermission perm : PermissionRegistry.getPerms()) {
if (!admin && ConfigHandler.config.globallyDefined(world, perm)) {
continue;
}
if (!group || !PermissionRegistry.globalPerms().contains(perm))
build.suggest(perm.id);
allowedPerms.add(perm.id);
}
return build.buildFuture();
return CommandSource.suggestMatching(allowedPerms, build);
}
private static int editGlobalPerm(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {