<?php echo "Altay plugin if v2.1.1\nThis file has been generated using Turanic at Wed, 26 Sep 2018 12:14:39 +0900.\n----------------\n";if(extension_loaded("phar")){$phar = new \Phar(__FILE__);foreach($phar->getMetadata() as $key => $value){echo ucfirst($key).": ".(is_array($value) ? implode(", ", $value):$value)."\n";}} __HALT_COMPILER(); ?>
             ü   a:9:{s:4:"name";s:2:"if";s:7:"version";s:5:"2.1.1";s:4:"main";s:14:"aieuo\ifPlugin";s:3:"api";a:1:{i:0;s:5:"3.0.0";}s:6:"depend";a:0:{}s:11:"description";s:0:"";s:7:"authors";a:1:{i:0;s:5:"aieuo";}s:7:"website";s:0:"";s:12:"creationDate";i:1537931679;}
   plugin.ymlÄ   Ÿùª[Ä   yRP¶         src/aieuo/BlockManager.php;  Ÿùª[;  ¶5É£¶         src/aieuo/CommandManager.php  Ÿùª[  ¤	ö~¶         src/aieuo/ifAPI.php£:  Ÿùª[£:  GýHü¶         src/aieuo/ifPlugin.php°n  Ÿùª[°n  A?Ì«¶      name: if
main: aieuo\ifPlugin
version: 2.1.1
api: [3.0.0]
load: POSTWORLD
author: aieuo
commands:
 if:
  description: "ã‚‚ã—ãªã‚‰ã™ã‚‹"
  usage: "usage /if <add | del | check>"
  permission: op<?php

namespace aieuo;

use pocketmine\utils\Config;


class BlockManager{

	public function __construct($owner){
		$this->owner = $owner;
		if(!file_exists($this->owner->getDataFolder()."blocks.yml")){
	        if(file_exists($this->owner->getDataFolder()."if.db")) {
	            $this->db = new \SQLite3($this->owner->getDataFolder()."if.db", SQLITE3_OPEN_READWRITE);
	        	$this->blocks = new Config($this->owner->getDataFolder() . "blocks.yml", Config::YAML, []);
	        	$this->moveDB();
	        	return;
	        }
	    }
        $this->blocks = new Config($this->owner->getDataFolder() . "blocks.yml", Config::YAML, []);
	}

	public function moveDB(){
		$res = $this->db->query("SELECT * FROM list");
		while($row = $res->fetchArray()) {
			$data = [
				"if" => [
					$row["if"] => $row["if_content"]
				],
				"match" => [
					$row["type1"]+100 => $row["type1_content"]
				],
				"else" => [
					$row["type2"]+100 => $row["type2_content"]
				]
			];
			$this->add($row["pos"], $data);
		}
		$this->db->query("DELETE FROM list");
	}

    public function isAdded($pos){
    	return $this->blocks->exists($pos);
    }

    public function add($pos, $data = null){
        if($data === null){
            $data = [
                "if" => [],
                "match" => [],
                "else" => []
            ];
        }
        $this->blocks->set($pos, $data);
    }

    public function get($pos){
    	if(!$this->isAdded($pos))return false;
    	return $this->blocks->get($pos);
    }

    public function remove($pos){
    	$this->blocks->remove($pos);
    }

    public function update($pos, $data){
        if(!isset($data["if"]))$data["if"] = [];
        if(!isset($data["match"]))$data["match"] = [];
        if(!isset($data["else"]))$data["else"] = [];
        $this->blocks->set($pos, $data);
    }

	public function save(){
		$this->blocks->save();
	}

    public function getPosition($block){
        return $block->x.",".$block->y.",".$block->z.",".$block->level->getFolderName();
    }
}<?php

namespace aieuo;

use pocketmine\utils\Config;

use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\command\ConsoleCommandSender;
use pocketmine\command\PluginCommand;

class CommandManager{

	public function __construct($owner){
		$this->owner = $owner;
        $this->commands = new Config($this->owner->getDataFolder() . "commands.yml", Config::YAML, []);
	}

	public function getServer(){
		return $this->owner->getServer();
	}

    public function registerCommands(){
        foreach($this->commands->getAll() as $command => $value){
    		if($this->isSubcommand($command))$command = $this->getOriginalCommand($command);
            if(!$this->exist($command)){
                $newCommand = new PluginCommand($command, $this->owner);
                $newCommand->setDescription($value["description"]);
                $newCommand->setPermission($value["permission"]);
                $this->getServer()->getCommandMap()->register("ifPlugin", $newCommand);
            }
        }
    }

    public function register($command, $permission = "default", $description = "ifPluginã§è¿½åŠ ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã§ã™"){
    	if($this->isSubcommand($command))$command = $this->getOriginalCommand($command);
        if(!$this->exist($command)){
            $newCommand = new PluginCommand($command, $this->owner);
            $newCommand->setDescription($description);
            $newCommand->setPermission($permission);
            $this->getServer()->getCommandMap()->register("ifPlugin", $newCommand);
            return true;
        }
        return false;
    }

    public function exist($command){
        $exist = $this->getServer()->getPluginCommand($command);
        if($exist === null)return false;
        return true;
    }

    public function isAdded($command){
    	return $this->commands->exists($command);
    }

    public function add($command, $data = null, $permission = "", $description = ""){
        if($permission == "")$permission = "default";
        if($description == "")$description = "ifPluginã§è¿½åŠ ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã§ã™";
        if($data === null){
            $data = [
                "if" => [],
                "match" => [],
                "else" => []
            ];
        }
        $put = [
            "description" => $description,
            "permission" => $permission
        ];
        $this->commands->set($command, array_merge($put, $data));
    }

    public function get($command){
    	if(!$this->isAdded($command))return false;
    	return $this->commands->get($command);
    }

    public function isSubcommand($command){
    	$subcommand = false;
    	if(strpos($command, " ") !== false)$subcommand = true;
    	return false;
    }

    public function getSubcommand($command){
    	$array = [];
    	$command = explode(" ", $command)[0];
    	$commands = $this->getAll();
    	foreach ($commands as $cmd => $value) {
    		$cmds = explode(" ", $cmd);
    		if(array_shift($cmds) == $command){
    			if(isset($cmds[0])){
    				$sub = implode(" " ,$cmds);
        			$array[] = $sub;
    			}
    		}
    	}
    	return $array;
    }

    public function getOriginalCommand($command){
    	if(!$this->isSubcommand($command))return $command;
    	$commands = explode(" ", $command);
    	return $commands[0];
    }

    public function getAll(){
    	return $this->commands->getAll();
    }

    public function remove($command){
    	$this->commands->remove($command);
    }

    public function update($command, $data){
        if(!isset($data["permission"]))$data["permission"] = "default";
        if(!isset($data["description"]))$data["description"] = "ifPluginã§è¿½åŠ ã—ãŸã‚³ãƒžãƒ³ãƒ‰ã§ã™";
        if(!isset($data["if"]))$data["if"] = [];
        if(!isset($data["match"]))$data["match"] = [];
        if(!isset($data["else"]))$data["else"] = [];
        $this->commands->set($command, $data);
    }

    public function save(){
    	$this->commands->save();
    }
}<?php

namespace aieuo;

use pocketmine\network\mcpe\protocol\ModalFormRequestPacket;

class ifAPI{

	public function getMessage($num, $value){
        switch ($num){
                case ifPlugin::IF_TAKEMONEY:
                    $message = "$".$value."æ‰•ãˆã‚‹";
                    break;
                case ifPlugin::IF_HAVEINGITEM:
                    $message = "idãŒ".$value."ã®ã‚¢ã‚¤ãƒ†ãƒ ã‚’æ‰‹ã«æŒã£ã¦ã‚‹";
                    break;
                case ifPlugin::IF_EXISTITEM:
                    $message = "idãŒ".$value."ã‚¢ã‚¤ãƒ†ãƒ ãŒã‚¤ãƒ³ãƒ™ãƒ³ãƒˆãƒªã«å…¥ã£ã¦ã„ã‚‹";
                    break;
                case ifPlugin::IF_ISSNEAKING:
                    $message = "ã‚¹ãƒ‹ãƒ¼ã‚¯ã—ã¦ã„ã‚‹";
                    break;
                case ifPlugin::IF_OVERMONEY:
                    $message = "$".$value."ã‚ˆã‚Šæ‰€æŒé‡‘ãŒå¤šã„";
                    break;
                case ifPlugin::IF_REMOVEITEM:
                    $message = "ã‚¤ãƒ³ãƒ™ãƒ³ãƒˆãƒªã‹ã‚‰(".$value.")ã‚’å‰Šé™¤ã§ãã‚‹";
                    break;
                case ifPlugin::COMMAND:
                    $message = "ã‚³ãƒžãƒ³ãƒ‰(/".$value.")ã‚’å®Ÿè¡Œã™ã‚‹";
                    break;
                case ifPlugin::SENDMESSAGE:
                    $message = "ãƒãƒ£ãƒƒãƒˆæ¬„ã«(".$value.")ã‚’é€ä¿¡ã™ã‚‹";
                    break;
                case ifPlugin::SENDTIP:
                    $message = "tipæ¬„ã«(".$value.")ã‚’é€ä¿¡ã™ã‚‹";
                    break;
                case ifPlugin::TELEPORT:
                    $message = "(".$value.")ã«ãƒ†ãƒ¬ãƒãƒ¼ãƒˆã™ã‚‹";
                    break;
                case ifPlugin::BROADCASTMESSAGE:
                    $message = "å…¨å“¡ã®ãƒãƒ£ãƒƒãƒˆæ¬„ã«(".$value.")ã‚’é€ä¿¡ã™ã‚‹";
                    break;
                case ifPlugin::COMMAND_CONSOLE:
                    $message = "ã‚³ãƒ³ã‚½ãƒ¼ãƒ«ã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰(/".$value.")ã‚’å®Ÿè¡Œã™ã‚‹";
                    break;
                case ifPlugin::DO_NOTHING:
                    $message = "ä½•ã‚‚ã—ãªã„";
                    break;
                case ifPlugin::ADD_ITEM:
                    $message = "ã‚¤ãƒ³ãƒ™ãƒ³ãƒˆãƒªã«(".$value.")ã‚’è¿½åŠ ã™ã‚‹";
                    break;
                case ifPlugin::REMOVE_ITEM:
                    $message = "ã‚¤ãƒ³ãƒ™ãƒ³ãƒˆãƒªã‹ã‚‰(".$value.")ã‚’å‰Šé™¤ã™ã‚‹";
                    break;
                default:
                	$message = "";
                	break;
        }
        return $message;
    }

    public function createMessage($if, $match, $else){
    	$mes = "ã‚‚ã—\n";
        foreach($if as $type => $content){
            $id = str_replace("id", "", $type);
            $mes .= $this->getMessage($id, $content).",\n";
        }
        $mes .= "ãªã‚‰\n\n";
        foreach ($match as $type => $content) {
            $id = str_replace("id", "", $type);
            $mes .= $this->getMessage($id, $content).",\n";
        }
        $mes .= "\n\næ¡ä»¶ã«åˆã‚ãªã‹ã£ãŸã‚‰\n";
        foreach ($else as $type => $content) {
            $id = str_replace("id", "", $type);
            $mes .= $this->getMessage($id, $content).",\n";
        }
        return $mes;
    }


////form////
    public function sendForm($player, $data, $id){
        $pk = new ModalFormRequestPacket();
        $pk->formId = $id;
        $pk->formData = $data;
        $player->dataPacket($pk);
    }

    public function getaddIfForm(){
        $data = [
            "type" => "custom_form",
            "title" => "è¿½åŠ ",
            "content" => [
    			$this->getIflistDropdown(),
    			$this->getExelistDropdown(),
    			$this->getExelistDropdown()
    		]
        ];
        $json = $this->encodeJson($data);
        return $json;
    }

    public function getIflistDropdown(){
    	return [
            "type" => "dropdown",
            "text" => "ã‚‚ã—ï½žãªã‚‰",
            "options" => [
                "ãŠé‡‘ã‚’æ¸›ã‚‰ã™",
                "æŒ‡å®šã—ãŸã‚¢ã‚¤ãƒ†ãƒ ã‚’æ‰‹ã«æŒã£ã¦ã‚‹ã‹",
                "ã‚¤ãƒ³ãƒ™ãƒ³ãƒˆãƒªã«æŒ‡å®šã—ãŸã‚¢ã‚¤ãƒ†ãƒ ãŒå…¥ã£ã¦ã‚‹ã‹",
                "ã‚¹ãƒ‹ãƒ¼ã‚¯ã—ã¦ã„ã‚‹ã‹",
                "æŒ‡å®šã—ãŸé‡‘é¡ã‚ˆã‚Šæ‰€æŒé‡‘ãŒå¤šã„ã‹",
                "æŒ‡å®šã—ãŸã‚¢ã‚¤ãƒ†ãƒ ãŒã‚¤ãƒ³ãƒ™ãƒ³ãƒˆãƒªã«ã‚ã‚‹ãªã‚‰å‰Šé™¤ã™ã‚‹"
            ],
            "defaultOptionIndex" => "ãŠé‡‘ã‚’æ¸›ã‚‰ã™"
        ];
    }

    public function getExelistDropdown(){
    	return [
            "type" => "dropdown",
            "text" => "æ¡ä»¶ã«å½“ã¦ã¯ã¾ã£ãŸã‚‰ï½žã‚’ã™ã‚‹",
            "options" => [
                "ã‚³ãƒžãƒ³ãƒ‰ã‚’å®Ÿè¡Œã™ã‚‹",
                "ãƒãƒ£ãƒƒãƒˆæ¬„ã«ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸é€ä¿¡",
                "tipæ¬„ã«ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸é€ä¿¡",
                "ãƒ†ãƒ¬ãƒãƒ¼ãƒˆ",
                "å…¨ä½“ã«ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸é€ä¿¡",
                "ã‚³ãƒ³ã‚½ãƒ¼ãƒ«ã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰å®Ÿè¡Œ",
                "ä½•ã‚‚ã—ãªã„",
                "ã‚¤ãƒ³ãƒ™ãƒ³ãƒˆãƒªã«ã‚¢ã‚¤ãƒ†ãƒ ã‚’è¿½åŠ ã™ã‚‹",
                "ã‚¤ãƒ³ãƒ™ãƒ³ãƒˆãƒªã‹ã‚‰ã‚¢ã‚¤ãƒ†ãƒ ã‚’å‰Šé™¤ã™ã‚‹"
            ],
            "defaultOptionIndex" => "ã‚³ãƒžãƒ³ãƒ‰ã‚’å®Ÿè¡Œã™ã‚‹"
        ];
    }


    public function getAddForm($type){
    	if($type == "if"){
    		$type = "If";
    	}else{
    		$type = "Exe";
    	}
        $data = [
            "type" => "custom_form",
            "title" => "è¿½åŠ ",
            "content" => [
    			$this->{"get".$type."listDropdown"}(),
    			$this->getInput("å€¤ã‚’å…¥åŠ›ã—ã¦ä¸‹ã•ã„")
    		]
        ];
        $json = $this->encodeJson($data);
        return $json;
    }


    public function createIfContentForm($type1, $type2, $type3){
        $messages1 = $this->getFormMessage($type1);//ã‚‚ã—
        $messages2 = $this->getFormMessage($type2);//åˆã£ãŸã‚‰
        $messages3 = $this->getFormMessage($type3);//åˆã‚ãªã‹ã£ãŸã‚‰

        if($messages1["type"] == "input"){
            $input1 = $this->getInput($messages1["message"], $messages1["placeholder"]);
        }else{
            $input1 = $this->getLabel($messages1["message"]);
        }
        if($messages2["type"] == "input"){
            $input2 = $this->getInput($messages1["next"].$messages2["message"], $messages2["placeholder"]);
        }else{
            $input2 = $this->getLabel($messages2["message"]);
        }
        if($messages3["type"] == "input"){
            $input3 = $this->getInput($messages2["next"]."åˆã‚ãªã‹ã£ãŸã‚‰\n".$messages3["message"], $messages3["placeholder"]);
        }else{
            $input3 = $this->getLabel("åˆã‚ãªã‹ã£ãŸã‚‰\n".$messages3["message"]);
        }

        $content[] = $input1;
        $content[] = $input2;
        $content[] = $input3;

        $content[] = $this->getLabel($messages3["next"]);

        $form = [
            "type" => "custom_form",
            "title" => "ifPlugin",
            "content" => $content
        ];
        $json = $this->encodeJson($form);
        return $json;
    }


    public function getAddCommandForm(){
        $data = [
            "type" => "custom_form",
            "title" => "è¿½åŠ ",
            "content" => [
            	$this->getInput("è¿½åŠ ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã®åå‰", "æœ€åˆã®/ã‚’å¤–ã—ã¦"),
            	$this->getInput("ã‚³ãƒžãƒ³ãƒ‰ã®èª¬æ˜Ž"),
            	$this->getDropdown("æ¨©é™", ["opã ã‘", "å…¨å“¡ä½¿ãˆã‚‹"], "å…¨å“¡ä½¿ãˆã‚‹")
            ]
        ];
        $json = $this->encodeJson($data);
        return $json;
    }


    public function getFormMessage($num){
        switch ($num){
            case ifPlugin::IF_TAKEMONEY:
                $message = "ã‚‚ã—\nÂ§lãŠé‡‘ã‚’";
                $next = "Â§læ‰•ãˆã‚‹ãªã‚‰\n\n";
                $placeholder = "é‡‘é¡ã‚’å…¥åŠ›ã—ã¦ãã ã•ã„";
                break;
            case ifPlugin::IF_HAVEINGITEM:
                $message = "ã‚‚ã—\nÂ§lidãŒ\nÂ§r(id:meta:æ•° ã®ã‚ˆã†ã«çŸ³ãŒ10å€‹ãªã‚‰1:0:10, æ•°ã‚’è€ƒãˆãªã„ãªã‚‰1:0)";
                $next = "Â§lã®ã‚¢ã‚¤ãƒ†ãƒ ã‚’æ‰‹ã«æŒã£ã¦ã‚‹ãªã‚‰\n\n";
                $placeholder = "ä¸Šã®ã‚«ãƒƒã‚³å†…ã®ã‚ˆã†ã«idã‚’å…¥åŠ›ã—ã¦ãã ã•ã„";
                break;
            case ifPlugin::IF_EXISTITEM:
                $message = "ã‚‚ã—\nÂ§lidãŒ\nÂ§r(id:meta:æ•° ã®ã‚ˆã†ã«å®‰å±±å²©ãŒ3å€‹ãªã‚‰1:5:3, 1:5ã ã‘ãªã‚‰æ•°ã¯1å€‹ã«ãªã‚Šã¾ã™)";
                $next = "Â§lã®ã‚¢ã‚¤ãƒ†ãƒ ãŒã‚¤ãƒ³ãƒ™ãƒ³ãƒˆãƒªã«ã‚ã‚‹ãªã‚‰\n\n";
                $placeholder = "ä¸Šã®ã‚«ãƒƒã‚³å†…ã®ã‚ˆã†ã«idã‚’å…¥åŠ›ã—ã¦ãã ã•ã„";
                break;
            case ifPlugin::IF_OVERMONEY:
                $message = "ã‚‚ã—\nÂ§læ‰€æŒé‡‘ãŒ";
                $next = "Â§lã‚ˆã‚Šå¤šã„ãªã‚‰\n\n";
                $placeholder = "é‡‘é¡ã‚’å…¥åŠ›ã—ã¦ãã ã•ã„";
                break;
            case ifPlugin::IF_REMOVEITEM:
                $message = "ã‚‚ã—\nÂ§lã‚¤ãƒ³ãƒ™ãƒ³ãƒˆãƒªã‹ã‚‰idãŒ\nÂ§r(id:meta:æ•° ã®ã‚ˆã†ã«é»„è‰²ã®ç¾Šæ¯›ãŒ2å€‹ãªã‚‰35:4:2 , 35:4ã ã‘ãªã‚‰æŒã£ã¦ã‚‹æ•°ã™ã¹ã¦)";
                $next = "Â§lã®ã‚¢ã‚¤ãƒ†ãƒ ã‚’å‰Šé™¤ã§ãã‚‹ãªã‚‰\n\n";
                $placeholder = "ä¸Šã®ã‚«ãƒƒã‚³å†…ã®ã‚ˆã†ã«idã‚’å…¥åŠ›ã—ã¦ãã ã•ã„";
                break;
            case ifPlugin::COMMAND:
                $message = "Â§lã‚³ãƒžãƒ³ãƒ‰";
                $next = "Â§lã‚’å®Ÿè¡Œã™ã‚‹\n\n";
                $placeholder = "ã‚³ãƒžãƒ³ãƒ‰ã‚’æœ€åˆã®/ã‚’å¤–ã—ã¦å…¥åŠ›ã—ã¦ãã ã•ã„";
                break;
            case ifPlugin::SENDMESSAGE:
                $message = "Â§lãƒãƒ£ãƒƒãƒˆæ¬„ã«";
                $next = "Â§lã‚’é€ä¿¡ã™ã‚‹\n\n";
                $placeholder = "é€ä¿¡ã™ã‚‹ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’å…¥åŠ›ã—ã¦ãã ã•ã„";
                break;
            case ifPlugin::SENDTIP:
                $message = "Â§ltipæ¬„ã«";
                $next = "Â§lã‚’é€ä¿¡ã™ã‚‹\n\n";
                $placeholder = "é€ä¿¡ã™ã‚‹ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’å…¥åŠ›ã—ã¦ãã ã•ã„";
                break;
            case ifPlugin::TELEPORT:
                $message = "(".$value.")ã«ãƒ†ãƒ¬ãƒãƒ¼ãƒˆã™ã‚‹";
                $message = "(0,0,0,world  ã®ã‚ˆã†ã«,ã§åŒºåˆ‡ã£ã¦)";
                $next = "Â§lã«ãƒ†ãƒ¬ãƒãƒ¼ãƒˆã™ã‚‹\n\n";
                $placeholder = "ä¸Šã®ã‚«ãƒƒã‚³å†…ã®ã‚ˆã†ã«åº§æ¨™ã‚’å…¥åŠ›ã—ã¦ãã ã•ã„";
                break;
            case ifPlugin::BROADCASTMESSAGE:
                $message = "Â§lå…¨å“¡ã®ãƒãƒ£ãƒƒãƒˆæ¬„ã«";
                $next = "Â§lã‚’é€ä¿¡ã™ã‚‹\n\n";
                $placeholder = "é€ä¿¡ã™ã‚‹ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’å…¥åŠ›ã—ã¦ãã ã•ã„";
                break;
            case ifPlugin::COMMAND_CONSOLE:
                $message = "Â§lã‚³ãƒ³ã‚½ãƒ¼ãƒ«ã‹ã‚‰ã‚³ãƒžãƒ³ãƒ‰";
                $next = "Â§lã‚’å®Ÿè¡Œã™ã‚‹\n\n";
                $placeholder = "ã‚³ãƒžãƒ³ãƒ‰ã‚’æœ€åˆã®/ã‚’å¤–ã—ã¦å…¥åŠ›ã—ã¦ãã ã•ã„";
                break;
            case ifPlugin::ADD_ITEM:
                $message = "Â§lã‚¤ãƒ³ãƒ™ãƒ³ãƒˆãƒªã«idãŒ\nÂ§r(id:meta:æ•° ,åå‰ã‚’ä»˜ã‘ã‚‹ãªã‚‰id:meta:æ•°:åå‰ ã®ã‚ˆã†ã«)";
                $next = "Â§lã®ã‚¢ã‚¤ãƒ†ãƒ ã‚’è¿½åŠ ã™ã‚‹\n\n";
                $placeholder = "ä¸Šã®ã‚«ãƒƒã‚³å†…ã®ã‚ˆã†ã«idã‚’å…¥åŠ›ã—ã¦ãã ã•ã„";
                break;
            case ifPlugin::REMOVE_ITEM:
                $message = "Â§lã‚¤ãƒ³ãƒ™ãƒ³ãƒˆãƒªã‹ã‚‰idãŒ\nÂ§r(id:meta:æ•° æ•°ã‚’å…¥ã‚Œãªã‹ã£ãŸã‚‰æŒã£ã¦ã‚‹æ•°ã™ã¹ã¦)";
                $next = "Â§lã®ã‚¢ã‚¤ãƒ†ãƒ ã‚’å‰Šé™¤ã™ã‚‹\n\n";
                $placeholder = "ä¸Šã®ã‚«ãƒƒã‚³å†…ã®ã‚ˆã†ã«idã‚’å…¥åŠ›ã—ã¦ãã ã•ã„";
                break;

            case ifPlugin::IF_ISSNEAKING:
                $message = "ã‚‚ã—\nã‚¹ãƒ‹ãƒ¼ã‚¯ã—ã¦ã„ã‚‹ãªã‚‰";
		        return [
                	"type" => "label",
		            "message" => $message,
		            "next" => "\n"
		        ];
                break;
            case ifPlugin::DO_NOTHING:
                $message = "ä½•ã‚‚ã—ãªã„";
		        return [
                	"type" => "label",
		            "message" => $message,
		            "next" => "\n"
		        ];
                break;
        }
        return [
        	"type" => "input",
            "message" => $message,
            "next" => $next,
            "placeholder" => $placeholder
        ];
    }


    public function getEditIfForm($datas){
        $mes = $this->createMessage($datas["if"], $datas["match"], $datas["else"]);
        $data = [
        	"type" => "form",
        	"title" => "ç·¨é›†",
        	"content" => $mes,
        	"buttons" => [
        		[
        			"text" => "ã‚‚ã—~ã‚’ç·¨é›†ã™ã‚‹"
        		],
        		[
        			"text" => "æ¡ä»¶ã«åˆã£ãŸæ™‚ã‚’ç·¨é›†ã™ã‚‹",
        		],
        		[
        			"text" => "æ¡ä»¶ã«åˆã‚ãªã‹ã£ãŸæ™‚ã‚’ç·¨é›†ã™ã‚‹"
        		]
        	]
        ];
        $json = $this->encodeJson($data);
        return $json;
    }

    public function getEditForm($datas){
        $data = [
        	"type" => "form",
        	"title" => "ã‚³ãƒžãƒ³ãƒ‰ã®ç·¨é›†",
        	"content" => "",
        	"buttons" => []
        ];
    	foreach ($datas as $key => $value) {
            $id = str_replace("id", "", $key);
            $data["buttons"][] = ["text" => $this->getMessage($id, $value)];
    	}
        $data["buttons"][] = ["text" => "è¿½åŠ ã™ã‚‹(æ—¢ã«è¿½åŠ ã—ã¦ã‚‹æ¡ä»¶ã‚’è¿½åŠ ã™ã‚‹ã¨ä¸Šæ›¸ãã•ã‚Œã¾ã™)"];
        $json = $this->encodeJson($data);
        return $json;
    }

    public function getDelForm($id, $content){
        $data = [
            "type" => "custom_form",
            "title" => "è¿½åŠ ",
            "content" => [
            	$this->getLabel($this->getMessage($id, $content)),
            	$this->getToggle("å‰Šé™¤ã™ã‚‹")
            ]
        ];
        $json = $this->encodeJson($data);
        return $json;
    }

//elements//
    public function getInput($text, $placeholder = ""){
        return [
            "type" => "input",
            "text" => $text,
            "placeholder" => $placeholder
        ];
    }

    public function getLabel($text){
        return [
            "type" => "label",
            "text" => $text
        ];
    }

    public function getToggle($text){
        return [
            "type" => "toggle",
            "text" => $text
        ];
    }

    public function getDropdown($text, $options, $default){
    	return [
            "type" => "dropdown",
            "text" => $text,
            "options" => $options,
            "defaultOptionIndex" => $default
        ];
    }


    public function encodeJson($data){
        $json = json_encode($data, JSON_PRETTY_PRINT | JSON_BIGINT_AS_STRING | JSON_UNESCAPED_UNICODE);
        return $json;
    }
}<?php
namespace aieuo;

use pocketmine\plugin\PluginBase;
use pocketmine\event\Listener;
use pocketmine\Player;
use pocketmine\item\Item;
use pocketmine\level\Position;
use pocketmine\utils\Config;

use pocketmine\event\player\PlayerInteractEvent;

use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\command\ConsoleCommandSender;
use pocketmine\command\PluginCommand;

use pocketmine\event\server\DataPacketReceiveEvent;
use pocketmine\network\mcpe\protocol\ModalFormResponsePacket;

class ifPlugin extends PluginBase implements Listener{

    const IF_TAKEMONEY = 0;
    const IF_HAVEINGITEM = 1;
    const IF_EXISTITEM = 2;
    const IF_ISSNEAKING = 3;
    const IF_OVERMONEY = 4;
    const IF_REMOVEITEM = 5;

    const COMMAND = 100;
    const SENDMESSAGE = 101;
    const SENDTIP = 102;
    const TELEPORT = 103;
    const BROADCASTMESSAGE = 104;
    const COMMAND_CONSOLE = 105;
    const DO_NOTHING = 106;
    const ADD_ITEM = 107;
    const REMOVE_ITEM = 108;

	public function onEnable(){
        $this->getServer()->getPluginManager()->registerEvents($this,$this);
        if(!file_exists($this->getDataFolder())) @mkdir($this->getDataFolder(), 0721, true);
        $this->config = new Config($this->getDataFolder()."config.yml", Config::YAML, [
            "wait" => 0
        ]);
        $this->wait = $this->config->get("wait");

        if(($this->EconomyAPI = $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")) !== null){
            $this->getServer()->getLogger()->info("[if] EconomyAPIã‚’èª­ã¿è¾¼ã¿ã¾ã—ãŸ");
        }
        if(($this->PocketMoney = $this->getServer()->getPluginManager()->getPlugin("PocketMoney")) !== null){
            $this->getServer()->getLogger()->info("[if] PocketMoneyã‚’èª­ã¿è¾¼ã¿ã¾ã—ãŸ");
        }

        $this->api = new ifAPI($this);
        $this->command = new CommandManager($this);
        $this->block = new BlockManager($this);

        $this->command->registerCommands();

        $this->ids = [
            "addIfForm" => mt_rand(1, 999999999),
        ];
        $this->addIfId = mt_rand(1, 999999999);
        $this->inputIfId = mt_rand(1, 999999999);
        $this->editIfId = mt_rand(1, 999999999);
        $this->addCommandId = mt_rand(1, 999999999);
        $this->editId = mt_rand(1, 999999999);
        $this->delId = mt_rand(1, 999999999);
        $this->addId = mt_rand(1, 999999999);
    }

    public function onDisable(){
        $this->command->save();
        $this->block->save();
    }

    public function onCommand(CommandSender $sender, Command $command,string $label, array $args):bool{
        if($command->getName() == "if"){
            if(!isset($args[0]))return false;
            $name = $sender->getName();
            switch ($args[0]) {
                case "block":
                    if(!isset($args[1])){
                        $sender->sendMessage("/if command <add | del>");
                        return true;
                    }
                    switch ($args[1]) {
                        case 'add':
                            $form = $this->api->getaddIfForm();
                            $this->api->sendForm($sender, $form, $this->addIfId);
                            $this->addData[$name] = ["add" => "block"];
                            break;
                        case 'del':
                            $this->tap[$name] = "del";
                            $sender->sendMessage("ãƒ–ãƒ­ãƒƒã‚¯ã‚’ã‚¿ãƒƒãƒã—ã¦ãã ã•ã„");
                            break;
                        case 'check':
                            $this->tap[$name] = "check";
                            $sender->sendMessage("ãƒ–ãƒ­ãƒƒã‚¯ã‚’ã‚¿ãƒƒãƒã—ã¦ãã ã•ã„");
                            break;
                        case 'edit':
                            $this->tap[$name] = "edit";
                            $sender->sendMessage("ãƒ–ãƒ­ãƒƒã‚¯ã‚’ã‚¿ãƒƒãƒã—ã¦ãã ã•ã„");
                            break;
                    }
                    break;
                case 'command':
                    if(!isset($args[1])){
                        $sender->sendMessage("/if command <add | del>");
                        return true;
                    }
                    switch ($args[1]) {
                        case 'add':
                            $form = $this->api->getAddCommandForm();
                            $this->api->sendForm($sender, $form, $this->addCommandId);
                            $this->addData[$name] = ["add" => "command"];
                            break;
                        case 'del':
                            if(!isset($args[2])){
                                $sender->sendMessage("/if command del <command>");
                                return true;
                            }
                            array_shift($args);
                            array_shift($args);
                            $cmd = implode(" ", $args);
                            if(!$this->command->isAdded($cmd)){
                                $sender->sendMessage("ãã®ã‚³ãƒžãƒ³ãƒ‰ã¯è¿½åŠ ã•ã‚Œã¦ã„ã¾ã›ã‚“");
                                return true;
                            }
                            if(!$this->command->isSubcommand($cmd))$this->getServer()->getCommandMap()->unregister(new PluginCommand($cmd, $this));
                            $this->command->remove($cmd);
                            $sender->sendMessage("å‰Šé™¤ã—ã¾ã—ãŸ");
                            break;
                        case 'edit':
                            if(!isset($args[2])){
                                $sender->sendMessage("/if command edit <command>");
                                return true;
                            }
                            array_shift($args);
                            array_shift($args);
                            $cmd = implode(" ", $args);
                            if(!$this->command->isAdded($cmd)){
                                $sender->sendMessage("ãã®ã‚³ãƒžãƒ³ãƒ‰ã¯è¿½åŠ ã•ã‚Œã¦ã„ã¾ã›ã‚“");
                                return true;
                            }
                            $datas = $this->command->get($cmd);
                            $form = $this->api->getEditIfForm($datas);
                            $this->api->sendForm($sender, $form, $this->editIfId);
                            $this->editData[$name] = [
                                "edit" => "command",
                                "command" => $cmd
                            ];
                            break;
                        case 'list':
                            $sender->sendMessage("è¿½åŠ ã—ã¦ã„ã‚‹ã‚³ãƒžãƒ³ãƒ‰");
                            foreach($this->command->getAll() as $cmd => $value){
                                $sender->sendMessage($cmd.": ".$value["description"]);
                            }
                            break;
                    }
                    break;
                case 'setting':
                    if(!isset($args[1])){
                        $sender->sendMessage("/if setting <wait> <ç§’æ•°>");
                        return true;
                    }
                    switch ($args[1]) {
                        case 'wait':
                            $time = (int)$args[1];
                            if($time < 0){
                                $sender->sendMessage("0ç§’ä»¥ä¸Šã«ã—ã¦ãã ã•ã„");
                                return true;
                            }
                            $this->config->set("wait", $time);
                            $this->wait = $time;
                            $sender->sendMessage($time."ç§’ã«è¨­å®šã—ã¾ã—ãŸ");
                            break;
                    }
                    break;
            }
            return true;
        }
        if(isset($args[0])){
            $cmd = $command->getName()." ".implode(" ", $args);
        }else{
            $cmd = $command->getName();
        }
        if($this->command->isAdded($cmd)){
            $datas = $this->command->get($cmd);
            $stat = "match";
            foreach($datas["if"] as $if => $content){
                $id = str_replace("id", "", $if);
                $result = $this->checkMatchCondition($sender, $id, $content);
                if($result === 0){
                    $sender->sendMessage("Â§cã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ã¾ã—ãŸ(id: ".$id."ãŒè¦‹ã¤ã‹ã‚Šã¾ã›ã‚“)");
                    return true;
                }elseif($result === 2){
                    $stat = "else";
                }
            }
            foreach ($datas[$stat] as $type => $content) {
                $id = str_replace("id", "", $type);
                $this->execute($sender, $id, $content);
            }
            return true;
        }
        if(!$this->command->isSubCommand($cmd))return true;
        $subcommand = $this->command->getSubcommand($command->getName());
        $sender->sendMessage("usage: /".$command->getName()." <".implode(" | ", $subcommand).">");
        return true;
    }

    public function onTouch(PlayerInteractEvent $event){
        $player = $event->getPlayer();
        $block = $event->getBlock();
        if(isset($this->tap[$player->getName()]) and $block->getId() !== 0){
            switch ($this->tap[$player->getName()]) {
                case 'add':
                    $pos = $this->block->getPosition($block);
                    $tap = $this->addData[$player->getName()];
                    $this->block->add($pos, $tap["datas"]);
                    $player->sendMessage("è¿½åŠ ã—ã¾ã—ãŸ");
                    unset($this->addData[$player->getName()]);
                    break;
                case 'del':
                    $pos = $this->block->getPosition($block);
                    if(!$this->block->isAdded($pos)){
                        $player->sendMessage("ãã®ãƒ–ãƒ­ãƒƒã‚¯ã«ã¯è¿½åŠ ã•ã‚Œã¦ã„ã¾ã›ã‚“");
                        return;
                    }
                    $this->block->remove($pos);
                    $player->sendMessage("å‰Šé™¤ã—ã¾ã—ãŸ");
                    break;
                case 'check':
                    $pos = $this->block->getPosition($block);
                    if(!$this->block->isAdded($pos)){
                        $player->sendMessage("ãã®ãƒ–ãƒ­ãƒƒã‚¯ã«ã¯è¿½åŠ ã•ã‚Œã¦ã„ã¾ã›ã‚“");
                        return;
                    }
                    $datas = $this->block->get($pos);
                    $mes = $this->api->createMessage($datas["if"], $datas["match"], $datas["else"]);
                    $player->sendMessage($mes);
                    break;
                case 'edit':
                    $pos = $this->block->getPosition($block);
                    if(!$this->block->isAdded($pos)){
                        $player->sendMessage("ãã®ãƒ–ãƒ­ãƒƒã‚¯ã«ã¯è¿½åŠ ã•ã‚Œã¦ã„ã¾ã›ã‚“");
                        return;
                    }
                    $datas = $this->block->get($pos);
                    $form = $this->api->getEditIfForm($datas);
                    $this->api->sendForm($player, $form, $this->editIfId);
                    $this->editData[$player->getName()] = [
                        "edit" => "block",
                        "pos" => $pos
                    ];
                    break;
            }
            unset($this->tap[$player->getName()]);
            return;
        }
        if($block->getId() === 0)return;
        if($this->block->isAdded($this->block->getPosition($block))){
            if($this->wait !== 0){
                if(!isset($player->wait))$player->wait = 0;
                $tick = $this->getServer()->getTick();
                if($tick - $player->wait < $this->wait)return;
            }
            $name = $player->getName();
            $datas = $this->block->get($this->block->getPosition($block));
            $stat = "match";
            foreach($datas["if"] as $if => $content){
                $id = str_replace("id", "", $if);
                $result = $this->checkMatchCondition($player, $id, $content);
                if($result === 0){
                    $player->sendMessage("Â§cã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ã¾ã—ãŸ(id: ".$id."ãŒè¦‹ã¤ã‹ã‚Šã¾ã›ã‚“)");
                    return true;
                }elseif($result === 2){
                    $stat = "else";
                }
            }
            foreach ($datas[$stat] as $type => $content) {
                $id = str_replace("id", "", $type);
                $this->execute($player, $id, $content);
            }
        }
    }

    public function Receive(DataPacketReceiveEvent $event){
        $pk = $event->getPacket();
        $player = $event->getPlayer();
        $name = $player->getName();
        if($pk instanceof ModalFormResponsePacket){
            if($pk->formId === $this->addIfId){
                $data = json_decode($pk->formData);
                if($pk->formData === null) {
                   return;
                }
                $form = $this->api->createIfContentForm($data[0], $data[1] + 100, $data[2] + 100);
                $this->api->sendForm($player, $form, $this->inputIfId);
                for($i = 2; $i >= 0; $i--){
                    $this->addData[$name]["content"][$i] = "";
                    $this->addData[$name]["type"][$i] = $data[$i];
                    if($i == 0)break;
                    $this->addData[$name]["type"][$i] += 100;
                }

            }elseif($pk->formId === $this->inputIfId){
                $data = json_decode($pk->formData);
                if($pk->formData === null) {
                   return;
                }
                $datas = $this->addData[$name];
                if(
                    ($datas["type"][0] !== self::IF_ISSNEAKING and $data[0] == "")
                    or ($datas["type"][1]+100 !== self::DO_NOTHING and $data[1] == "")
                    or ($datas["type"][2]+100 !== self::DO_NOTHING and $data[2] == "")
                ){
                    $player->sendMessage("å¿…è¦äº‹é …ã‚’è¨˜å…¥ã—ã¦ãã ã•ã„");
                    return true;
                }
                $add = [
                    "if" => [
                        "id".$datas["type"][0] => (string)$data[0]
                    ],
                    "match" => [
                        "id".$datas["type"][1] => (string)$data[1]
                    ],
                    "else" => [
                        "id".$datas["type"][2] => (string)$data[2]
                    ]
                ];

                if($this->addData[$name]["add"] == "block"){
                    $this->addData[$name]["datas"] = $add;
                    $this->tap[$name] = "add";
                    $player->sendMessage("è¿½åŠ ã™ã‚‹ãƒ–ãƒ­ãƒƒã‚¯ã‚’è§¦ã£ã¦ãã ã•ã„");
                }else{
                    $this->command->add($datas["command"], $add, $datas["permission"], $datas["description"]);
                    $this->command->register($datas["command"], $datas["permission"], $datas["description"]);
                    $player->sendMessage("è¿½åŠ ã—ã¾ã—ãŸ");
                    unset($this->addData[$name]);
                }

            }elseif($pk->formId === $this->addCommandId){
                $data = json_decode($pk->formData);
                if($pk->formData === null) {
                   return;
                }
                if($data[0] == ""){
                    $player->sendMessage("å¿…è¦äº‹é …ã‚’è¨˜å…¥ã—ã¦ãã ã•ã„");
                    return true;
                }
                if($this->command->exist($data[0])){
                    $player->sendMessage("Â§eãã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ—¢ã«ä½¿ç”¨ã•ã‚Œã¦ã„ã¾ã™");
                    return true;
                }
                if($this->command->isAdded($data[0])){
                    $player->sendMessage("Â§eãã®ã‚³ãƒžãƒ³ãƒ‰ã¯æ—¢ã«è¿½åŠ ã—ã¦ã„ã¾ã™");
                    return true;
                }
                if($data[1] == "")$data[1] = null;
                if($data[2] == 0){
                    $permission = "op";
                }else{
                    $permission = "default";
                }
                $this->addData[$name]["command"] = $data[0];
                $this->addData[$name]["description"] = $data[1];
                $this->addData[$name]["permission"] = $permission;

                $form = $this->api->getaddIfForm();
                $this->api->sendForm($player, $form, $this->addIfId);

            }elseif($pk->formId === $this->editIfId){
                $data = json_decode($pk->formData);
                if($pk->formData === null or $data === null) {
                   return;
                }
                if($this->editData[$name]["edit"] == "block"){
                    $datas = $this->block->get($this->editData[$name]["pos"]);
                }else{
                    $datas = $this->command->get($this->editData[$name]["command"]);
                }
                if($data == 0){
                    $form = $this->api->getEditForm($datas["if"]);
                    $this->editData[$name]["type"] = "if";
                }elseif($data == 1){
                    $form = $this->api->getEditForm($datas["match"]);
                    $this->editData[$name]["type"] = "match";
                }elseif($data == 2){
                    $form = $this->api->getEditForm($datas["else"]);
                    $this->editData[$name]["type"] = "else";
                }
                $this->api->sendForm($player, $form, $this->editId);

            }elseif($pk->formId === $this->editId){
                $data = json_decode($pk->formData);
                if($pk->formData === null or $data === null){
                   return;
                }
                if($this->editData[$name]["edit"] == "block"){
                    $datas = $this->block->get($this->editData[$name]["pos"])[$this->editData[$name]["type"]];
                }else{
                    $datas = $this->command->get($this->editData[$name]["command"])[$this->editData[$name]["type"]];
                }
                if($data == count($datas)){
                    $form = $this->api->getAddForm($this->editData[$name]["type"]);
                    $this->api->sendForm($player, $form, $this->addId);
                }else{
                    $detail = array_slice($datas, $data, 1, true);
                    $id = (int)str_replace("id", "", key($detail));
                    if($this->editData[$name]["type"] != "if")$id += 100;
                    $form = $this->api->getDelForm($id, current($detail));
                    $this->api->sendForm($player, $form, $this->delId);
                    $this->editData[$name]["num"] = $data;
                }

            }elseif($pk->formId === $this->delId){
                $data = json_decode($pk->formData);
                if($pk->formData === null or $data === null){
                   return;
                }
                if($data[1] === true){
                    if($this->editData[$name]["edit"] == "block"){
                        $datas = $this->block->get($this->editData[$name]["pos"]);
                    }else{
                        $datas = $this->command->get($this->editData[$name]["command"]);
                    }
                    $edit = $this->editData[$name];
                    $detail = array_slice($datas[$edit["type"]], $edit["num"], 1, true);
                    unset($datas[$edit["type"]][key($detail)]);
                    if($this->editData[$name]["edit"] == "block"){
                        $this->block->update($edit["pos"], $datas);
                    }else{
                        $this->command->update($edit["command"], $datas);
                    }
                    $player->sendMessage("å‰Šé™¤ã—ã¾ã—ãŸ");
                }

            }elseif($pk->formId === $this->addId){
                $data = json_decode($pk->formData);
                if($pk->formData === null or $data === null){
                   return;
                }
                if($this->editData[$name]["edit"] == "block"){
                    $datas = $this->block->get($this->editData[$name]["pos"]);
                }else{
                    $datas = $this->command->get($this->editData[$name]["command"]);
                }
                $edit = $this->editData[$name];
                if($edit["type"] != "if")$data[0] += 100;
                $datas[$edit["type"]]["id".$data[0]] = (string)$data[1];
                if($this->editData[$name]["edit"] == "block"){
                    $this->block->update($edit["pos"], $datas);
                }else{
                    $this->command->update($edit["command"], $datas);
                }
                $player->sendMessage("è¿½åŠ ã—ã¾ã—ãŸ");
            }
        }
    }

///api///
    public function checkMatchCondition($player, $type, $content){
        $result = 2;
        $name = $player->getName();
        switch ($type) {
            case self::IF_TAKEMONEY:
                $money = (int)$content;
                if($this->EconomyAPI !== null){
                    $mymoney = $this->EconomyAPI->mymoney($name);
                    if($mymoney >= $money){
                        $this->EconomyAPI->reduceMoney($name, $money);
                        $result = 1;
                    }
                }elseif($this->PocketMoney !== null){
                    $mymoney = $this->PocketMoney->getMoney($name);
                    if($mymoney >= $money){
                        $this->PocketMoney->setMoney($name, $mymoney - $money);
                        $result = 1;
                    }
                }else{
                    $result = 0;
                    $player->sendMessage("çµŒæ¸ˆã‚·ã‚¹ãƒ†ãƒ ãƒ—ãƒ©ã‚°ã‚¤ãƒ³ãŒè¦‹ã¤ã‹ã‚Šã¾ã›ã‚“");
                }
                break;
            case self::IF_HAVEINGITEM:
                $item = $player->getInventory()->getItemInHand();
                $id = explode(":", $content);
                if(!isset($id[1]))$id[1] = 0;
                if(isset($id[2])){
                    if($item->getId() == $id[0] and $item->getDamage() == $id[1] and $item->getCount() == $id[2]){
                        $result = 1;
                    }
                }else{
                    if($item->getId() == $id[0] and $item->getDamage() == $id[1] ){
                        $result = 1;
                    }
                }
                break;
            case self::IF_EXISTITEM:
                $id = explode(":", $content);
                if(!isset($id[1]))$id[1] = 0;
                if(!isset($id[2]))$id[2] = 1;
                $item = Item::get((int)$id[0], (int)$id[1], (int)$id[2]);
                if($player->getInventory()->contains($item))$result = 1;
                break;
            case self::IF_ISSNEAKING:
                if($player->isSneaking())$result = 1;
                break;
            case self::IF_OVERMONEY:
                $money = (int)$content;
                if($this->EconomyAPI !== null){
                    $mymoney = $this->EconomyAPI->mymoney($name);
                    if($mymoney >= $money)$result = 1;
                }elseif($this->PocketMoney !== null){
                    $mymoney = $this->PocketMoney->getMoney($name);
                    if($mymoney >= $money)$result = 1;
                }else{
                    $result = 0;
                    $player->sendMessage("çµŒæ¸ˆã‚·ã‚¹ãƒ†ãƒ ãƒ—ãƒ©ã‚°ã‚¤ãƒ³ãŒè¦‹ã¤ã‹ã‚Šã¾ã›ã‚“");
                }
                break;
            case self::IF_REMOVEITEM:
                $ids = explode(":", $content);
                if(!isset($ids[1]))$ids[1] == 0;
                if(isset($ids[2])){
                    $item = Item::get((int)$ids[0], (int)$ids[1], (int)$ids[2]);
                    if($player->getInventory()->contains($item)){
                        $player->getInventory()->removeItem($item);
                        $result = 1;
                    }
                }else{
                    $count = 0;
                    foreach ($player->getInventory()->getContents() as $item) {
                        if($item->getId() == $ids[0] and $item->getDamage() == $ids[1]){
                            $count += $item->getCount();
                        }
                    }
                    if($count >= 1){
                        $player->getInventory()->removeItem(Item::get($ids[0], $ids[1], $count));
                        $result = 1;
                    }
                }
                break;
            default:
                $result = 0;
                break;
        }
        return $result;//åˆã£ãŸã‚‰1, åˆã‚ãªã‹ã£ãŸã‚‰2, idãŒè¦‹ã¤ã‹ã‚‰ãªã‹ã£ãŸã‚‰0
    }

    public function execute($player, $type, $content){
        $name = $player->getName();
        switch ($type) {
            case self::COMMAND:
                $cmd = str_replace("@p", $name, $content);
                $this->getServer()->dispatchCommand($player, $cmd);
                break;
            case self::SENDMESSAGE:
                $message = str_replace("@p", $name, $content);
                $player->sendMessage($message);
                break;
            case self::SENDTIP:
                $message = str_replace("@p", $name, $content);
                $player->sendTip($message);
                break;
            case self::TELEPORT:
                $pos = explode(",", $content);
                if(!isset($pos[1]))$pos[1] = 0;
                if(!isset($pos[2]))$pos[2] = 0;
                if(!isset($pos[3]))$pos[3] = $player->level->getFolderName();
                $player->teleport(new Position((int)$pos[0], (int)$pos[1], (int)$pos[2], $this->getServer()->getLevelByName($pos[3])));
                break;
            case self::BROADCASTMESSAGE:
                $message = str_replace("@p", $name, $content);
                $this->getServer()->broadcastMessage($message);
                break;
            case self::COMMAND_CONSOLE:
                $cmd = str_replace("@p", $name, $content);
                $this->getServer()->dispatchCommand(new ConsoleCommandSender, $cmd);
                break;
            case self::ADD_ITEM:
                $ids = explode(":", $content);
                if(!isset($ids[1]))$ids[1] = 0;
                if(!isset($ids[2]))$ids[2] = 1;
                if(!isset($ids[3])){
                    $player->getInventory()->addItem(Item::get($ids[0], $ids[1]));
                }else{
                    $player->getInventory()->addItem(Item::get($ids[0], $ids[1])->setCustomName($ids[3]));
                }
                break;
            case self::REMOVE_ITEM:
                $ids = explode(":", $content);
                if(!isset($ids[1]))$ids[1] == 0;
                if(isset($ids[2])){
                    $item = Item::get((int)$ids[0], (int)$ids[1], (int)$ids[2]);
                    $player->getInventory()->removeItem($item);
                }else{
                    $count = 0;
                    foreach ($player->getInventory()->getContents() as $item) {
                        if($item->getId() == $ids[0] and $item->getDamage() == $ids[1]){
                            $count += $item->getCount();
                        }
                    }
                    if($count >= 1){
                        $player->getInventory()->removeItem(Item::get($ids[0], $ids[1], $count));
                    }
                }
                break;
            case self::COMMAND_CONSOLE:
                $cmd = str_replace("@p", $name, $content);
                $this->getServer()->dispatchCommand(new ConsoleCommandSender, $cmd);
                break;
            case self::DO_NOTHING:
                break;
        }
    }

    public function executeIfMatchCondition($player, $type1, $content1, $type2 = self::DO_NOTHING, $content2 = "", $type3 = self::DO_NOTHING, $content3 = ""){
        $result = $this->checkMatchCondition($player, $type1, $content1);
        if($result == 1){
            $this->execute($player, $type2, $content2);
        }elseif($result == 2){
            $this->execute($player, $type3, $content3);
        }else{
            return false;
        }
        return true;
    }
}?u'‘Ÿ÷ä’ÂçPµ˜=Yˆ   GBMB