Fabric API

Fabric API

152M Downloads

[1.21.6] Permission level check for `FabricClientCommandSource`

jebibot opened this issue ยท 5 comments

commented

As of 1.21.6, net.minecraft.client.network.ClientCommandSource implements not only net.minecraft.command.CommandSource but also PermissionLevelSource.

It'd be useful if FabricClientCommandSource extend PermissionLevelSource and implement permission level checks.

commented

I agree, I dont really think this is feasible as the behaviour will differ between single and multiplyer. You can still add your own checks for creative or op (does the client even know if its an op?) within your command.

commented

I don't think it is the case. Permissions don't really make sense for client commands

commented

@cputnam-a11y My use case is to show client-side debug commands, that have no meaning for normal users, only to OPs.

commented

I thought this would work out of box, as ClientCommandSource implements PermissionLevelSource, but it doesn't. Its implementation also has changed from:

    public boolean hasPermissionLevel(int level) {
        ClientPlayerEntity clientPlayerEntity = this.client.player;
        return clientPlayerEntity != null ? clientPlayerEntity.hasPermissionLevel(level) : level == 0;
    }

to:

    public boolean hasPermissionLevel(int level) {
        return this.elevatedPermissions || level == 0;
    }

and client commands are executed with elevatedPermissions = true.

commented

Given then that the implementation is not really useful for client commands, I'd say this can be closed. IIRC the concrete implementation of FabricClientCommandSource is the vanilla class.