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

Everyone can see the command #119

Closed
AmeerReal opened this issue Feb 16, 2019 · 2 comments
Closed

Everyone can see the command #119

AmeerReal opened this issue Feb 16, 2019 · 2 comments
Labels

Comments

@AmeerReal
Copy link

AmeerReal commented Feb 16, 2019

But if the player doesn't have permission he can't use the command, how can I hide the command for the Non-Perm players? Even with PurePerms and default: op or default: false I can't.

@AmeerReal AmeerReal changed the title Everone can see the command Everyone can see the command Feb 16, 2019
@falkirks falkirks added the bug label Feb 16, 2019
@AmeerReal
Copy link
Author

AmeerReal commented Feb 17, 2019

I fixed it with this code in the MineReset/src/falkirks/minereset/command/MineCommand.php file

<?php

namespace falkirks\minereset\command;


use falkirks\minereset\MineReset;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\command\PluginIdentifiableCommand;
use pocketmine\Player;
use pocketmine\plugin\Plugin;

class MineCommand extends Command implements PluginIdentifiableCommand {
    /** @var MineReset  */
    protected $api;
    /** @var  SubCommand[] */
    protected $subCommands;
    public function __construct(MineReset $api){
        parent::__construct("mine", "Mine reset command", "/mine <create|set|list|reset|reset-all|destroy|report> <name> [parameters]");
	$this->setPermission("mine.command");
        $this->api = $api;
        $this->subCommands = [];
    }
    /**
     * @param CommandSender $sender
     * @param string $commandLabel
     * @param string[] $args
     *
     * @return mixed
     */
    public function execute(CommandSender $sender, string $commandLabel, array $args){
	if(!$this->testPermission($sender)){
			return true;
		}
        if(count($args) > 0 && array_key_exists($args[0], $this->subCommands)){
            return $this->subCommands[array_shift($args)]->execute($sender, $commandLabel, $args);
        }
        else{
            $sender->sendMessage($this->getUsage());
            return null;
        }
    }

    /**
     * @return \pocketmine\plugin\Plugin
     */
    public function getPlugin(): Plugin{
        return $this->api;
    }

    public function registerSubCommand(string $name, SubCommand $command, $aliases = []){
        $this->subCommands[$name] = $command;

        foreach ($aliases as $alias){
            if(!isset($this->subCommands[$alias])){
                $this->registerSubCommand($alias, $command);
            }
        }
    }
}

falkirks added a commit that referenced this issue Feb 18, 2019
@falkirks
Copy link
Owner

Thanks for sharing your fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants