<?php echo "Altay plugin if v2.3.1\nThis file has been generated using Turanic at Fri, 09 Nov 2018 19:57:01 +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.3.1";s:4:"main";s:17:"aieuo\ip\ifPlugin";s:3:"api";a:2:{i:0;s:5:"3.0.0";i:1;s:5:"4.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:1541761021;}
   plugin.ymlk   ýgå[k   ïøs¶      #   src/aieuo/ip/commands/ifCommand.phpM  ýgå[M  ¯Áy¶      )   src/aieuo/ip/economy/EconomyAPILoader.phpf  ýgå[f  þ<™ì¶      &   src/aieuo/ip/economy/EconomyLoader.phpÿ   ýgå[ÿ   ¬„架      *   src/aieuo/ip/economy/MoneySystemLoader.phpW  ýgå[W  ÎY¶      *   src/aieuo/ip/economy/PocketMoneyLoader.php×  ýgå[×  2ä2+¶         src/aieuo/ip/EventListener.php�q  ýgå[�q  �Ä%å¶         src/aieuo/ip/form/Elements.phpà  ýgå[à  ಄¥¶         src/aieuo/ip/form/Form.phpò/  ýgå[ò/  –À-¶         src/aieuo/ip/form/Parts.php  ýgå[  ™4ó¬¶         src/aieuo/ip/ifAPI.phpQ^  ýgå[Q^  ›(Œ¶         src/aieuo/ip/ifPlugin.php6  ýgå[6  ÐúÔ¶      %   src/aieuo/ip/manager/BlockManager.phpû  ýgå[û  ö³ðf¶      '   src/aieuo/ip/manager/CommandManager.phpÂ  ýgå[Â  ׶›G¶      %   src/aieuo/ip/manager/EventManager.php  ýgå[  à¡/®¶      "   src/aieuo/ip/manager/ifManager.phpŸ
  ýgå[Ÿ
  1ÔØë¶         src/aieuo/ip/Session.php¯  ýgå[¯  򁺽¶      (   src/aieuo/ip/task/DelayedCommandTask.phpm  ýgå[m  Žuà¶         src/aieuo/ip/task/SaveTask.php{  ýgå[{  ú7i<¶         src/aieuo/ip/utils/Messages.phpW  ýgå[W  Hžý–¶      ---
name: if
main: aieuo\ip\ifPlugin
version: 2.3.1
api:
- 3.0.0
- 4.0.0
load: POSTWORLD
author: aieuo
...
<?php

namespace aieuo\ip\commands;

use pocketmine\command\Command;
use pocketmine\command\CommandExecutor;
use pocketmine\command\CommandSender;
use pocketmine\command\PluginCommand;

use aieuo\ip\form\Form;
use aieuo\ip\utils\Messages;
use aieuo\ip\Session;

class ifCommand extends PluginCommand implements CommandExecutor {

	public function __construct($owner){
		parent::__construct('if', $owner);
		$this->setPermission('op');
		$this->setDescription("条件にあった時、イベントが起きた時に何かをする");
		$this->setUsage("if <block | command | event>");
		$this->setExecutor($this);
		$this->owner = $owner;
	}

	public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args): bool{
		if(!$sender->isOp() or $sender->getName() === "CONSOLE")return true;
		$name = $sender->getName();
		if(!isset($args[0])){
			$form = Form::getSelectIfTypeForm();
			Form::sendForm($sender, $form, Form::getFormId("SelectIfTypeForm"));
			return true;
		}
		switch ($args[0]) {
			case 'block':
				if(isset($args[1])){
					$session = $sender->ifSession;
					$session->setValid();
					$session->setIfType(Session::BLOCK);
					switch ($args[1]) {
						case "add":
							$session->setData("type", "add");
							$sender->sendMessage("追加するブロックを触ってください");
							return true;
						case "add_empty":
							$session->setData("type", "add_empty");
							$sender->sendMessage("追加するブロックを触ってください");
							return true;
						case "edit":
							$session->setData("type", "edit");
							$sender->sendMessage("編集するブロックを触ってください");
							return true;
						case "check":
							$session->setData("type", "check");
							$sender->sendMessage("確認するブロックを触ってください");
							return true;
						case "del":
							$session->setData("type", "del");
							$sender->sendMessage("削除するブロックを触ってください");
							return true;
						case "cancel":
							$session->setValid(false);
							$sender->sendMessage("キャンセルしました");
							return true;
					}
					return true;
				}
				$form = Form::getSelectBlockActionForm();
				Form::sendForm($sender, $form, Form::getFormId("SelectBlockActionForm"));
				break;
			case 'command':
				if(isset($args[1])){
					$session = $sender->ifSession;
					$session->setValid();
					$session->setIfType(Session::COMMAND);
					$manager = $this->owner->getCommandManager();
					switch ($args[1]) {
						case "add":
							$session->setData("type", "add_");
							$form = Form::getAddCommandForm();
							Form::sendForm($sender, $form, Form::getFormId("AddCommandForm"));
							return true;
						case "add_empty":
							$session->setData("type", "add_empty");
							$form = Form::getAddCommandForm();
							Form::sendForm($sender, $form, Form::getFormId("AddCommandForm"));
							return true;
						case "edit":
							$session->setData("type", "edit");
							if(isset($args[2])){
								if(!$manager->isAdded($args[2])){
									$sender->sendMessage("そのコマンドはまだ追加されていません");
									$session->setValid(false);
									return true;
								}
								$datas = $manager->get($args[2]);
								$mes = Messages::createMessage($datas["if"], $datas["match"], $datas["else"]);
								$form = Form::getEditIfForm($mes);
								Form::sendForm($sender, $form, Form::getFormId("EditIfForm"));
								return true;
							}
							$form = Form::getSelectCommandForm();
							Form::sendForm($sender, $form, Form::getFormId("SelectCommandForm"));
							return true;
						case "check":
							$session->setData("type", "check");
							if(isset($args[2])){
								if(!$manager->isAdded($args[2])){
									$sender->sendMessage("そのコマンドはまだ追加されていません");
									$session->setValid(false);
									return true;
								}
								$datas = $manager->get($args[2]);
								$mes = Messages::createMessage($datas["if"], $datas["match"], $datas["else"]);
								$sender->sendMessage($mes);
								return true;
							}
							$form = Form::getSelectCommandForm();
							Form::sendForm($sender, $form, Form::getFormId("SelectCommandForm"));
							return true;
						case "del":
							$session->setData("type", "del");
							if(isset($args[2])){
								if(!$manager->isAdded($args[2])){
									$sender->sendMessage("そのコマンドはまだ追加されていません");
									$session->setValid(false);
									return true;
								}
								$manager->remove($args[2]);
								$sender->sendMessage("削除しました");
								return true;
							}
							$form = Form::getSelectCommandForm();
							Form::sendForm($sender, $form, Form::getFormId("SelectCommandForm"));
							return true;
						case "cancel":
							$session->setValid(false);
							$sender->sendMessage("キャンセルしました");
							return true;
					}
				}
				$form = Form::getSelectCommandActionForm();
				Form::sendForm($sender, $form, Form::getFormId("SelectCommandActionForm"));
				break;
			case 'event':
				if(isset($args[1])){
	                $session = $sender->ifSession;
	                $session->setValid();
	                $session->setIfType(Session::EVENT);
	                switch ($args[1]) {
	                    case "add":
	                    case "add_empty":
	                    case "edit":
	                    case "check":
	                    case "del":
	                        $session->setData("type", $args[1]);
	                        break;
	                    case "cancel":
	                        $session->setValid(false);
	                        $sender->sendMessage("キャンセルしました");
	                        break;
	                }
	                $form = Form::getSelectEventForm();
	                Form::sendForm($sender, $form, Form::getFormId("SelectEventForm"));
	                return true;
				}
                $form = Form::getSelectEventActionForm();
                Form::sendForm($sender, $form, Form::getFormId("SelectEventActionForm"));
				break;
			default:
				$form = Form::getSelectIfTypeForm();
				Form::sendForm($sender, $form, Form::getFormId("SelectIfTypeForm"));
				break;
		}
		return true;
	}
}<?php

namespace aieuo\ip\economy;

class EconomyAPILoader extends EconomyLoader{

	private $plugin;

	public function __construct($plugin){
		$this->plugin = $plugin;
	}

	public function getPlugin(){
		return $this->plugin;
	}

	public function getMoney($name){
		return (int)$this->plugin->mymoney($name);
	}

	public function addMoney($name, $money){
		$money = (int)$money;
        $this->plugin->addMoney($name, $money);
		return true;
	}

	public function takeMoney($name, $money){
		$money = (int)$money;
        $this->plugin->reduceMoney($name, $money);
		return true;
	}
}<?php

namespace aieuo\ip\economy;

class EconomyLoader {

	public function getMoney($name){
		return false;
	}

	public function addMoney($name, $money){
		return false;
	}

	public function takeMoney($name, $money){
		return false;
	}
}<?php

namespace aieuo\ip\economy;

class MoneySystemLoader extends EconomyLoader{

	private $plugin;

	public function __construct($plugin){
		$this->plugin = $plugin;
	}

	public function getPlugin(){
		return $this->plugin;
	}

	public function getMoney($name){
		return (int)$this->plugin->check($name);
	}

	public function addMoney($name, $money){
		$money = (int)$money;
		$this->plugin->addMoney($name, $money);
		return true;
	}

	public function takeMoney($name, $money){
		$money = (int)$money;
		$this->plugin->takeMoney($name, $money);
		return true;
	}
}<?php

namespace aieuo\ip\economy;

class PocketMoneyLoader extends EconomyLoader{

	private $plugin;

	public function __construct($plugin){
		$this->plugin = $plugin;
	}

	public function getPlugin(){
		return $this->plugin;
	}

	public function getMoney($name){
		return (int)$this->plugin->getMoney($name);
	}

	public function addMoney($name, $money){
		$money = (int)$money;
		$mymoney = $this->plugin->getMoney($name);
        $this->plugin->setMoney($name, $mymoney + $money);
		return true;
	}

	public function takeMoney($name, $money){
		$money = (int)$money;
		$mymoney = $this->plugin->getMoney($name);
        $this->plugin->setMoney($name, $mymoney - $money);
		return true;
	}
}<?php

namespace aieuo\ip;

use pocketmine\event\Listener;
use pocketmine\event\server\DataPacketReceiveEvent;
use pocketmine\network\mcpe\protocol\ModalFormResponsePacket;
use pocketmine\Player;
use pocketmine\event\player\PlayerChatEvent;
use pocketmine\event\player\PlayerCommandPreprocessEvent;
use pocketmine\event\player\PlayerInteractEvent;
use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\event\player\PlayerQuitEvent;
use pocketmine\event\player\PlayerToggleFlightEvent;
use pocketmine\event\block\BlockBreakEvent;
use pocketmine\event\block\BlockPlaceEvent;
use pocketmine\event\entity\EntityDeathEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\event\entity\EntityLevelChangeEvent;
use pocketmine\event\CraftItemEvent;

use aieuo\ip\form\Form;
use aieuo\ip\utils\Messages;
use aieuo\ip\Session;

class EventListener implements Listener {
	public function __construct($owner){
		$this->owner = $owner;
	}

    public function getOwner(){
        return $this->owner;
    }
    public function chat(PlayerChatEvent $event){
        $this->onEvent($event, "PlayerChatEvent");
    }
    public function commandProcess(PlayerCommandPreprocessEvent $event){
        $this->onEvent($event, "PlayerCommandPreprocessEvent");

        $manager = $this->getOwner()->getCommandManager();
        if($manager->isAdded(mb_substr($event->getMessage(), 1))){
            $datas = $manager->get(mb_substr($event->getMessage(), 1));
            $manager->executeIfMatchCondition($event->getPlayer(), $datas["if"], $datas["match"], $datas["else"]);
        }
    }
    public function join(PlayerJoinEvent $event){
        $this->onEvent($event, "PlayerJoinEvent");

        $player = $event->getPlayer();
        if($player->isOp()){
            $session = new Session();
            $player->ifSession = $session;
        }
    }
    public function quit(PlayerQuitEvent $event){
        $this->onEvent($event, "PlayerQuitEvent");
    }
    public function toggleFlight(PlayerToggleFlightEvent $event){
        $this->onEvent($event, "PlayerToggleFlightEvent");
    }
    public function blockBreak(BlockBreakEvent $event){
        $this->onEvent($event, "BlockBreakEvent");
    }
    public function blockPlace(BlockPlaceEvent $event){
        $this->onEvent($event, "BlockPlaceEvent");
    }
    public function entityDamage(EntityDamageEvent $event){
        $this->onEvent($event, "EntityDamageEvent");
    }
    public function entityDeath(EntityDeathEvent $event){
        $this->onEvent($event, "EntityDeathEvent");
    }
    public function onEvent($event, $eventname){
        switch ($eventname) {
            case 'PlayerInteractEvent':
            case 'PlayerChatEvent':
            case 'PlayerCommandPreprocessEvent':
            case 'PlayerJoinEvent':
            case 'PlayerQuitEvent':
            case 'PlayerToggleFlightEvent':
            case 'BlockBreakEvent':
            case 'BlockPlaceEvent':
                $player = $event->getPlayer();
                break;
            case 'EntityDamageEvent':
            case 'EntityDeathEvent':
                $player = $event->getEntity();
                if(!$player instanceof Player)return;
                break;
        }
        $manager = $this->getOwner()->getEventManager();
        $datas = $manager->getByEvent($eventname);
        $manager->setOptions($eventname, $event);
        foreach ($datas as $key => $data) {
            $data = $manager->get($key);
            $manager->executeIfMatchCondition($player, $data["if"], $data["match"], $data["else"]);
        }
    }

	public function interact(PlayerInteractEvent $event){
		$this->onEvent($event, "PlayerInteractEvent");

		$player = $event->getPlayer();
        $manager = $this->getOwner()->getBlockManager();
        $block = $event->getBlock();
        $pos = $manager->getPosition($block);
		if($player->isOp()){
			if(($session = $player->ifSession)->isValid()){
				$type = $session->getData("type");
				$manager = $this->getOwner()->getBlockManager();
				switch ($type) {
					case 'add':
                        if($manager->isAdded($pos)){
                            $player->sendMessage("そのブロックにはすでに追加されています");
                            return;
                        }
                        $form = Form::getAddIfForm();
                        Form::sendForm($player, $form, Form::getFormId("AddIfForm"));
                        $session->setData("if_key", $pos);
						return;
					case 'add_empty':
                        if($manager->isAdded($pos)){
                            $player->sendMessage("そのブロックにはすでに追加されています");
                            return;
                        }
						$manager->set($manager->getPosition($block));
	                    $player->sendMessage("追加しました");
						break;
					case 'edit':
	                    if(!$manager->isAdded($pos)){
	                        $player->sendMessage("そのブロックには追加されていません");
	                        return;
	                    }
	                    $datas = $manager->get($pos);
	                    $mes = Messages::createMessage($datas["if"], $datas["match"], $datas["else"]);
	                    $form = Form::getEditIfForm($mes);
	                    Form::sendForm($player, $form, Form::getFormId("EditIfForm"));
	                    $session->setData("if_key", $pos);
						return;
					case 'check':
	                    $pos = $manager->getPosition($block);
	                    if(!$manager->isAdded($pos)){
	                        $player->sendMessage("そのブロックには追加されていません");
	                        return;
	                    }
	                    $datas = $manager->get($pos);
	                    $mes = Messages::createMessage($datas["if"], $datas["match"], $datas["else"]);
	                    $player->sendMessage($mes);
						break;
					case 'del':
	                    $pos = $manager->getPosition($block);
	                    if(!$manager->isAdded($pos)){
	                        $player->sendMessage("そのブロックには追加されていません");
	                        return;
	                    }
	                    $manager->remove($pos);
	                    $player->sendMessage("削除しました");
						break;
				}
				$session->setValid(false);
                return;
			}
		}
        if($manager->isAdded($pos)){
            $datas = $manager->get($pos);
            $manager->executeIfMatchCondition($player, $datas["if"], $datas["match"], $datas["else"]);
        }
	}


    public function Receive(DataPacketReceiveEvent $event){
        $pk = $event->getPacket();
        $player = $event->getPlayer();
        $name = $player->getName();
        if(!$player->isOp())return;
        if($pk instanceof ModalFormResponsePacket){
            if($pk->formId === Form::getFormId("SelectIfTypeForm")){
                $data = json_decode($pk->formData);
                if($data === null) {
                   return;
                }
                $session = $player->ifSession;
                switch ($data) {
                	case 0:
		        		$form = Form::getSelectBlockActionForm();
		        		Form::sendForm($player, $form, Form::getFormId("SelectBlockActionForm"));
                		break;
                	case 1:
                        $form = Form::getSelectCommandActionForm();
                        Form::sendForm($player, $form, Form::getFormId("SelectCommandActionForm"));
                		break;
                	case 2:
                        $form = Form::getSelectEventActionForm();
                        Form::sendForm($player, $form, Form::getFormId("SelectEventActionForm"));
                		break;
                }
            }

            if($pk->formId === Form::getFormId("SelectBlockActionForm")){
                $data = json_decode($pk->formData);
                if($data === null) {
                   return;
                }
                $session = $player->ifSession;
                $session->setValid();
                $session->setIfType(Session::BLOCK);
                switch ($data) {
                	case 0:
                        $session->setData("type", "add");
                        $player->sendMessage("追加するブロックを触ってください");
                		break;
                	case 1:
						$session->setData("type", "add_empty");
                		$player->sendMessage("追加するブロックを触ってください");
                		break;
                	case 2:
						$session->setData("type", "edit");
                		$player->sendMessage("編集するブロックを触ってください");
                		break;
                	case 3:
						$session->setData("type", "check");
                		$player->sendMessage("確認するブロックを触ってください");
                		break;
                	case 4:
						$session->setData("type", "del");
                		$player->sendMessage("削除するブロックを触ってください");
                		break;
                	case 5:
                		$session->setValid(false);
                		$player->sendMessage("キャンセルしました");
                		break;
                }
            }

            if($pk->formId === Form::getFormId("EditIfForm")){
                $data = json_decode($pk->formData);
                $session = $player->ifSession;
                if($data === null) {
                	$session->setValid(false, false);
                    return;
                }
                $type = $session->getIfType();
                if($type === Session::BLOCK){
                	$manager = $this->getOwner()->getBlockManager();
                }elseif($type === Session::COMMAND){
                    $manager = $this->getOwner()->getCommandManager();
                }elseif($type === Session::EVENT){
                    $manager = $this->getOwner()->getEventManager();
                }
                $key = $session->getData("if_key");
                $datas = $manager->get($key);
                if($data == 0){
                    $form = Form::getEditContentsForm($datas["if"]);
                    $session->setData("type", "if");
                }elseif($data == 1){
                    $form = Form::getEditContentsForm($datas["match"]);
                    $session->setData("type", "match");
                }elseif($data == 2){
                    $form = Form::getEditContentsForm($datas["else"]);
                    $session->setData("type", "else");
                }else{
                    $manager->remove($key);
                    $player->sendMessage("削除しました");
                    $session->setValid(false);
                    return;
                }
	            Form::sendForm($player, $form, Form::getFormId("EditIfContentsForm"));
            }

            if($pk->formId === Form::getFormId("EditIfContentsForm")){
                $data = json_decode($pk->formData);
                $session = $player->ifSession;
                if($data === null) {
                    $session->setValid(false, false);
                    return;
                }
                $type = $session->getIfType();
                $event = false;
                if($type === Session::BLOCK){
                	$manager = $this->getOwner()->getBlockManager();
                }elseif($type === Session::COMMAND){
                    $manager = $this->getOwner()->getCommandManager();
                }elseif($type === Session::EVENT){
                    $manager = $this->getOwner()->getEventManager();
                    $event = true;
                }
                $key = $session->getData("if_key");
                $datas = $manager->get($key);
                if($data == 0){
                    $form = Form::getAddContentsForm($session->getData("type"), $event);
                    Form::sendForm($player, $form, Form::getFormId("AddContentsForm"));
                }else{
                	$if = $datas[$session->getData("type")][--$data];
                    $form = Form::getDetailForm((int)$if["id"], $if["content"]);
                    Form::sendForm($player, $form, Form::getFormId("DetailForm"));
                    $session->setData("num", $data);
                    $session->setData("id", $if["id"]);
                    $session->setData("content", $if["content"]);
                }
            }

            if($pk->formId === Form::getFormId("AddContentsForm")){
            	$json = str_replace([",]",",,"], [",\"\"]",",\"\","], $pk->formData);
                $data = json_decode($json);
                $session = $player->ifSession;
                if($data === null) {
                	$session->setValid(false, false);
                    return;
                }
                $type = $session->getIfType();
                if($type === Session::BLOCK){
                	$manager = $this->getOwner()->getBlockManager();
                }elseif($type === Session::COMMAND){
                    $manager = $this->getOwner()->getCommandManager();
                }elseif($type === Session::EVENT){
                    $manager = $this->getOwner()->getEventManager();
                }
                if($session->getData("type") == "if"){
                	$id = $manager->getIfIdByListNumber($data[0]);
                }else{
                	$id = $manager->getExeIdByListNumber($data[0]);
                }
                $manager->add($session->getData("if_key"), $session->getData("type"), $id, $data[1]);
                $player->sendMessage("追加しました");
            }

            if($pk->formId === Form::getFormId("DetailForm")){
                $data = json_decode($pk->formData);
                $session = $player->ifSession;
                if($data === null) {
                	$session->setValid(false, false);
                    return;
                }
                $type = $session->getIfType();
                if($type === Session::BLOCK){
                    $manager = $this->getOwner()->getBlockManager();
                }elseif($type === Session::COMMAND){
                    $manager = $this->getOwner()->getCommandManager();
                }elseif($type === Session::EVENT){
                    $manager = $this->getOwner()->getEventManager();
                }
                if($data == 0){
                    $form = Form::getUpdateContentsForm($session->getData("type"), $session->getData("id"), $session->getData("content"));
                    Form::sendForm($player, $form, Form::getFormId("UpdateContentsForm"));
                }elseif($data == 1){
                    $manager->del($session->getData("if_key"), $session->getData("type"), $session->getData("num"));
                    $player->sendMessage("削除しました");
                }
            }

            if($pk->formId === Form::getFormId("UpdateContentsForm")){
                $json = str_replace([",]",",,"], [",\"\"]",",\"\","], $pk->formData);
                $data = json_decode($json);
                $session = $player->ifSession;
                if($data === null) {
                    $session->setValid(false, false);
                    return;
                }
                $type = $session->getIfType();
                if($type === Session::BLOCK){
                    $manager = $this->getOwner()->getBlockManager();
                }elseif($type === Session::COMMAND){
                    $manager = $this->getOwner()->getCommandManager();
                }elseif($type === Session::EVENT){
                    $manager = $this->getOwner()->getEventManager();
                }
                $manager->del($session->getData("if_key"), $session->getData("type"), $session->getData("num"));
                $manager->add($session->getData("if_key"), $session->getData("type"), $session->getData("id"), $data[1]);
                $player->sendMessage("変更しました");
            }

            if($pk->formId === Form::getFormId("AddIfForm")){
                $data = json_decode($pk->formData);
                $session = $player->ifSession;
                if($data === null) {
                    $session->setValid(false, false);
                    return;
                }
                $id_1 = ifAPI::getIfIdByListNumber($data[0]);
                $id_2 = ifAPI::getExeIdByListNumber($data[1]);
                $id_3 = ifAPI::getExeIdByListNumber($data[2]);
                $form = Form::createIfContentForm($id_1, $id_2, $id_3);
                Form::sendForm($player, $form, Form::getFormId("InputContentsForm"));
                $session->setData("id_1", $id_1);
                $session->setData("id_2", $id_2);
                $session->setData("id_3", $id_3);
            }

            if($pk->formId === Form::getFormId("InputContentsForm")){
                $data = json_decode($pk->formData);
                $session = $player->ifSession;
                if($data === null) {
                    $session->setValid(false, false);
                    return;
                }
                $type = $session->getIfType();
                if($type === Session::BLOCK){
                    $manager = $this->getOwner()->getBlockManager();
                }elseif($type === Session::COMMAND){
                    $manager = $this->getOwner()->getCommandManager();
                    $manager->setOptions($session->getData("if_key"), $session->getData("description"), $session->getData("permission"));
                }elseif($type === Session::EVENT){
                    $manager = $this->getOwner()->getEventManager();
                    $manager->setOptions($session->getData("event"));
                    $key = $manager->add_empty();
                    $session->setData("if_key", $key);
                }
                $key = $session->getData("if_key");
                $manager->add($key, "if", $session->getData("id_1"), (string)$data[0]);
                $manager->add($key, "match", $session->getData("id_2"), (string)$data[1]);
                $manager->add($key, "else", $session->getData("id_3"), (string)$data[2]);
                $session->setValid(false);
                $player->sendMessage("追加しました");
            }

            if($pk->formId === Form::getFormId("SelectCommandActionForm")){
                $data = json_decode($pk->formData);
                if($data === null) {
                   return;
                }
                $session = $player->ifSession;
                $session->setValid();
                $session->setIfType(Session::COMMAND);
                switch ($data) {
                    case 0:
                        $session->setData("type", "add");
                        break;
                    case 1:
                        $session->setData("type", "add_empty");
                        break;
                    case 2:
                        $session->setData("type", "edit");
                        break;
                    case 3:
                        $session->setData("type", "check");
                        break;
                    case 4:
                        $session->setData("type", "del");
                        break;
                    case 5:
                        $session->setValid(false);
                        $player->sendMessage("キャンセルしました");
                        break;
                }
                switch ($data) {
                    case 0:
                    case 1:
                        $form = Form::getAddCommandForm();
                        Form::sendForm($player, $form, Form::getFormId("AddCommandForm"));
                        break;
                    case 2:
                    case 3:
                    case 4:
                        $form = Form::getSelectCommandForm();
                        Form::sendForm($player, $form, Form::getFormId("SelectCommandForm"));
                        break;
                }
            }

            if($pk->formId === Form::getFormId("AddCommandForm")){
                $json = str_replace([",]",",,"], [",\"\"]",",\"\","], $pk->formData);
                $data = json_decode($json);
                $session = $player->ifSession;
                $manager = $this->getOwner()->getCommandManager();
                if($data === null) {
                    $session->setValid(false, false);
                    return;
                }
                if($data[0] === ""){
                    $player->sendMessage("必要事項を入力してください");
                    return;
                }
                if($manager->exists($data[0])){
                    $player->sendMessage("§cそのコマンドは既に使用されています");
                    return;
                }
                if($manager->isAdded($data[0])){
                    $player->sendMessage("§eそのコマンドは既に追加しています");
                    return;
                }
                if($data[1] === "")$data[1] = "ifPluginで追加したコマンドです";
                if($session->getData("type") == "add_empty"){
                    $manager->setOptions($data[0], $data[1], $data[2] == 0 ? "op" : "default");
                    $manager->set($data[0]);
                    $player->sendMessage("追加しました");
                    $session->setValid(false);
                    return;
                }
                $session->setData("if_key", $data[0]);
                $session->setData("description", $data[1]);
                $session->setData("permission", $data[2] == 0 ? "op" : "default");
                $form = Form::getAddIfForm();
                Form::sendForm($player, $form, Form::getFormId("AddIfForm"));
            }

            if($pk->formId === Form::getFormId("SelectCommandForm")){
                $data = json_decode($pk->formData);
                $session = $player->ifSession;
                if($data === null) {
                    $session->setValid(false, false);
                    return;
                }
                if($data[0] === ""){
                    $player->sendMessage("必要事項を入力してください");
                    return;
                }
                $session->setData("if_key", $data[0]);
                $type = $session->getData("type");
                $manager = $this->getOwner()->getCommandManager();
                if(!$manager->isAdded($data[0])){
                    $player->sendMessage("そのコマンドはまだ追加されていません");
                    return;
                }
                if($type == "edit"){
                    $datas = $manager->get($data[0]);
                    $mes = Messages::createMessage($datas["if"], $datas["match"], $datas["else"]);
                    $form = Form::getEditIfForm($mes);
                    Form::sendForm($player, $form, Form::getFormId("EditIfForm"));
                }elseif($type == "check"){
                    $datas = $manager->get($data[0]);
                    $mes = Messages::createMessage($datas["if"], $datas["match"], $datas["else"]);
                    $player->sendMessage($mes);
                }elseif($type == "del"){
                    $manager->remove($data[0]);
                    $player->sendMessage("削除しました");
                }
            }

            if($pk->formId === Form::getFormId("SelectEventActionForm")){
                $data = json_decode($pk->formData);
                if($data === null) {
                   return;
                }
                $session = $player->ifSession;
                $session->setValid();
                $session->setIfType(Session::EVENT);
                switch ($data) {
                    case 0:
                        $session->setData("type", "add");
                        break;
                    case 1:
                        $session->setData("type", "add_empty");
                        break;
                    case 2:
                        $session->setData("type", "edit");
                        break;
                    case 3:
                        $session->setData("type", "check");
                        break;
                    case 4:
                        $session->setData("type", "del");
                        break;
                    case 5:
                        $session->setValid(false);
                        $player->sendMessage("キャンセルしました");
                        break;
                }
                $form = Form::getSelectEventForm();
                Form::sendForm($player, $form, Form::getFormId("SelectEventForm"));
            }

            if($pk->formId === Form::getFormId("SelectEventForm")){
                $data = json_decode($pk->formData);
                $session = $player->ifSession;
                if($data === null) {
                    $session->setValid(false, false);
                    return;
                }
                $eventname = ifAPI::getEventName($data[0]);
                $session->setData("event", $eventname);
                $type = $session->getData("type");
                $manager = $this->getOwner()->getEventManager();
                $manager->setOptions($eventname);
                switch ($type) {
                    case 'add':
                        $form = Form::getAddIfForm(true);
                        Form::sendForm($player, $form, Form::getFormId("AddIfForm"));
                        $session->setData("if_key", null);
                        break;
                    case 'add_empty':
                        $manager->add_empty();
                        $player->sendMessage("追加しました");
                        $session->setValid(false);
                        break;
                    case 'edit':
                    case 'check':
                    case 'del':
                        $all = $manager->getByEvent($eventname);
                        $datas = [];
                        foreach ($all as $key => $value) {
                            $datas[] = $manager->get($key);
                        }
                        $form = Form::getEditEventForm($eventname, $datas);
                        Form::sendForm($player, $form, Form::getFormId("EditEventForm"));
                        break;
                }
            }

            if($pk->formId === Form::getFormId("EditEventForm")){
                $data = json_decode($pk->formData);
                $session = $player->ifSession;
                if($data === null) {
                    $session->setValid(false, false);
                    return;
                }
                $type = $session->getData("type");
                $manager = $this->getOwner()->getEventManager();
                $manager->setOptions($session->getData("event"));
                $datas = $manager->get($data);
                if($data == $manager->getCount($session->getData("event"))){
                    $form = Form::getAddIfForm(true);
                    Form::sendForm($player, $form, Form::getFormId("AddIfForm"));
                    $session->setData("if_key", null);
                    return;
                }
                switch ($type) {
                    case 'edit':
                        $mes = Messages::createMessage($datas["if"], $datas["match"], $datas["else"]);
                        $form = Form::getEditIfForm($mes);
                        Form::sendForm($player, $form, Form::getFormId("EditIfForm"));
                        $session->setData("if_key", $data);
                        break;
                    case 'check':
                        $mes = Messages::createMessage($datas["if"], $datas["match"], $datas["else"]);
                        $player->sendMessage($mes);
                        $session->setValid(false);
                        break;
                    case 'del':
                        $manager->remove($data);
                        $player->sendMessage("削除しました");
                        $session->setValid(false);
                        break;
                }
            }
        }
    }
}<?php

namespace aieuo\ip\form;

class Elements {
    public static function getLabel($text){
        return [
            "type" => "label",
            "text" => $text
        ];
    }

    public static function getInput($text, $placeholder = "", $default = ""){
        return [
            "type" => "input",
            "text" => $text,
            "default" => $default,
            "placeholder" => $placeholder
        ];
    }

    public static function getToggle($text){
        return [
            "type" => "toggle",
            "text" => $text
        ];
    }

    public static function getDropdown($text, $options, $default = 0){
    	$default = $options[$default];
    	return [
            "type" => "dropdown",
            "text" => $text,
            "options" => $options,
            "defaultOptionIndex" => $default
        ];
    }

    public function getButton($text){
    	return [
    		"text" => $text
    	];
    }
}<?php

namespace aieuo\ip\form;

use pocketmine\network\mcpe\protocol\ModalFormRequestPacket;

use aieuo\ip\ifPlugin;
use aieuo\ip\ifAPI;
use aieuo\ip\utils\Messages;

class Form {

    private static $formId;

    public static function sendForm($player, $data, $id){
        $pk = new ModalFormRequestPacket();
        $pk->formId = $id;
        $pk->formData = $data;
        $player->dataPacket($pk);
    }

    public static function registerFormId($name){
        self::$formId[$name] = mt_rand(1, 999999999);
    }

    public static function registerFormIds(){
        self::registerFormId("SelectIfTypeForm");
        self::registerFormId("SelectIfForm");
        self::registerFormId("SelectBlockActionForm");
        self::registerFormId("EditIfForm");
        self::registerFormId("EditIfContentsForm");
        self::registerFormId("AddContentsForm");
        self::registerFormId("UpdateContentsForm");
        self::registerFormId("DetailForm");
        self::registerFormId("AddIfForm");
        self::registerFormId("InputContentsForm");
        self::registerFormId("SelectCommandActionForm");
        self::registerFormId("AddCommandForm");
        self::registerFormId("SelectCommandForm");
        self::registerFormId("SelectEventActionForm");
        self::registerFormId("SelectEventForm");
        self::registerFormId("EditEventForm");
    }

    public static function getFormId($type){
        return self::$formId[$type];
    }

////////////////////////////////block////////////////////////////////
    public static function getSelectBlockActionForm(){
        $data = [
            "type" => "form",
            "title" => "選択",
            "content" => "§7ボタンを押してください",
            "buttons" => [
                [
                    "text" => "追加する"
                ],
                [
                    "text" => "空の物を追加する",
                ],
                [
                    "text" => "編集する"
                ],
                [
                    "text" => "確認する"
                ],
                [
                    "text" => "削除する"
                ],
                [
                    "text" => "キャンセルする"
                ]
            ]
        ];
        $json = self::encodeJson($data);
        return $json;
    }
////////////////////////////////command////////////////////////////////
    public static function getSelectCommandActionForm(){
        $data = [
            "type" => "form",
            "title" => "選択",
            "content" => "§7ボタンを押してください",
            "buttons" => [
                [
                    "text" => "追加する"
                ],
                [
                    "text" => "コマンドだけ追加する",
                ],
                [
                    "text" => "編集する"
                ],
                [
                    "text" => "確認する"
                ],
                [
                    "text" => "削除する"
                ],
                [
                    "text" => "キャンセルする"
                ]
            ]
        ];
        $json = self::encodeJson($data);
        return $json;
    }
    public static function getAddCommandForm(){
        $data = [
            "type" => "custom_form",
            "title" => "追加",
            "content" => [
                Elements::getInput("追加するコマンドの名前", "最初の/を外して"),
                Elements::getInput("コマンドの説明"),
                Elements::getDropdown("権限", ["opだけ", "全員使える"], 1)
            ]
        ];
        $json = self::encodeJson($data);
        return $json;
    }
    public static function getSelectCommandForm(){
        $data = [
            "type" => "custom_form",
            "title" => "コマンド選択",
            "content" => [
                Elements::getInput("コマンドの名前", "最初の/を外して"),
            ]
        ];
        $json = self::encodeJson($data);
        return $json;
    }
////////////////////////////////event////////////////////////////////
    public static function getSelectEventActionForm(){
        $data = [
            "type" => "form",
            "title" => "選択",
            "content" => "§7ボタンを押してください",
            "buttons" => [
                [
                    "text" => "追加する"
                ],
                [
                    "text" => "空の物を追加する",
                ],
                [
                    "text" => "編集する"
                ],
                [
                    "text" => "確認する"
                ],
                [
                    "text" => "削除する"
                ],
                [
                    "text" => "キャンセルする"
                ]
            ]
        ];
        $json = self::encodeJson($data);
        return $json;
    }
    public static function getSelectEventForm(){
        $data = [
            "type" => "custom_form",
            "title" => "イベント選択",
            "content" => [
                Parts::getEventListDropdown()
            ]
        ];
        $json = self::encodeJson($data);
        return $json;
    }

    public static function getEditEventForm($event, $datas){
        $data = [
            "type" => "form",
            "title" => $event,
            "content" => "イベントの編集",
            "buttons" => []
        ];
        foreach ($datas as $key => $value) {
            $mes = Messages::createMessage($value["if"], $value["match"], $value["else"]);
            $data["buttons"][] = ["text" => mb_substr(str_replace("\n", " ", $mes), 0, 30)."・・・"];
        }
        $data["buttons"][] = ["text" => "追加する"];
        $json = self::encodeJson($data);
        return $json;
    }
////////////////////////////////all////////////////////////////////
    public static function getSelectIfTypeForm(){
        $data = [
            "type" => "form",
            "title" => "選択",
            "content" => "§7ボタンを押してください",
            "buttons" => [
                [
                    "text" => "ブロック"
                ],
                [
                    "text" => "コマンド",
                ],
                [
                    "text" => "イベント"
                ]
            ]
        ];
        $json = self::encodeJson($data);
        return $json;
    }

    public static function getEditIfForm($mes){
        $data = [
            "type" => "form",
            "title" => "編集",
            "content" => $mes,
            "buttons" => [
                [
                    "text" => "もし~を編集する"
                ],
                [
                    "text" => "条件に合った時を編集する",
                ],
                [
                    "text" => "条件に合わなかった時を編集する"
                ],
                [
                    "text" => "削除する"
                ]
            ]
        ];
        $data = self::encodeJson($data);
        return $data;
    }
    public static function getEditContentsForm($datas){
        $data = [
            "type" => "form",
            "title" => "編集",
            "content" => "",
            "buttons" => []
        ];
        $data["buttons"][] = ["text" => "追加する"];
        foreach ($datas as $key => $value) {
            $data["buttons"][] = ["text" => Messages::getMessage($value["id"], $value["content"])];
        }
        $data = self::encodeJson($data);
        return $data;
    }

    public static function getDetailForm($id, $content){
        $data = [
            "type" => "form",
            "title" => "詳細",
            "content" => Messages::getMessage($id, $content),
            "buttons" => [
                ["text" => "編集する"],
                ["text" => "削除する"]
            ]
        ];
        $data = self::encodeJson($data);
        return $data;
    }

    public static function getSelectIfForm($ifs){
        $buttons = [];
        foreach ($ifs as $if){
            $buttons[] = ["text" => $if];
        }
        $data = [
            "type" => "form",
            "title" => "選択",
            "content" => "§7ボタンを押してください",
            "buttons" => $buttons
        ];
        $json = self::encodeJson($data);
        return $json;
    }

    public static function getAddContentsForm($type, $event = false){
        if($type == "if"){
            $list = Parts::getIflistDropdown();
        }else{
            $list = Parts::getExelistDropdown(0, $event);
        }
        $data = [
            "type" => "custom_form",
            "title" => "追加",
            "content" => [
                $list,
                Elements::getInput("値を入力して下さい")
            ]
        ];
        $json = self::encodeJson($data);
        return $json;
    }

    public static function getUpdateContentsForm($type, $id, $defaltInput = ""){
        if($type == "if"){
            $mes = Parts::getIflist()[ifAPI::getListNumberByIfId($id)];
        }else{
            $mes = Parts::getExelist()[ifAPI::getListNumberByExeId($id)];
        }
        $data = [
            "type" => "custom_form",
            "title" => "追加",
            "content" => [
                Elements::getLabel($mes),
                Elements::getInput("値を入力して下さい", "", $defaltInput)
            ]
        ];
        $json = self::encodeJson($data);
        return $json;
    }

    public static function getAddIfForm($event = false){
        $data = [
            "type" => "custom_form",
            "title" => "追加",
            "content" => [
                Parts::getIflistDropdown(),
                Parts::getExelistDropdown(0, $event),
                Parts::getExelistDropdown(0, $event)
            ]
        ];
        $json = self::encodeJson($data);
        return $json;
    }
//////////////////////////////////////////////////////////
    public static function createIfContentForm($type1, $type2, $type3, $encode = true, $event = false){
        $messages1 = Messages::getFormMessage($type1, $event);//もし
        $messages2 = Messages::getFormMessage($type2);//合ったら
        $messages3 = Messages::getFormMessage($type3);//合わなかったら

        if($messages1["type"] == "input"){
            $input1 = Elements::getInput($messages1["message"], $messages1["placeholder"]);
        }else{
            $input1 = Elements::getLabel($messages1["message"]);
        }
        if($messages2["type"] == "input"){
            $input2 = Elements::getInput($messages1["next"].$messages2["message"], $messages2["placeholder"]);
        }else{
            $input2 = Elements::getLabel($messages2["message"]);
        }
        if($messages3["type"] == "input"){
            $input3 = Elements::getInput($messages2["next"]."合わなかったら\n".$messages3["message"], $messages3["placeholder"]);
        }else{
            $input3 = Elements::getLabel("合わなかったら\n".$messages3["message"]);
        }

        $content[] = $input1;
        $content[] = $input2;
        $content[] = $input3;

        $content[] = Elements::getLabel($messages3["next"]);

        $data = [
            "type" => "custom_form",
            "title" => "ifPlugin",
            "content" => $content
        ];
        if($encode)$data = self::encodeJson($data);
        return $data;
    }

//////////////////////////////////////////////////////////////
    public static function encodeJson($data){
        $json = json_encode($data, JSON_PRETTY_PRINT | JSON_BIGINT_AS_STRING | JSON_UNESCAPED_UNICODE);
        return $json;
    }
}<?php

namespace aieuo\ip\form;

class Parts {

	public static function getIfList(){
    	$list = [
            "何も確認しない",
            "お金を減らす",
            "指定した金額より所持金が多いか",
            "指定したアイテムを手に持ってるか",
            "インベントリに指定したアイテムが入ってるか",
            "指定したアイテムがインベントリにあるなら削除する",
            "プレイヤーがopか",
            "プレイヤーがスニークしているか",
            "プレイヤーが飛んでいるか",
            "ゲームモードが指定したものだったら",
            "指定した範囲内にいたら",
            "乱数が指定したものだったら",
            "二つの値を比較する",
        ];
        return $list;
	}
    public static function getIflistDropdown($default = 0){
    	$options = self::getIfList();
        $dropdown = Elements::getDropdown("もし～なら", $options, $default);
    	return $dropdown;
    }

    public static function getExeList(){
    	$list = [
            "何もしない",
            "チャット欄にメッセージ送信",
            "tip欄にメッセージ送信",
            "タイトル送信",
            "全体にメッセージ送信",
            "opだけにメッセージ送信",
            "音声付きのメッセージを送信",
            "コマンドを実行する",
            "コンソールからコマンド実行",
            "遅れてコマンド実行",
            "テレポート",
            "動かす",
            "インベントリにアイテムを追加する",
            "インベントリからアイテムを削除する",
            "プレイヤーを動けなくする",
            "プレイヤーを動けるようにする",
            "手に持ってるアイテムにエンチャントを追加する",
            "エフェクトを与える",
            "表示する名前を変更する",
            "寝かせる",
            "座らせる",
            "ゲームモードを変更する",
            "体力を変更する",
            "最大体力を変更する",
            "攻撃する",
            "キックする",
        ];
        return $list;
    }
    public static function getExelistDropdown($default = 0, $event = false){
    	$options = self::getExeList();
        if($event)$options[] = "イベントをキャンセルする";
        $dropdown = Elements::getDropdown("条件に当てはまったら～をする", $options, $default);
    	return $dropdown;
    }

    public static function getEventListDropdown(){
    	$options = [
            "プレイヤーがチャットしたとき",
            "プレイヤーがコマンドを実行したとき",
            "プレイヤーがブロックを触ったとき",
            "プレイヤーがサーバーに参加したとき",
            "プレイヤーがサーバーから退室したとき",
            "プレイヤーがブロックを壊したとき",
            "プレイヤーがブロックを置いたとき",
            "プレイヤーがダメージを受けたとき",
            "プレイヤーがフライ状態を切り替えたとき",
            "プレイヤーが死亡したとき",
        ];
        $dropdown = Elements::getDropdown("イベントを選んでください", $options);
    	return $dropdown;
    }
}<?php

namespace aieuo\ip;

use aieuo\ip\manager\ifManager;

use pocketmine\Server;
use pocketmine\item\Item;
use pocketmine\item\enchantment\Enchantment;
use pocketmine\item\enchantment\EnchantmentInstance;
use pocketmine\lang\TranslationContainer;
use pocketmine\command\ConsoleCommandSender;
use pocketmine\level\Position;
use pocketmine\math\Vector3;
use pocketmine\entity\Effect;
use pocketmine\entity\EffectInstance;
use pocketmine\entity\Entity;
use pocketmine\network\mcpe\protocol\ModalFormRequestPacket;
use pocketmine\network\mcpe\protocol\AddEntityPacket;
use pocketmine\network\mcpe\protocol\types\EntityLink;
use pocketmine\event\entity\EntityDamageEvent;

use aieuo\ip\task\DelayedCommandTask;

class ifAPI {

	const MATCHED = 0;
	const NOT_MATCHED = 1;
	const NOT_FOUND = 2;

    public static function getIfIdByListNumber($num){
        switch ($num){
            case 0:
                return ifPlugin::IF_NO_CHECK;
            case 1:
                return ifPlugin::IF_TAKEMONEY;
            case 2:
                return ifPlugin::IF_OVERMONEY;
            case 3:
                return ifPlugin::IF_HAVEINGITEM;
            case 4:
                return ifPlugin::IF_EXISTITEM;
            case 5:
                return ifPlugin::IF_REMOVEITEM;
            case 6:
                return ifPlugin::IF_IS_OP;
            case 7:
                return ifPlugin::IF_IS_SNEAKING;
            case 8:
                return ifPlugin::IF_IS_FLYING;
            case 9:
                return ifPlugin::IF_GAMEMODE;
            case 10:
                return ifPlugin::IF_IN_AREA;
            case 11:
                return ifPlugin::IF_RANDOM_NUMBER;
            case 12:
                return ifPlugin::IF_COMPARISON;
            default:
                return false;
        }
    }

    public static function getListNumberByIfId($id){
        switch ($id){
            case ifPlugin::IF_NO_CHECK:
            	return 0;
            case ifPlugin::IF_TAKEMONEY:
            	return 1;
            case ifPlugin::IF_OVERMONEY:
            	return 2;
            case ifPlugin::IF_HAVEINGITEM:
            	return 3;
            case ifPlugin::IF_EXISTITEM:
            	return 4;
            case ifPlugin::IF_REMOVEITEM:
            	return 5;
            case ifPlugin::IF_IS_OP:
            	return 6;
            case ifPlugin::IF_IS_SNEAKING:
            	return 7;
            case ifPlugin::IF_IS_FLYING:
            	return 8;
            case ifPlugin::IF_GAMEMODE:
            	return 9;
            case ifPlugin::IF_IN_AREA:
                return 10;
            case ifPlugin::IF_RANDOM_NUMBER:
                return 11;
            case ifPlugin::IF_COMPARISON:
                return 12;
            default:
                return false;
        }
    }

    public static function getExeIdByListNumber($num){
        switch ($num){
            case 0:
                return ifPlugin::DO_NOTHING;
            case 1:
                return ifPlugin::SENDMESSAGE;
            case 2:
                return ifPlugin::SENDTIP;
            case 3:
                return ifPlugin::SENDTITLE;
            case 4:
                return ifPlugin::BROADCASTMESSAGE;
            case 5:
                return ifPlugin::SENDMESSAGE_TO_OP;
            case 6:
                return ifPlugin::SENDVOICEMESSAGE;
            case 7:
                return ifPlugin::COMMAND;
            case 8:
                return ifPlugin::COMMAND_CONSOLE;
            case 9:
                return ifPlugin::DELAYED_COMMAND;
            case 10:
                return ifPlugin::TELEPORT;
            case 11:
                return ifPlugin::MOTION;
            case 12:
                return ifPlugin::ADD_ITEM;
            case 13:
                return ifPlugin::REMOVE_ITEM;
            case 14:
                return ifPlugin::SET_IMMOBILE;
            case 15:
                return ifPlugin::UNSET_IMMOBILE;
            case 16:
                return ifPlugin::ADD_ENCHANTMENT;
            case 17:
                return ifPlugin::ADD_EFFECT;
            case 18:
                return ifPlugin::SET_NAMETAG;
            case 19:
                return ifPlugin::SET_SLEEPING;
            case 20:
                return ifPlugin::SET_SITTING;
            case 21:
                return ifPlugin::SET_GAMEMODE;
            case 22:
                return ifPlugin::SET_HEALTH;
            case 23:
                return ifPlugin::SET_MAXHEALTH;
            case 24:
                return ifPlugin::ATTACK;
            case 25:
                return ifPlugin::KICK;
            case 26:
                return ifPlugin::EVENT_CANCELL;
            default:
                return false;
        }
    }

    public static function getListNumberByExeId($num){
        switch ($num){
            case ifPlugin::DO_NOTHING:
            	return 0;
            case ifPlugin::SENDMESSAGE:
            	return 1;
            case ifPlugin::SENDTIP:
            	return 2;
            case ifPlugin::SENDTITLE:
            	return 3;
            case ifPlugin::BROADCASTMESSAGE:
            	return 4;
            case ifPlugin::SENDMESSAGE_TO_OP:
            	return 5;
            case ifPlugin::SENDVOICEMESSAGE:
            	return 6;
            case ifPlugin::COMMAND:
            	return 7;
            case ifPlugin::COMMAND_CONSOLE:
                return 8;
            case ifPlugin::DELAYED_COMMAND:
                return 9;
            case ifPlugin::TELEPORT:
            	return 10;
            case ifPlugin::MOTION:
            	return 11;
            case ifPlugin::ADD_ITEM:
            	return 12;
            case ifPlugin::REMOVE_ITEM:
            	return 13;
            case ifPlugin::SET_IMMOBILE:
            	return 14;
            case ifPlugin::UNSET_IMMOBILE:
            	return 15;
            case ifPlugin::ADD_ENCHANTMENT:
            	return 16;
            case ifPlugin::ADD_EFFECT:
            	return 17;
            case ifPlugin::SET_NAMETAG:
            	return 18;
            case ifPlugin::SET_SLEEPING:
            	return 19;
            case ifPlugin::SET_SITTING:
            	return 20;
            case ifPlugin::SET_GAMEMODE:
            	return 21;
            case ifPlugin::SET_HEALTH:
            	return 22;
            case ifPlugin::SET_MAXHEALTH:
            	return 23;
            case ifPlugin::ATTACK:
            	return 24;
            case ifPlugin::KICK:
            	return 25;
            case ifPlugin::EVENT_CANCELL:
            	return 26;
            default:
                return false;
        }
    }

    public static function getEventName($num){
        switch ($num) {
            case 0:
                $eventname = "PlayerChatEvent";
                break;
            case 1:
                $eventname = "PlayerCommandPreprocessEvent";
                break;
            case 2:
                $eventname = "PlayerInteractEvent";
                break;
            case 3:
                $eventname = "PlayerJoinEvent";
                break;
            case 4:
                $eventname = "PlayerQuitEvent";
                break;
            case 5:
                $eventname = "BlockBreakEvent";
                break;
            case 6:
                $eventname = "BlockPlaceEvent";
                break;
            case 7:
                $eventname = "EntityDamageEvent";
                break;
            case 8:
                $eventname = "PlayerToggleFlightEvent";
                break;
            case 9:
                $eventname = "PlayerDeathEvent";
                break;
            default:
                $eventname = "";
        }
        return $eventname;
    }

    public function checkMatchCondition($player, $type, $content, $eventname = null, $data = null){
        $result = self::NOT_MATCHED;
        $name = $player->getName();
        switch ($type) {
            case ifPlugin::IF_NO_CHECK:
                $result = self::MATCHED;
                break;
            case ifPlugin::IF_TAKEMONEY:
            	$mymoney = ifManager::getOwner()->getEcomony()->getMoney($name);
                $money = (int)$content;
                if($mymoney === false){
                    $player->sendMessage("§c経済システムプラグインが見つかりません");
                    break;
                }
                if($mymoney >= $money){
                    ifManager::getOwner()->getEconomy()->reduceMoney($name, $money);
                    $result = self::MATCHED;
                }
                break;
            case ifPlugin::IF_OVERMONEY:
            	$mymoney = ifManager::getOwner()->getEcomony()->getMoney($name);
                $money = (int)$content;
                if($mymoney === false){
                    $player->sendMessage("§c経済システムプラグインが見つかりません");
                    break;
                }
                if($mymoney >= $money){
                    $result = self::MATCHED;
                }
                break;
            case ifPlugin::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 = self::MATCHED;
                    }
                }else{
                    if($item->getId() == $id[0] and $item->getDamage() == $id[1] ){
                        $result = self::MATCHED;
                    }
                }
                break;
            case ifPlugin::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 = self::MATCHED;
                break;
            case ifPlugin::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 = self::MATCHED;
                    }
                }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 = self::MATCHED;
                    }
                }
                break;
            case ifPlugin::IF_IS_OP:
                if($player->isOp())$result = self::MATCHED;
                break;
            case ifPlugin::IF_IS_SNEAKING:
                if($player->isSneaking())$result = self::MATCHED;
                break;
            case ifPlugin::IF_IS_FLYING:
                if($player->isFlying())$result = self::MATCHED;
                break;
            case ifPlugin::IF_GAMEMODE:
                $gamemode = $player->getServer()->getGamemodeFromString($content);
                if($player->getGamemode() == $gamemode)$result = self::MATCHED;
                break;
            case ifPlugin::IF_IN_AREA:
                preg_match("/([xyz]\(-?[0-9\.]+,-?[0-9\.]+\))+/", $content, $matches);
                array_shift($matches);
                $checks = [];
                foreach ($matches as $match) {
                    if(!preg_match("/([xyz])\((-?[0-9\.]+),-?([0-9\.]+)\)/", $match, $matches1))continue;
                    $min = min((float)$matches1[2], (float)$matches1[3]);
                    $max = max((float)$matches1[2], (float)$matches1[3]);
                    $checks[$matches1[1]] = [$min, $max];
                }
                if(count($checks) == 0)break;
                $result = self::MATCHED;
                foreach ($checks as $axis => $value) {
                    if($player->$axis < $value[0] and $player->$axis > $value[1]){
                        $result = self::NOT_MATCHED;
                    }
                }
                break;
            case ifPlugin::IF_RANDOM_NUMBER:
                if(!preg_match("/(-?[0-9]+),(-?[0-9]+);(-?[0-9]+)/", $content, $matches)) break;
                $min = min((int)$matches[1], (int)$matches[2]);
                $max = max((int)$matches[1], (int)$matches[2]);
                $rand = mt_rand($min, $max);
                if($rand == (int)$matches[3])$result = self::MATCHED;
                break;
            case ifPlugin::IF_COMPARISON:
                if(!preg_match("/([^!>=<]+)([!>=<]{1,2})([^!>=<]+)/", $content, $matches)){
                    $player->sendMessage("§c[二つの値を比較する] 正しく入力できていません§f");
                    break;
                }
                $operator = $matches[2];
                $val1 = trim(rtrim($matches[1]));
                $val2 = trim(rtrim($matches[3]));
                switch ($operator){
                    case "=":
                    case "==":
                        if($val1 == $val2)$result = self::MATCHED;
                        break;
                    case "!=":
                    case "=!":
                        if($val1 != $val2)$result = self::MATCHED;
                        break;
                    case ">":
                        if($val1 > $val2)$result = self::MATCHED;
                        break;
                    case "<":
                        if($val1 < $val2)$result = self::MATCHED;
                        break;
                    case ">=":
                    case "=>":
                        if($val1 >= $val2)$result = self::MATCHED;
                        break;
                    case "<=":
                    case "=<":
                        if($val1 <= $val2)$result = self::MATCHED;
                        break;
                    case "><":
                        if(strpos($val1, $val2) !== false)$result = self::MATCHED;
                        break;
                    case "<>":
                        if(strpos($val1, $val2) === false)$result = self::MATCHED;
                        break;
                    default:
                        $player->sendMessage("§c[二つの値を比較する] その組み合わせは使用できません 次の中から選んでください[==|>|>=|<|<=|!=]§r");
                        break;
                }
                break;
            default:
                $result = self::NOT_FOUND;
                break;
        }
        return $result;
    }

    public function execute($player, $type, $content){
        $name = $player->getName();
        switch ($type) {
            case ifPlugin::DO_NOTHING:
                break;
            case ifPlugin::SENDMESSAGE:
                $player->sendMessage($content);
                break;
            case ifPlugin::SENDTIP:
                $player->sendTip($content);
                break;
            case ifPlugin::SENDTITLE:
                $player->addTitle($content, "", 20, 100, 20);
                break;
            case ifPlugin::BROADCASTMESSAGE:
                $this->getServer()->broadcastMessage($content);
                break;
            case ifPlugin::SENDMESSAGE_TO_OP:
            	$players = $player->getServer()->getOnlinePlayers();
            	foreach ($players as $op) {
            		if($op->isOp()){
            			$op->sendMessage($content);
            		}
            	}
            case ifPlugin::SENDVOICEMESSAGE:
		        $text = new TranslationContainer($content);
		        $player->sendMessage($text);
		        break;
            case ifPlugin::COMMAND:
                $this->getServer()->dispatchCommand($player, $content);
                break;
            case ifPlugin::COMMAND_CONSOLE:
                $this->getServer()->dispatchCommand(new ConsoleCommandSender, $content);
                break;
            case ifPlugin::DELAYED_COMMAND:
                if(!preg_match("/([0-9]+),(.+)/", $content, $matches)){
                    $player->sendMessage("§c[遅れてコマンド実行] 書き方が正しくありません");
                    break;
                }
                ifManager::getOwner()->getScheduler()->scheduleDelayedTask(new DelayedCommandTask($player, $matches[2]), (int)$matches[1]*20);
                break;
            case ifPlugin::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 ifPlugin::MOTION:
                $pos = explode(",", $content);
                if(!isset($pos[1]))$pos[1] = 0;
                if(!isset($pos[2]))$pos[2] = 0;
                $player->setMotion(new Vector3((int)$pos[0], (int)$pos[1], (int)$pos[2]));
                break;
            case ifPlugin::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((int)$ids[0], (int)$ids[1], (int)$ids[2]));
                    break;
                }
                $player->getInventory()->addItem(Item::get((int)$ids[0], (int)$ids[1], (int)$ids[2])->setCustomName($ids[3]));
                break;
            case ifPlugin::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);
                    break;
                }
                $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 ifPlugin::SET_IMMOBILE:
            	$player->setImmobile();
            	break;
            case ifPlugin::UNSET_IMMOBILE:
            	$player->setImmobile(false);
            	break;
            case ifPlugin::ADD_ENCHANTMENT:
                $args = explode(",", $content);
                if(!isset($args[1]) or (int)$args[1] <= 0)$args[1] = 1;
	            if(is_numeric($args[0])){
		            $enchantment = Enchantment::getEnchantment((int)$args[0]);
		        }else{
		            $enchantment = Enchantment::getEnchantmentByName($args[0]);
		        }
		        if(!($enchantment instanceof Enchantment)){
		            $sender->sendMessage("エンチャントが見つかりません");
		            break;
		        }
		        $item = $player->getInventory()->getItemInHand();
		        $item->addEnchantment(new EnchantmentInstance($enchantment, $args[1]));
       			$player->getInventory()->setItemInHand($item);
            	break;
            case ifPlugin::ADD_EFFECT:
                $args = explode(",", $content);
                if(!isset($args[1]) or (int)$args[1] <= 0)$args[1] = 1;
                if(!isset($args[2]) or (int)$args[2] <= 0)$args[2] = 30;
        		$effect = Effect::getEffectByName($args[0]);
		        if($effect === null){
		            $effect = Effect::getEffect((int)$args[0]);
		        }
		        if($effect === null){
		            $sender->sendMessage("エフェクトが見つかりません");
		            break;
		        }
		        $power = (int)$args[1];
		        $time = (int)$args[2] * 20;
				$effect = new EffectInstance($effect, $time, $power, true);
            	$player->addEffect($effect);
            	break;
            case ifPlugin::SET_NAMETAG:
            	$player->setNametag($content);
            	$player->setDisplayName($content);
            	break;
            case ifPlugin::SET_SLEEPING:
                $pos = explode(",", $content);
                if(!isset($pos[1]))$pos[1] = 0;
                if(!isset($pos[2]))$pos[2] = 0;
		    	$pos = new Vector3((int)$pos[0], (int)$pos[1], (int)$pos[2]);
		    	$player->sleepOn($pos);
            	break;
            case ifPlugin::SET_SITTING:
                $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;
		        $pk = new AddEntityPacket();
		        $pk->entityRuntimeId = Entity::$entityCount++;
		        $pk->type = 84;
		        $pk->position = new Position((int)$pos[0], (int)$pos[1], (int)$pos[2], $pos[3]);
		          $link = new EntityLink();
				  $link->riddenId = $pk->entityRuntimeId;
				  $link->riderId = $player->getId();
				  $link->type = 1;
		        $pk->links = [$link];
		        $pk->metadata = [
					Entity::DATA_FLAGS => [Entity::DATA_TYPE_LONG, 1 << Entity::DATA_FLAG_INVISIBLE]
				];
		        $player->dataPacket($pk);
		        break;
            case ifPlugin::SET_GAMEMODE:
            	$gamemode = Server::getGamemodeFromString($content);
            	if($gamemode === -1){
            		$player->sendMessage("ゲームモードが見つかりません");
            		break;
            	}
            	$player->setGamemode($gamemode);
            	break;
            case ifPlugin::SET_HEALTH:
            	$health = (int)$content;
            	if($health <= 0)$health = 1;
            	$player->setHealth($health);
            	break;
            case ifPlugin::SET_MAXHEALTH:
            	$health = (int)$content;
            	if($health <= 0)$health = 1;
            	$player->setMaxHealth($health);
            	break;
		    case ifPlugin::ATTACK:
				$data = new EntityDamageEvent($player, EntityDamageEvent::CAUSE_ENTITY_ATTACK, (int)$content);
				$player->attack($data);
				break;
			case ifPlugin::KICK:
		    	$player->kick($content);
		    	break;
        }
    }

    public function executeIfMatchCondition($player, $datas1, $datas2, $datas3){
        $stat = "2";
        foreach($datas1 as $datas){
            $result = $this->checkMatchCondition($player, $datas["id"], $datas["content"]);
            if($result === self::NOT_FOUND){
                $player->sendMessage("§cエラーが発生しました(id: ".$datas["id"]."が見つかりません)");
                return false;
            }elseif($result === self::NOT_MATCHED){
                $stat = "3";
            }
        }
        foreach (${"datas".$stat} as $datas) {
            $this->execute($player, $datas["id"], $datas["content"]);
        }
        return true;
    }
}<?php
namespace aieuo\ip;

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;

use aieuo\ip\commands\ifCommand;
use aieuo\ip\manager\ifManager;
use aieuo\ip\manager\BlockManager;
use aieuo\ip\manager\CommandManager;
use aieuo\ip\manager\EventManager;
use aieuo\ip\utils\Messages;
use aieuo\ip\form\Form;
use aieuo\ip\economy\EconomyLoader;
use aieuo\ip\economy\EconomyAPILoader;
use aieuo\ip\economy\MoneySystemLoader;
use aieuo\ip\economy\PocketMoneyLoader;
use aieuo\ip\ifAPI;
use aieuo\ip\task\SaveTask;

class ifPlugin extends PluginBase implements Listener{

    const IF_TAKEMONEY = 0;
    const IF_HAVEINGITEM = 1;
    const IF_EXISTITEM = 2;
    const IF_IS_SNEAKING = 3;
    const IF_OVERMONEY = 4;
    const IF_REMOVEITEM = 5;
    const IF_GAMEMODE = 6;
    const IF_NO_CHECK = 7;
    const IF_COMPARISON = 8;
    const IF_IS_OP = 9;
    const IF_IS_FLYING = 10;
    const IF_IN_AREA = 11;
    const IF_RANDOM_NUMBER = 12;

    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;
    const SET_IMMOBILE = 109;
    const UNSET_IMMOBILE = 110;
    const SET_HEALTH = 111;
    const SET_MAXHEALTH = 112;
    const SET_GAMEMODE = 113;
    const SET_NAMETAG = 114;
    const ADD_ENCHANTMENT = 115;
    const ADD_EFFECT = 116;
    const EVENT_CANCELL = 117;
    const SENDMESSAGE_TO_OP = 118;
    const SET_SLEEPING = 119;
    const SET_SITTING = 120;
    const ATTACK = 121;
    const KICK = 122;
    const SENDVOICEMESSAGE = 123;
    const SENDTITLE = 124;
    const MOTION = 125;
    const DELAYED_COMMAND = 126;

    public function onEnable(){
        $this->getServer()->getPluginManager()->registerEvents(new EventListener($this),$this);

        $this->getServer()->getCommandMap()->register("ifPlugin", new ifCommand($this));

        Form::registerFormIds();

        if(!file_exists($this->getDataFolder())) @mkdir($this->getDataFolder(), 0721, true);
        $this->config = new Config($this->getDataFolder()."config.yml", Config::YAML, [
            "wait" => 0,
            "save_time" => 10*20*60
        ]);
        $this->wait = $this->config->get("wait");

        $this->loadEconomySystemPlugin();

        $this->command = new CommandManager($this);
        $this->block = new BlockManager($this);
        $this->event = new EventManager($this);

        $this->api = new ifAPI();

        $savetime = (int)$this->config->get("save_time", 10*20*60);
        $savetask = new SaveTask($this);
        $this->getScheduler()->scheduleRepeatingTask($savetask, (int)$savetime);
    }

    public function getBlockManager(){
        return $this->block;
    }

    public function getCommandManager(){
        return $this->command;
    }

    public function getEventManager(){
        return $this->event;
    }

    public function getEcomony(){
        return $this->economy;
    }

    public function getAPI(){
        return $this->api;
    }

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

    public function loadEconomySystemPlugin(){
        if(($plugin = $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")) !== null){
            $this->economy = new EconomyAPILoader($plugin);
            $this->getServer()->getLogger()->info("[if] EconomyAPIを見つけました");
        }elseif(($plugin = $this->getServer()->getPluginManager()->getPlugin("MoneySystem")) !== null){
            $this->economy = new MoneySystemLoader($plugin);
            $this->getServer()->getLogger()->info("[if] MoneySystemを見つけました");
        }elseif(($plugin = $this->getServer()->getPluginManager()->getPlugin("PocketMoney")) !== null){
            $this->economy = new PocketMoneyLoader($plugin);
            $this->getServer()->getLogger()->info("[if] PocketMoneyを見つけました");
        }else{
            $this->economy = new EconomyLoader();
            $this->getServer()->getLogger()->warning("[if] 経済システムプラグインが見つかりませんでした");
        }
    }
}<?php

namespace aieuo\ip\manager;

class BlockManager extends ifManager{

	public function __construct($owner){
		parent::__construct($owner ,"blocks");
		if(!file_exists($this->getDataFolder()."blocks.yml")){
	        if(file_exists($this->getDataFolder()."if.db")) {
	            $db = new \SQLite3($this->getDataFolder()."if.db", SQLITE3_OPEN_READWRITE);
	        	$this->moveDB($db);
	        }
	    }
	}

	public function moveDB($db){
		$res = $db->query("SELECT * FROM list");
		while($row = $res->fetchArray()) {
			$data = [
				"if" => [
					["id" => $row["if"], "content" => $row["if_content"]]
				],
				"match" => [
					["id" => $row["type1"]+100, "content" => $row["type1_content"]]
				],
				"else" => [
					["id" => $row["type2"]+100, "content" => $row["type2_content"]]
				]
			];
			$this->set($row["pos"], $data);
		}
	}

    public function getPosition($block){
        return $block->x.",".$block->y.",".$block->z.",".$block->level->getFolderName();
    }

    public function set($key, $data = []){
        if(!isset($datas["if"]))$datas["if"] = [];
        if(!isset($datas["match"]))$datas["match"] = [];
        if(!isset($datas["else"]))$datas["else"] = [];
        parent::set($key, $data);
    }
}<?php

namespace aieuo\ip\manager;

use pocketmine\command\Command;
use pocketmine\command\PluginCommand;

class CommandManager extends ifManager{

    private $command_list = [];

	public function __construct($owner){
        parent::__construct($owner, "commands");
        $this->registerCommands();
	}

    public function registerCommands(){
        foreach($this->getAll() as $command => $value){
    		if($this->isSubcommand($command))$command = $this->getOriginalCommand($command);
            if(!$this->exists($command)){
                $this->register($command, $value["permission"], $value["description"]);
            }
        }
    }

    public function register($command, $permission = "default", $description = "ifPluginで追加したコマンドです"){
    	if($this->isSubcommand($command))$command = $this->getOriginalCommand($command);
        if(!$this->exists($command)){
            $newCommand = new PluginCommand($command, $this->getOwner());
            $newCommand->setDescription($description);
            $newCommand->setPermission($permission);
            $this->getServer()->getCommandMap()->register("ifPlugin", $newCommand);
            var_dump($command);
            $this->command_list[$command] = $newCommand;
            return true;
        }
        return false;
    }

    public function unregister($command){
        if($this->isSubcommand($command))$command = $this->getOriginalCommand($command);
        if($this->exists($command) or !isset($this->command_list[$command]))return false;
        $this->getServer()->getCommandMap()->unregister($this->command_list[$command]);
        unset($this->command_list[$command]);
    }

    public function exists($command){
        $exist = $this->getServer()->getPluginCommand($command);
        if($exist === null)return false;
        return true;
    }

    public function isSubcommand($command){
    	$subcommand = false;
    	if(strpos($command, " ") !== false)$subcommand = true;
    	return $subcommand;
    }

    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 setOptions($command, $description, $permission){
        $this->tmp[$command] = [$description, $permission];
    }

    public function set($key, $data = []){
        if(isset($this->tmp[$key])){
            $data["description"] = $this->tmp[$key][0];
            $data["permission"] = $this->tmp[$key][1];
            unset($this->tmp[$key]);
        }
        if(!isset($datas["if"]))$datas["if"] = [];
        if(!isset($datas["match"]))$datas["match"] = [];
        if(!isset($datas["else"]))$datas["else"] = [];
        parent::set($key, $data);
    }

    public function add($key, $type, $id, $content){
        $datas = [];
        if($this->isAdded($key))$datas = $this->get($key);
        if(isset($this->tmp[$key])){
            $datas["description"] = $this->tmp[$key][0];
            $datas["permission"] = $this->tmp[$key][1];
            unset($this->tmp[$key]);
        }
        if(!isset($datas["if"]))$datas["if"] = [];
        if(!isset($datas["match"]))$datas["match"] = [];
        if(!isset($datas["else"]))$datas["else"] = [];
        if(!isset($datas["description"]))$datas["description"] = "ifPluginで追加したコマンドです";
        if(!isset($datas["permission"]))$datas["permission"] = "op";
        $datas[$type][] = [
            "id" => $id,
            "content" => $content
        ];
        $this->register($key, $datas["description"], $datas["permission"]);
        parent::set($key, $datas);
    }

    public function remove($key){
        $this->unregister($key);
        parent::remove($key);
    }
}<?php

namespace aieuo\ip\manager;

use pocketmine\item\Item;
use pocketmine\level\Position;
use pocketmine\Player;
use pocketmine\event\Cancellable;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerChatEvent;
use pocketmine\event\player\PlayerCommandPreprocessEvent;
use pocketmine\event\player\PlayerInteractEvent;
use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\event\player\PlayerQuitEvent;
use pocketmine\event\block\BlockBreakEvent;
use pocketmine\event\block\BlockPlaceEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityDamageByEntityEvent;

use aieuo\ip\ifPlugin;

class EventManager extends ifManager{

	public function __construct($owner){
        parent::__construct($owner, "events");
    }

    public function setOptions($eventname, $event = null){
        $this->tmp = [$eventname, $event];
    }

    public function get($key){
        $datass = $this->getByEvent($this->tmp[0]);
        if(!isset($datass[$key]))return [];
        $datas = $datass[$key];
        $change = false;
        foreach ($datas as $type => $data) {
            if(!is_array($data) or count($data) == 0)continue;
            if(!isset($data[0])){
                $datass[$key][$type] = [];
                foreach ($data as $key => $value) {
                    $datass[$key][$type][] = [
                        "id" => str_replace("id", "", $key),
                        "content" => $value
                    ];
                }
                $change = true;
            }
        }
        if(!isset($datas["if"]))$datas["if"] = [];
        if(!isset($datas["match"]))$datas["match"] = [];
        if(!isset($datas["else"]))$datas["else"] = [];
        if($change){
            $this->set($this->tmp[0], $datass);
        }
        return $datas;
    }

    public function getCount($event){
        $datas = $this->getByEvent($this->tmp[0]);
        return count($datas);
    }

    public function add_empty(){
        $datas = $this->getByEvent($this->tmp[0]);
        $data = [
            "if" => [],
            "match" => [],
            "else" => []
        ];
        $datas[] = $data;
        $this->set($this->tmp[0], $datas);
        return count($datas) -1;
    }

    public function add($key, $type, $id, $content){
        $datas = $this->getByEvent($this->tmp[0]);
        $datas[$key][$type][] = [
            "id" => $id,
            "content" => $content
        ];
        $this->set($this->tmp[0], $datas);
    }

    public function getByEvent($event){
        $datas = [];
        if(isset(($all = $this->getAll())[$event]))$datas = $all[$event];
        return $datas;
    }

    public function del($key, $type, $num){
        $datas = $this->getByEvent($this->tmp[0]);
        if(!isset($datas[$key]))return false;
        unset($datas[$key][$type][$num]);
        $datas[$key][$type] = array_merge($datas[$key][$type]);
        $this->set($this->tmp[0], $datas);
        return true;
    }

    public function remove($key){
        $datas = $this->getByEvent($this->tmp[0]);
        if(!isset($datas[$key]))return false;
        unset($datas[$key]);
        $datas = array_merge($datas);
        $this->set($this->tmp[0], $datas);
        return true;
    }

    public function replaceVariable($event, $eventname, $mes){
        switch ($eventname) {
            case 'PlayerInteractEvent':
            case 'PlayerChatEvent':
            case 'PlayerCommandPreprocessEvent':
            case 'PlayerJoinEvent':
            case 'PlayerQuitEvent':
            case 'PlayerToggleFlightEvent':
            case 'BlockBreakEvent':
            case 'BlockPlaceEvent':
                $player = $event->getPlayer();
                break;
            case 'EntityDamageEvent':
            case 'EntityDeathEvent':
                $player = $event->getEntity();
                if(!$player instanceof Player)return $mes;
                break;
        }
        $variables["{playername}"] = $player->getName();
        $variables["{nametag}"] = $player->getDisplayName();
        $variables["{playerpos}"] = $player->x." ".$player->y." ".$player->z." ".$player->level->getFolderName();
        $variables["{player_x}"] = (int)$player->x;
        $variables["{player_y}"] = (int)$player->y;
        $variables["{player_z}"] = (int)$player->z;
        $variables["{player_level}"] = $player->level->getFolderName();
        if(
            $eventname == "PlayerInteractEvent"
            or $eventname == "BlockBreakEvent"
            or $eventname == "BlockPlaceEvent"
        ){
            $block = $event->getBlock();
            $variables["{block}"] = $block->__toString();
            $variables["{blockname}"] = $block->getName();
            $variables["{blockid}"] = $block->getId();
            $variables["{blockdamage}"] = $block->getDamage();
            $variables["{blockids}"] = $block->getId().":".$block->getDamage();
            $variables["{blockpos}"] = $block->x." ".$block->y." ".$block->z." ".$block->level->getFolderName();
            $variables["{block_level}"] = $block->level->getFolderName();
        }
        if(
            $eventname == "PlayerChatEvent"
            or $eventname == "PlayerCommandPreprocessEvent"
        ){
            $variables["{mes}"] = $event->getMessage();
        }
        if($eventname == "EntityDamageEvent"){
            $entity = $event->getEntity();
            if($event instanceof EntityDamageByEntityEvent){
                $damager = $event->getDamager();
                if($damager instanceof Player){
                    $datas["{attacker}"] = $damager->getName();
                }
            }
        }
        foreach ($variables as $variable => $value) {
            $mes = str_replace($variable, $value, $mes);
        }
        return $mes;
    }

    public function execute($player, $type, $content){
        switch ($type) {
            case ifPlugin::EVENT_CANCELL:
                $event = $this->tmp[1];
                if($event instanceof Cancellable){
                    $event->setCancelled();
                }
                return;
        }
        parent::execute($player, $type, $content);
    }

    public function executeIfMatchCondition($player, $datas1, $datas2, $datas3){
        $stat = "2";
        foreach($datas1 as $datas){
            $result = $this->checkMatchCondition($player, $datas["id"], $this->replaceVariable($this->tmp[1], $this->tmp[0], $datas["content"]));
            if($result === self::NOT_FOUND){
                $player->sendMessage("§cエラーが発生しました(id: ".$datas["id"]."が見つかりません)");
                return false;
            }elseif($result === self::NOT_MATCHED){
                $stat = "3";
            }
        }
        foreach (${"datas".$stat} as $datas) {
            $this->execute($player, $datas["id"], $this->replaceVariable($this->tmp[1], $this->tmp[0], $datas["content"]));
        }
        return true;
    }
}<?php

namespace aieuo\ip\manager;

use pocketmine\utils\Config;

use aieuo\ip\ifPlugin;
use aieuo\ip\ifAPI;

class ifManager extends ifAPI{

	private static $owner;
	private $config;

	public function __construct($owner, $type){
		self::$owner = $owner;
        $this->config = new Config($this->getDataFolder() . $type. ".yml", Config::YAML, []);
	}

	public static function getOwner(){
		return self::$owner;
	}

	public function getServer(){
		return self::getOwner()->getServer();
	}

	public function getDataFolder(){
		return self::getOwner()->getDataFolder();
	}

    public function getConfig(){
        return $this->config;
    }

    public function isAdded($key){
    	return $this->config->exists($key);
    }

    public function get($key){
        if(!$this->isAdded($key))return false;
        $datas = $this->config->get($key);
        $change = false;
        foreach ($datas as $type => $data) {
            if(!is_array($data) or count($data) == 0)continue;
            if(!isset($data[0])){
                $datas[$type] = [];
                foreach ($data as $key => $value) {
                    $datas[$type][] = [
                        "id" => str_replace("id", "", $key),
                        "content" => $value
                    ];
                }
                $change = true;
            }
        }
        if(!isset($datas["if"]))$datas["if"] = [];
        if(!isset($datas["match"]))$datas["match"] = [];
        if(!isset($datas["else"]))$datas["else"] = [];
        if($change){
            $this->set($key, $datas);
        }
        return $datas;
    }

    public function getAll(){
    	return $this->config->getAll();
    }

    public function set($key, $datas = []){
    	$this->config->set($key, $datas);
    }

    public function del($key, $type, $num){
        if(!$this->isAdded($key))return false;
        $datas = $this->get($key);
        unset($datas[$type][$num]);
        $datas[$type] = array_merge($datas[$type]);
        $this->set($key, $datas);
        return true;
    }

    public function remove($key){
    	$this->config->remove($key);
    }

	public function save(){
		$this->config->save();
	}

    public function add($key, $type, $id, $content){
        $datas = [];
        if($this->isAdded($key))$datas = $this->get($key);
        if(!isset($datas["if"]))$datas["if"] = [];
        if(!isset($datas["match"]))$datas["match"] = [];
        if(!isset($datas["else"]))$datas["else"] = [];
        $datas[$type][] = [
            "id" => $id,
            "content" => $content
        ];
        $this->config->set($key, $datas);
    }
}<?php

namespace aieuo\ip;

class Session {

	const BLOCK = 0;
	const COMMAND = 1;
	const EVENT = 2;

	private $valid = false;
	private $if_type = self::BLOCK;
	private $datas = [];

	public function isValid(){
		return $this->valid;
	}

	public function setValid($valid = true, $del = true){
		$this->valid = $valid;
		if(!$valid and $del)$this->removeAllData();
	}

	public function getIfType(){
		return $this->if_type;
	}

	public function setIfType($type){
		if($type !== self::BLOCK and $type !== self::COMMAND and $type !== self::EVENT)$type = self::BLOCK;
		$this->if_type = $type;
	}

	public function getData($id){
		if(!isset($this->datas[$id]))return "";
		return $this->datas[$id];
	}

	public function setData($id, $data){
		$this->datas[$id] = $data;
	}

	public function removeData($id){
		unset($this->datas[$id]);
	}

	public function removeAllData(){
		$this->datas = [];
	}
}<?php
namespace aieuo\ip\task;

use pocketmine\scheduler\Task;

class DelayedCommandTask extends Task {
	public function __construct($player, $command) {
        $this->player = $player;
        $this->command = $command;
	}

	public function onRun(int $currentTick) {
		$this->player->getServer()->dispatchCommand($this->player, $this->command);
	}
}<?php
namespace aieuo\ip\task;

use pocketmine\scheduler\Task;

class SaveTask extends Task {
	public function __construct($owner) {
        $this->owner = $owner;
	}

	public function onRun(int $currentTick) {
        $this->owner->getBlockManager()->save();
        $this->owner->getCommandManager()->save();
        $this->owner->getEventManager()->save();
	}
}<?php

namespace aieuo\ip\utils;

use aieuo\ip\ifPlugin;

class Messages {

    public static function createMessage($ifs, $matchs, $elses){
    	$mes = "もし\n";
        foreach($ifs as $if){
            $mes .= self::getMessage($if["id"], $if["content"]).",\n";
        }
        $mes .= "\nなら\n";
        foreach ($matchs as $match) {
            $mes .= self::getMessage($match["id"], $match["content"]).",\n";
        }
        $mes .= "\n条件に合わなかったら\n";
        foreach ($elses as $else) {
            $mes .= self::getMessage($else["id"], $else["content"]).",\n";
        }
        return $mes;
    }

	public static function getMessage($num, $value = "", $event = false){
        switch ($num){
            case ifPlugin::IF_NO_CHECK:
                $message = "何も確認しない";
                break;
            case ifPlugin::IF_TAKEMONEY:
                $message = "$".$value."払える";
                break;
            case ifPlugin::IF_OVERMONEY:
                $message = "$".$value."より所持金が多い";
                break;
            case ifPlugin::IF_HAVEINGITEM:
                $message = "idが".$value."のアイテムを手に持ってる";
                break;
            case ifPlugin::IF_EXISTITEM:
                $message = "idが".$value."アイテムがインベントリに入っている";
                break;
            case ifPlugin::IF_REMOVEITEM:
                $message = "インベントリから(".$value.")を削除できる";
                break;
            case ifPlugin::IF_IS_OP:
                $message = "プレイヤーがop";
                break;
            case ifPlugin::IF_IS_SNEAKING:
                $message = "プレイヤーがスニークしている";
                break;
            case ifPlugin::IF_IS_FLYING:
                $message = "プレイヤーが飛んでいる";
                break;
            case ifPlugin::IF_GAMEMODE:
                $message = "ゲームモードが(".$value.")";
                break;
            case ifPlugin::IF_IN_AREA:
                preg_match("/([xyz]\(-?[0-9\.]+,-?[0-9\.]+\))+/", $value, $matches);
                array_shift($matches);
                $mes = [];
                foreach ($matches as $match) {
                    if(!preg_match("/([xyz])\((-?[0-9\.]+),-?([0-9\.]+)\)/", $match, $result))continue;
                    $min = min((float)$result[2], (float)$result[3]);
                    $max = max((float)$result[2], (float)$result[3]);
                    $mes[] = $result[1]."座標が".$min."以上、".$max."以下";
                }
                if(count($mes) == 0){
                    $message = "§c[指定した範囲内にいたら] 正しく入力できていません§f";
                }else{
                    $message = "プレイヤーが".implode(",", $mes)."にいる";
                }
                break;
            case ifPlugin::IF_RANDOM_NUMBER:
                if(!preg_match("/(-?[0-9]+),(-?[0-9]+);(-?[0-9]+)/", $value, $matches)){
                    $message = "§c[乱数が指定したものだったら] 正しく入力できていません§f";
                }else{
                    $min = min((int)$matches[1], (int)$matches[2]);
                    $max = max((int)$matches[1], (int)$matches[2]);
                    $message = $min."～".$max."の範囲の乱数が".$matches[3];
                }
                break;
            case ifPlugin::IF_COMPARISON:
                if(!preg_match("/([^!>=<]+)([!>=<]{1,2})([^!>=<]+)/", $value, $matches)){
                    $message = "§c[二つの値を比較する] 正しく入力できていません§f";
                }else{
                    $operator = $matches[2];
                    $val1 = trim(rtrim($matches[1]));
                    $val2 = trim(rtrim($matches[3]));
                    switch ($operator){
                        case "=":
                        case "==":
                            $message = $val1."と".$val2."が等しい";
                            break;
                        case "!=":
                        case "=!":
                            $message = $val1."と".$val2."が等しくない";
                            break;
                        case ">":
                            $message = $val1."が".$val2."より大きい";
                            break;
                        case "<":
                            $message = $val1."が".$val2."より小さい";
                            break;
                        case ">=":
                        case "=>":
                            $message = $val1."が".$val2."以上";
                            break;
                        case "<=":
                        case "=<":
                            $message = $val1."が".$val2."以下";
                            break;
                        case "><":
                            $message = $val1."の中に".$val2."が含まれている";
                            break;
                        case "<>":
                            $message = $val1."の中に".$val2."が含まれていない";
                            break;
                        default:
                            $message = "§cその組み合わせは使用できません 次の中から選んでください[==|>|>=|<|<=|!=]§r";
                            break;
                    }
                }
                break;
            case ifPlugin::DO_NOTHING:
                $message = "何もしない";
                break;
            case ifPlugin::SENDMESSAGE:
                $message = "チャット欄に(".$value.")を送信する";
                break;
            case ifPlugin::SENDTIP:
                $message = "tip欄に(".$value.")を送信する";
                break;
            case ifPlugin::SENDTITLE:
                $message = "タイトル欄に(".$value.")を送信する";
                break;
            case ifPlugin::BROADCASTMESSAGE:
                $message = "全員のチャット欄に(".$value.")を送信する";
                break;
            case ifPlugin::SENDMESSAGE_TO_OP:
                $message = "opだけに(".$value.")を送信する";
                break;
            case ifPlugin::SENDVOICEMESSAGE:
                $message = "音声付きのメッセージ(".$value.")を送信する";
                break;
            case ifPlugin::COMMAND:
                $message = "コマンド(/".$value.")を実行する";
                break;
            case ifPlugin::COMMAND_CONSOLE:
                $message = "コンソールからコマンド(/".$value.")を実行する";
                break;
            case ifPlugin::DELAYED_COMMAND:
                if(!preg_match("/([0-9]+),(.+)/", $value, $matches)){
                    $player->sendMessage("§c[遅れてコマンド実行] 書き方が正しくありません§f");
                    break;
                }
                $message = $matches[1]."秒後に/".$matches[2]."を実行する";
                break;
            case ifPlugin::TELEPORT:
                $message = "(".$value.")にテレポートする";
                break;
            case ifPlugin::TELEPORT:
                $pos = explode(",", $value);
                if(!isset($pos[1]))$pos[1] = 0;
                if(!isset($pos[2]))$pos[2] = 0;
                $message = "(".implode(",", $pos).")にテレポートする";
                break;
            case ifPlugin::MOTION:
                $pos = explode(",", $value);
                if(!isset($pos[1]))$pos[1] = 0;
                if(!isset($pos[2]))$pos[2] = 0;
                $message = "(".implode(",", $pos).")ブロック分動かす";
                break;
            case ifPlugin::ADD_ITEM:
                $ids = explode(":", $value);
                if(!isset($ids[1]))$ids[1] = 0;
                if(!isset($ids[2]))$ids[2] = 1;
                if(!isset($ids[3]))$ids[3] = "";
                $message = "インベントリに($ids[0]:$ids[1] x$ids[2], $ids[3])を追加する";
                break;
            case ifPlugin::REMOVE_ITEM:
                $ids = explode(":", $value);
                if(!isset($ids[1]))$ids[1] == 0;
                if(!isset($ids[2]))$ids[2] == "全て";
                $message = "インベントリから($ids[0]:$ids[1] x$ids[2])を削除する";
                break;
            case ifPlugin::SET_IMMOBILE:
                $message = "プレイヤーを動けなくする";
                break;
            case ifPlugin::UNSET_IMMOBILE:
                $message = "プレイヤーを動けるようにする";
                break;
            case ifPlugin::ADD_ENCHANTMENT:
                $args = explode(",", $value);
                if(!isset($args[1]) or (int)$args[1] <= 0)$args[1] = 1;
                $message = "手に持ってるアイテムに(id:".$args[0].",レベル:".$args[1].")のエンチャントを追加する";
                break;
            case ifPlugin::ADD_EFFECT:
                $args = explode(",", $value);
                if(!isset($args[1]) or (int)$args[1] <= 0)$args[1] = 1;
                if(!isset($args[2]) or (int)$args[2] <= 0)$args[2] = 30;
                $time = (int)$args[2] * 20;
                $message = "プレイヤーに(id:".$args[0].",強さ:".$args[1].")のエフェクトを".$time."秒間与える";
                break;
            case ifPlugin::SET_NAMETAG:
                $message = "表示している名前を(".$value.")に変更する";
                break;
            case ifPlugin::SET_SLEEPING:
                $pos = explode(",", $value);
                if(!isset($pos[1]))$pos[1] = 0;
                if(!isset($pos[2]))$pos[2] = 0;
                $message = "(".implode(",", $pos).")で寝かせる";
                break;
            case ifPlugin::SET_SITTING:
                $pos = explode(",", $value);
                if(!isset($pos[1]))$pos[1] = 0;
                if(!isset($pos[2]))$pos[2] = 0;
                $message = "(".implode(",", $pos).")で座らせる";
                break;
            case ifPlugin::SET_GAMEMODE:
                $message = "ゲームモードを(".$value.")に設定する";
                break;
            case ifPlugin::SET_HEALTH:
                $message = "体力を(".$value.")に設定する";
                break;
            case ifPlugin::SET_MAXHEALTH:
                $message = "最大体力を(".$value.")に設定する";
                break;
            case ifPlugin::ATTACK:
                $message = "(".$value.")ダメージ与える";
                break;
            case ifPlugin::KICK:
                $message = "(".$value.")でキックする";
                break;
            case ifPlugin::EVENT_CANCELL:
                $message = "イベントをキャンセルする";
                break;
            default:
            	$message = "";
            	break;
        }
        return $message;
    }

    public static function getFormMessage($num){
        switch ($num){
            case ifPlugin::IF_TAKEMONEY:
                $message = "もし\n§lお金を";
                $next = "§l払えるなら\n\n";
                $placeholder = "金額を入力してください";
                break;
            case ifPlugin::IF_OVERMONEY:
                $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_REMOVEITEM:
                $message = "もし\n§lインベントリからidが\n§r(id:meta:数 のように黄色の羊毛が2個なら35:4:2 , 35:4だけなら持ってる数すべて)";
                $next = "§lのアイテムを削除できるなら\n\n";
                $placeholder = "上のカッコ内のようにidを入力してください";
                break;
            case ifPlugin::IF_GAMEMODE:
                $message = "もし\n§lゲームモードが\n§r(0,1,2,3,s,c,a,v)";
                $next = "§lなら\n\n";
                $placeholder = "カッコ内から一つ選んで入力してください";
                break;
            case ifPlugin::IF_IN_AREA:
                $message = "もし\n§lプレイヤーが\n§r(書き方: <x|y|z>(<最小の座標>,<最大の座標>)\nx座標が0~10の範囲なら:  x(0,10)\nx,y,z座標が0~5の範囲なら:  x(0,5)y(0,5)z(0,5))";
                $next = "§lの範囲にいたら\n\n";
                $placeholder = "カッコ内のように入力してください";
                break;
            case ifPlugin::IF_RANDOM_NUMBER:
                $message = "もし\n§l乱数\n§r(最小値,最大値;確認する数)\n1~10の範囲の乱数が2の時に処理するなら:  1,10;2";
                $next = "§lなら\n\n";
                $placeholder = "カッコ内のように入力してください";
            case ifPlugin::IF_COMPARISON:
                $message = "もし\n§l二つの値を比較して条件を満たしている\n§r(値1 [== | > | < | >= | <= | !=])\nイベントのブロックを触ったときにブロックのidが1か調べるなら:  {blockid}==1";
                $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::SENDTITLE:
                $message = "§ltitle欄に";
                $next = "§lを送信する\n\n";
                $placeholder = "送信するメッセージを入力してください";
                break;
            case ifPlugin::BROADCASTMESSAGE:
                $message = "§l全員のチャット欄に";
                $next = "§lを送信する\n\n";
                $placeholder = "送信するメッセージを入力してください";
                break;
            case ifPlugin::SENDMESSAGE_TO_OP:
                $message = "§lopだけに";
                $next = "§lを送信する\n\n";
                $placeholder = "送信するメッセージを入力してください";
                break;
            case ifPlugin::SENDVOICEMESSAGE:
                $message = "§lチャット欄に音声付きの";
                $next = "§lを送信する\n\n";
                $placeholder = "送信するメッセージを入力してください";
                break;
            case ifPlugin::COMMAND:
                $message = "§lコマンド";
                $next = "§lを実行する\n\n";
                $placeholder = "コマンドを最初の/を外して入力してください";
                break;
            case ifPlugin::COMMAND_CONSOLE:
                $message = "§lコンソールからコマンド";
                $next = "§lを実行する\n\n";
                $placeholder = "コマンドを最初の/を外して入力してください";
                break;
            case ifPlugin::DELAYED_COMMAND:
                $message = "§l?秒後にコマンド\n§r(秒数, コマンド)\n10秒後に /aieuo を実行するなら: 10,aieuo";
                $next = "§lを実行する\n\n";
                $placeholder = "カッコ内のように入力してください";
                break;
            case ifPlugin::TELEPORT:
                $message = "(0,0,0,world  のように,で区切って)";
                $next = "§lにテレポートする\n\n";
                $placeholder = "上のカッコ内のように座標を入力してください";
                break;
            case ifPlugin::MOTION:
                $message = "(0,1,0  のように,で区切って)";
                $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::ADD_ENCHANTMENT:
                $message = "§lid,レベルが\n§r(,で区切って)";
                $next = "§lのエンチャントを手に持ってるアイテムに追加する\n\n";
                $placeholder = "数値を入力してください";
                break;
            case ifPlugin::ADD_EFFECT:
                $message = "§lid,強さ,時間が\n§r(,で区切って)";
                $next = "§lのエフェクトを与える\n\n";
                $placeholder = "数値を入力してください";
                break;
            case ifPlugin::SET_NAMETAG:
                $message = "§l表示している名前を";
                $next = "§lにする\n\n";
                $placeholder = "かっこの中から一つ選んで入力してください";
                break;
            case ifPlugin::SET_SLEEPING:
                $message = "(0,0,0,world  のように,で区切って)";
                $next = "§lで寝かせる\n\n";
                $placeholder = "上のカッコ内のように座標を入力してください";
                break;
            case ifPlugin::SET_SITTING:
                $message = "(0,0,0,world  のように,で区切って)";
                $next = "§lで座らせる\n\n";
                $placeholder = "上のカッコ内のように座標を入力してください";
                break;
            case ifPlugin::SET_GAMEMODE:
                $message = "§lゲームモードを\n§r(0,1,2,3,s,c,a,v)";
                $next = "§lにする\n\n";
                $placeholder = "かっこの中から一つ選んで入力してください";
                break;
            case ifPlugin::SET_HEALTH:
                $message = "§l体力を\n§r(2でハート一個分)";
                $next = "§lにする\n\n";
                $placeholder = "数値を入力してください";
                break;
            case ifPlugin::SET_MAXHEALTH:
                $message = "§l最大体力を\n§r(2でハート一個分)";
                $next = "§lにする\n\n";
                $placeholder = "数値を入力してください";
                break;
            case ifPlugin::ATTACK:
                $message = "§l\n§r(2でハート一個分)";
                $next = "§lダメージ与える\n\n";
                $placeholder = "数値を入力してください";
                break;
            case ifPlugin::KICK:
                $message = "";
                $next = "§lでキックする\n\n";
                $placeholder = "理由を入力してください";
                break;
        }
        if(isset($message))return [
        	"type" => "input",
            "message" => $message,
            "next" => $next,
            "placeholder" => $placeholder
        ];
        switch ($num){
            case ifPlugin::IF_NO_CHECK:
                $message = "何も確認しない";
                break;
            case ifPlugin::IF_IS_OP:
                $message = "もし\nOPなら";
                break;
            case ifPlugin::IF_IS_SNEAKING:
                $message = "もし\nスニークしているなら";
                break;
            case ifPlugin::IF_IS_SNEAKING:
                $message = "もし\n飛んでいるなら";
                break;
            case ifPlugin::DO_NOTHING:
                $message = "何もしない";
                break;
            case ifPlugin::SET_IMMOBILE:
                $message = "プレイヤーを動けないようにする";
                break;
            case ifPlugin::UNSET_IMMOBILE:
                $message = "プレイヤーを動けるようにする";
                break;
            case ifPlugin::EVENT_CANCELL:
                $message = "イベントをキャンセルする";
                break;
        }
        return [
        	"type" => "label",
            "message" => $message,
            "next" => "\n"
        ];
    }
}VpN�0À­3à×E–7ækm#§$   GBMB