Skip to content

Commit

Permalink
v0.1.15: Add a configuration to grant 'permissions' to tebex command …
Browse files Browse the repository at this point in the history
…sender
  • Loading branch information
Muqsit committed Jun 22, 2024
1 parent d2a149b commit abc8a0c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Tebex
main: muqsit\tebex\Loader
version: 0.1.14
version: 0.1.15
author: Muqsit
api: 5.0.0
permissions:
Expand Down
9 changes: 8 additions & 1 deletion resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ worker-limit: 2
# Sub-commands to disable. You may want to disable "secret" sub-command when running in production
# Example to disable "tbx secret" and "tbx info":
# disabled-sub-commands: [secret, info]
disabled-sub-commands: []
disabled-sub-commands: []

# Permissions given to Tebex command sender
# Example to grant Tebex the following permissions: "myplugin.command.addrandomtags", "myplugin.command.keypack":
# permissions:
# - myplugin.command.addrandomtags
# - myplugin.command.keypack
permissions: []
12 changes: 9 additions & 3 deletions src/muqsit/tebex/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,27 @@
use pocketmine\command\PluginCommand;
use pocketmine\plugin\PluginBase;
use RuntimeException;
use function array_fill_keys;
use function file_get_contents;

final class Loader extends PluginBase{

public const PERMISSION_GROUP_CONFIGURED = "tebex.permission.configured";

private TebexInformation $information;
private ?TebexHandler $handler = null;
private ?ConnectionBasedTebexApi $api = null;
private PluginCommand $command;
private int $worker_limit;

protected function onEnable() : void{
$config = new TypedConfig($this->getConfig());

if(!TebexCommandSender::hasInstance()){
TebexCommandSender::setInstance(new TebexCommandSender($this, $this->getServer()->getLanguage()));
$sender = new TebexCommandSender($this, $this->getServer()->getLanguage());
$attachment = $sender->addAttachment($this, self::PERMISSION_GROUP_CONFIGURED);
$attachment->setPermissions(array_fill_keys($config->getStringList("permissions"), true));
TebexCommandSender::setInstance($sender);
}

TebexApiStatics::setLogger(new PmmpTebexLogger($this->getLogger()));
Expand All @@ -45,8 +53,6 @@ protected function onEnable() : void{
$this->getServer()->getCommandMap()->register($this->getName(), $command);
$this->command = $command;

$config = new TypedConfig($this->getConfig());

$this->worker_limit = $config->getInt("worker-limit", 2);

$secret = $config->getString("secret");
Expand Down

0 comments on commit abc8a0c

Please sign in to comment.