|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * _ ____ _ __ _ _ _ ___ _ _____ _ _ ____ ___ _ _ _____ |
| 5 | + * / \ | _ \ | |/ / / \ | \ | | |_ _| / \ | ____| | \ | | / ___| |_ _| | \ | | | ____| |
| 6 | + * / _ \ | |_) | | ' / / _ \ | \| | | | / _ \ _____ | _| | \| | | | _ | | | \| | | _| |
| 7 | + * / ___ \ | _ < | . \ / ___ \ | |\ | | | / ___ \ |_____| | |___ | |\ | | |_| | | | | |\ | | |___ |
| 8 | + * /_/ \_\ |_| \_\ |_|\_\ /_/ \_\ |_| \_| |___| /_/ \_\ |_____| |_| \_| \____| |___| |_| \_| |_____| |
| 9 | + * |
| 10 | + * ArkaniaStudios-ANGE, une API conçue pour simplifier le développement. |
| 11 | + * Fournissant des outils et des fonctionnalités aux développeurs. |
| 12 | + * Cet outil est en constante évolution et est régulièrement mis à jour, |
| 13 | + * afin de répondre aux besoins changeants de la communauté. |
| 14 | + * |
| 15 | + * @author Julien |
| 16 | + * @link https://arkaniastudios.com |
| 17 | + * @version 0.2.0-beta |
| 18 | + * |
| 19 | + */ |
| 20 | + |
| 21 | +declare(strict_types=1); |
| 22 | + |
| 23 | +namespace arkania\commands\default; |
| 24 | + |
| 25 | +use arkania\commands\CommandBase; |
| 26 | +use arkania\commands\parameters\SubParameter; |
| 27 | +use arkania\npc\FormManager; |
| 28 | +use arkania\player\permissions\MissingPermissionException; |
| 29 | +use arkania\player\permissions\PermissionsBase; |
| 30 | +use pocketmine\command\CommandSender; |
| 31 | +use pocketmine\player\Player; |
| 32 | +use function strtolower; |
| 33 | + |
| 34 | +class NpcCommand extends CommandBase { |
| 35 | + public static array $npc = []; |
| 36 | + |
| 37 | + /** |
| 38 | + * @throws MissingPermissionException |
| 39 | + */ |
| 40 | + public function __construct() { |
| 41 | + parent::__construct( |
| 42 | + 'npc', |
| 43 | + 'Manage the NPCs', |
| 44 | + '/npc' |
| 45 | + ); |
| 46 | + $this->setPermission(PermissionsBase::getPermission('npc')); |
| 47 | + } |
| 48 | + |
| 49 | + public function getCommandParameter() : array { |
| 50 | + return [ |
| 51 | + new SubParameter('create', 'create', true), |
| 52 | + new SubParameter('disband', 'disband', true), |
| 53 | + new SubParameter('rotate', 'rotate', true), |
| 54 | + new SubParameter('edit', 'edit', true) |
| 55 | + ]; |
| 56 | + } |
| 57 | + |
| 58 | + public function onRun(CommandSender $sender, array $parameters) : void { |
| 59 | + if(!$sender instanceof Player) { |
| 60 | + return; |
| 61 | + } |
| 62 | + |
| 63 | + if($parameters === []) { |
| 64 | + FormManager::getInstance()->sendNpcCreationForm($sender); |
| 65 | + return; |
| 66 | + } |
| 67 | + $argument = strtolower($parameters['create']); |
| 68 | + if($argument === 'create') { |
| 69 | + FormManager::getInstance()->sendNpcCreationForm($sender); |
| 70 | + } elseif($argument === 'disband') { |
| 71 | + self::$npc[$sender->getName()] = 'disband'; |
| 72 | + $sender->sendMessage('§cTap on the NPC to disband it'); |
| 73 | + } elseif($argument === 'rotate') { |
| 74 | + self::$npc[$sender->getName()] = 'rotate'; |
| 75 | + $sender->sendMessage('§cTap on the NPC to rotate it'); |
| 76 | + } elseif($argument === 'edit') { |
| 77 | + self::$npc[$sender->getName()] = 'edit'; |
| 78 | + $sender->sendMessage('§cTap on the NPC to edit it'); |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | +} |
0 commit comments