Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to give plugin.yml permissions to console only #6499

Open
Gaprix opened this issue Nov 12, 2024 · 2 comments
Open

Ability to give plugin.yml permissions to console only #6499

Gaprix opened this issue Nov 12, 2024 · 2 comments
Labels
Category: API Related to the plugin API Easy task Probably really easy to do, good task for first-time contributors Type: Enhancement Contributes features or other improvements to PocketMine-MP

Comments

@Gaprix
Copy link
Contributor

Gaprix commented Nov 12, 2024

Description

Now if you specify the permission, marked as "default: false", the console won't be able to run the command

permissions:
  myplugin.command.test:
    default: false

I suggest allowing the ConsoleCommandSender to execute such commands

Justification

It is often necessary to restrict a dangerous (or unwanted) command even to server operators. In this case, access to this command can be given manually to players through the permission manager. But in that case, the ConsoleCommandSender will lose the access to it, which is confusing

Alternative methods

Code like this may be used to force-grant the permission

$server = Server::getInstance();
$refObj = new \ReflectionObject($server);
$field = $refObj->getProperty("consoleSender");
$field->setAccessible(true);

$permission = PermissionManager::getInstance()->getPermission("myplugin.command.test");

$consoleSender = new ConsoleCommandSender($server, $server->getLanguage());
$consoleSender->addAttachment($this)->setPermission($permission, true);

$field->setValue($server, $consoleSender);
@dktapps
Copy link
Member

dktapps commented Nov 12, 2024

This works as intended. Changing it the way you want would be misleading.

What we really need is a way to specify pocketmine.group.console in plugin.yml. Currently it's not possible to say default: console or similar.

@dktapps dktapps changed the title Grant ConsoleCommandSender the ability to execute commands with "default: false" permissions Ability to restrict plugin.yml commands to console Nov 12, 2024
@dktapps dktapps added Category: API Related to the plugin API Type: Enhancement Contributes features or other improvements to PocketMine-MP Easy task Probably really easy to do, good task for first-time contributors labels Nov 12, 2024
@dktapps dktapps changed the title Ability to restrict plugin.yml commands to console Ability to give plugin.yml permissions to console only Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: API Related to the plugin API Easy task Probably really easy to do, good task for first-time contributors Type: Enhancement Contributes features or other improvements to PocketMine-MP
Projects
None yet
Development

No branches or pull requests

2 participants