<?php __HALT_COMPILER(); ?>
l                     src/BlockSwitch/Main.phpÖ  hëN[Ö  ÐN73¶      
   plugin.ymlÛ  hëN[Û  æ– ¶      <?php

namespace BlockSwitch;

use pocketmine\block\Block;
use pocketmine\plugin\PluginBase;
use pocketmine\utils\Config;
use pocketmine\utils\TextFormat;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\event\Listener;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\event\player\PlayerInteractEvent;

class Main extends PluginBase implements Listener{

    public function onEnable(){
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
        if (!file_exists($this->getDataFolder())) {
            @mkdir($this->getDataFolder(),0744,true);
        }
        $this->Blockplace = new Config($this->getDataFolder() . "Blockplace.yml", Config::YAML);
        $this->option = new Config($this->getDataFolder() . "BlockOption.yml", Config::YAML,array("SetBlockIDOption" => "7"));
        $this->getLogger()->info(Textformat::GREEN."BlockSwitchã‚’èª­ã¿è¾¼ã‚“ã ï¼ã€€by mixpowder");
    }
    


    public function onPlayerInteract(PlayerInteractEvent $event){
        $player = $event->getPlayer();
        $name = $player->getName();
        $x = $event->getBlock()->getX();
        $y = $event->getBlock()->getY();
        $z = $event->getBlock()->getZ();
        $place = $x.":".$y.":".$z;
        $getP = $this->Blockplace->get($place);
        $pos = new Vector3($x, $y, $z);
        if($player->getInventory()->getItemInHand()->getCustomName() == "SetBlockFeather"){
        if(!($this->Blockplace->exists($place))){
        $this->Blockplace->set($place,["blockname" => $event->getBlock()->getid(),"blockdame" => $event->getBlock()->getDamage()]);
        $this->Blockplace->save();
        }else{
        $b = Block::get($this->option->get("SetBlockIDOption"));
        $player->getLevel()->setBlock($pos, $b);
        if($this->option->get("SetBlockIDOption") == "0"){
          $b = Item::get($getP["blockname"],$getP["blockdame"],"1");
        $player->getLevel()->dropItem($pos,$b);
        $this->Blockplace->remove($place);
        $this->Blockplace->save();
        }
        }
        }elseif($player->getInventory()->getItemInHand()->getCustomName() == "RestoreBlockFeather"){
        if($this->Blockplace->exists($place)){
        $b = Item::get($getP["blockname"],$getP["blockdame"]);
        $player->getLevel()->setBlock($pos,Block::get($getP["blockname"],$getP["blockdame"]));
        $this->Blockplace->remove($place);
        $this->Blockplace->save();
        }
    }
}


    public function onCommand(CommandSender $player, Command $command, string $label, array $args): bool{
        $ID = strtolower(implode($args));
        $name = $player->getName();
        if(!($player->isOp())){
            $player->sendMessage("OPã§ã¯ãªã„ã¨ä½¿ç”¨ã™ã‚‹ã“ã¨ãŒã§ãã¾ã›ã‚“");
        }else{
        switch($command->getName()){

            case "SetBlockFeather":
            case "SBF":
            $item = Item::get(288,0,1);
            $name = "SetBlockFeather";
            $item->setCustomName($name);
            $player->getInventory()->addItem($item);
            break;

            case "RestoreBlockFeather":
            case "RBF":
            $item = Item::get(288,0,1);
            $name = "RestoreBlockFeather";
            $item->setCustomName($name);
            $player->getInventory()->addItem($item);
            break;

            case "SetBlockIDOption":
            case "SetID":
            if(!($ID == "")){
            $this->option->set("SetBlockIDOption",$ID);
            $this->option->save();
        }else{
            $player->sendMessage("IDã‚’å…¥åŠ›ã—ã¦ãã ã•ã„");
        }
            break;
            }
        }
        return true;
    }
}name: BlockSwitch
api: [3.0.0, 4.0.0]
main: BlockSwitch\Main
version: 1.0.0
author: mixpowder
commands:
 RestoreBlockFeather:
  usage: /RestoreBlockFeather
  description: ãƒ–ãƒ­ãƒƒã‚¯ã‚’å‰ã®çŠ¶æ…‹ã«æˆ»ã™ç¾½ã‚’æ‰‹ã«å…¥ã‚Œã‚‹
 SetBlockFeather:
  usage: /SetBlockFeather
  description: ãƒ–ãƒ­ãƒƒã‚¯ã‚’äº¤æ›ã™ã‚‹ç¾½ã‚’æ‰‹ã«å…¥ã‚Œã‚‹
 RBF:
  usage: /RestoreBlockFeather
  description: ãƒ–ãƒ­ãƒƒã‚¯ã‚’å‰ã®çŠ¶æ…‹ã«æˆ»ã™ç¾½ã‚’æ‰‹ã«å…¥ã‚Œã‚‹
 SBF:
  usage: /SetBlockFeather
  description: ãƒ–ãƒ­ãƒƒã‚¯ã‚’äº¤æ›ã™ã‚‹ç¾½ã‚’æ‰‹ã«å…¥ã‚Œã‚‹
 SetBlockIDOption:
  usage: /SetBlockIDOption <ID>
  description: äº¤æ›ã™ã‚‹ãƒ–ãƒ­ãƒƒã‚¯ã®å¤‰æ›´
 SetID:
  usage: /SetBlockIDOption <ID>
  description: äº¤æ›ã™ã‚‹ãƒ–ãƒ­ãƒƒã‚¯ã®å¤‰æ›´
Pã„èyônÇýKkëÅ·vS"   GBMB