<?php __HALT_COMPILER(); ?>
q                     src/chest/ChestClear/Main.phpA  ê,&\A  ¤¸¶      
   plugin.yml¬   ê,&\¬   �·9�¶      <?php

namespace chest\ChestClear;

use pocketmine\command\CommandSender;
use pocketmine\command\Command;
use pocketmine\plugin\PluginBase;
use pocketmine\Server;
use pocketmine\Player;
use pocketmine\inventory\PlayerInventory;
use pocketmine\item\Item;
use pocketmine\event\Listener;
use pocketmine\item\enchantment\Enchantment;
use pocketmine\item\enchantment\EnchantmentInstance;
use pocketmine\event\block\BlockBreakEvent;
use pocketmine\event\EventPriority;
use pocketmine\plugin\MethodEventExecutor;
use pocketmine\level\Level;
use pocketmine\block\Block;
use pocketmine\math\Vector3;
use pocketmine\tile\Tile;
use pocketmine\tile\Chest;
use pocketmine\tile\TileChest;

class Main extends PluginBase implements Listener{

    public function onEnable(){
        $this->getLogger()->info("§aChestClearを読み込みました。　製作者ryota3422");
        $this->getServer()->getPluginManager()->registerEvent("pocketmine\\event\\block\\BlockBreakEvent", $this, EventPriority::HIGHEST, new MethodEventExecutor("onBreakEvent"), $this);
    }

    public function onDisable(){
        
    }

    public function onCommand(CommandSender $sender, Command $command, string $label, array $args):bool{
         switch ($command->getName()) {
            case "ccitem":  
                  if($sender instanceof Player){
                    $item = Item::get(445,0,1);
                    $name=("チェスト消去アイテム");
                    $item->setCustomName($name);
                    $enchantment = Enchantment::getEnchantment(15);
                    $item->addEnchantment(new EnchantmentInstance( $enchantment,5));
                  if($sender->getInventory()->canAddItem($item)){
                    $sender->getInventory()->addItem($item);
                    $sender->sendMessage("§a[ChestClear]アイテムを付与しました。不要になった場合溶岩に捨ててください。");
                    break;
                  }else{
                    $sender->sendMessage("§a[ChestClear]インベントリがいっぱいです。開けてください。");
                    break;
                   }
                  }else{
                    $this->getLogger()->info("§e[ChestClear] §cコンソールからの実行は不可能です。");
                    break;
                  }

         }
    return true;
  }

     public function onBreakEvent(BlockBreakEvent $event){
         $player=$event->getPlayer();
         $breakitemid=$event->getItem()->getID();
         $targetitemid=("445");
         if($breakitemid==$targetitemid){
          $targetchestid=("54");
          if ($event->getBlock()->getID()==$targetchestid){
           $level=$player->getLevel();
           $block=$event->getBlock();
           $chestx=$block->getX();
           $chesty=$block->getY();
           $chestz=$block->getZ();
           $pos = new Vector3($chestx,$chesty,$chestz);
           $chest = $level->getTile($pos);
           $chest->getInventory()->clearall();
           $chest->saveNBT();
           $player->sendMessage("§a[ChestClear]指定したチェストの中身を消去しました。");
           $level->save();
          }else{
          $player->sendMessage("§a[ChestClear]そのブロックはチェストではありません。チェストを指定してください");
          }
          }else{
         }
     }
}

name: ChestClear
author: ryota3422
version: 1.0.0
api: 3.0.0
main: chest\ChestClear\Main
commands:
  ccitem:
    description: §9<警察以上>消去用アイテム付与

MeøUÒPòbbÞs/iP;`›ïô   GBMB