예제 #1
0
 /**
  * @param CommandSender $sender
  * @param string $commandLabel
  * @param string[] $args
  *
  * @return mixed
  */
 public function execute(CommandSender $sender, $commandLabel, array $args)
 {
     if ($sender->hasPermission("chestrefill.command")) {
         if (isset($args[0])) {
             switch ($args[0]) {
                 case 'add':
                     if (isset($args[1])) {
                         $pattern = $this->main->getPatternStore()->getPattern($args[1]);
                         if ($pattern !== null) {
                             $pattern::startWizard($sender, $args, $this->main);
                         } else {
                             $sender->sendMessage("That pattern doesn't exist.");
                         }
                     } else {
                         $sender->sendMessage("You must specify a pattern type.");
                     }
                     break;
                 default:
                     $sender->sendMessage("Unknown subcommand.");
                     break;
             }
         } else {
             $sender->sendMessage("Running ChestRefill v" . $this->main->getDescription()->getVersion());
         }
     } else {
         $sender->sendMessage("You don't have permission to use this command.");
     }
 }
예제 #2
0
 public function load()
 {
     foreach ($this->config->getAll() as $chestData) {
         $level = $this->main->getServer()->getLevelByName($chestData["levelName"]);
         if ($level instanceof Level) {
             $chest = new Chest(new Position($chestData["x"], $chestData["y"], $chestData["z"], $level));
             $chestTile = $chest->getChest();
             if ($chestTile instanceof \pocketmine\tile\Chest) {
                 $pattern = $this->main->getPatternStore()->makePattern($chestData["patternName"], $chestData["patternArgs"]);
                 if ($pattern instanceof ChestPattern) {
                     $chest->setPattern($pattern);
                     $this->chests[] = $chest;
                 } else {
                     $this->main->getLogger()->warning("Failed to load a chest: Pattern data invalid.");
                 }
             } else {
                 $this->main->getLogger()->warning("Failed to load a chest: No chest at position.");
             }
         } else {
             $this->main->getLogger()->warning("Failed to load a chest: Level is not loaded.");
         }
     }
 }