-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
toby7002
committed
Oct 4, 2023
1 parent
1cb273d
commit 21cdf57
Showing
4 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/thebigcrafter/omp/commands/subcommands/ListCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of oh-my-pmmp. | ||
* (c) thebigcrafter <[email protected]> | ||
* This source file is subject to the GPL-3.0 license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace thebigcrafter\omp\commands\subcommands; | ||
|
||
use CortexPE\Commando\BaseSubCommand; | ||
use pocketmine\command\CommandSender; | ||
use pocketmine\Server; | ||
use thebigcrafter\omp\cache\PluginCache; | ||
use thebigcrafter\omp\cache\PluginsPool; | ||
use thebigcrafter\omp\OhMyPMMP; | ||
use function phpversion; | ||
|
||
class ListCommand extends BaseSubCommand { | ||
protected function prepare() : void { | ||
$this->setPermission("oh-my-pmmp.list"); | ||
} | ||
|
||
/** | ||
* @param array<string> $args | ||
*/ | ||
public function onRun(CommandSender $sender,string $aliasUsed,array $args) : void { | ||
foreach (PluginsPool::getStorage() as $plugin) { | ||
$this->renderBlock($sender, $plugin); | ||
} | ||
} | ||
|
||
private function renderBlock(CommandSender $sender, PluginCache $plugin) { | ||
$name = $plugin->getName(); | ||
$versions = implode(",", $plugin->getVersions()); | ||
$desc = $plugin->getShortDescription(); | ||
$homepage = $plugin->getHomepage(); | ||
$downloads = $plugin->getDownloads(); | ||
$score = $plugin->getScore(); | ||
$license = $plugin->getLicense(); | ||
|
||
$sender->sendMessage("================" . PHP_EOL); | ||
$sender->sendMessage("# Name: $name"); | ||
$sender->sendMessage("# Versions: $versions"); | ||
$sender->sendMessage("# Description: $desc"); | ||
$sender->sendMessage("# Homepage: $homepage"); | ||
$sender->sendMessage("# Downloads: $downloads"); | ||
$sender->sendMessage("# Score: $score"); | ||
$sender->sendMessage("# License: $license"); | ||
$sender->sendMessage("================" . PHP_EOL . PHP_EOL); | ||
} | ||
} |