
<?php
echo "PocketMine-MP plugin TheMaze v1.0.0
This file has been generated using DevTools v1.13.0 at Sun, 09 Dec 2018 13:57:33 +0900
----------------
";

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:7:"TheMaze";s:7:"version";s:5:"1.0.0";s:4:"main";s:12:"maze\TheMaze";s:3:"api";s:5:"3.3.4";s:6:"depend";s:0:"";s:11:"description";s:0:"";s:7:"authors";s:0:"";s:7:"website";s:0:"";s:12:"creationDate";i:1544331453;}
   plugin.ymlQ   \Q   m	          src/maze/command/MainCommand.php	  \	  쵪p         src/maze/event/SignEvent.phpG  \G  k         src/maze/event/SignTouch.php  \  %v         src/maze/generator/BaseData.php   \   `      "   src/maze/generator/MazeDriller.phpr  \r  $      $   src/maze/generator/MazeGenerator.phpm  \m  uN      &   src/maze/generator/PositionDecoder.php  \  wq      (   src/maze/generator/ProcessingDriller.phpZ  \Z  OҔ      '   src/maze/generator/ProcessingFiller.php  \  9      !   src/maze/generator/WallFiller.php
  \
  l      $   src/maze/memory/TaskingClipboard.php@   \@   䁸g         src/maze/path/Path.phpu  \u   d         src/maze/task/Timer.php*  \*  Ŵ         src/maze/TheMaze.php  \  r	         src/maze/tmp/Messages.php6  \6  ^8ζ         src/maze/tmp/TmpStation.php  \  r      name: TheMaze
main: maze\TheMaze
api: 3.3.4
version: 1.0.0
author: metowa1227<?php
namespace maze\command;

use pocketmine\command\{
	Command,
	CommandSender
};
use pocketmine\Player;
use maze\tmp\TmpStation;
use maze\generator\MazeGenerator;

class MainCommand extends Command
{
	public function __construct()
	{
        parent::__construct("maze", "Maze command", "/maze <pos1/pos2/generate>");
        $this->setPermission("maze.main");
    }

    public function execute(CommandSender $sender, string $label, array $args) : bool
    {
    	if (!$sender instanceof Player) {
    		$sender->sendMessage("このコマンドはコンソールからは実行できません。");
    		return true;
    	}
    	if (!$sender->isOp()) {
    		$sender->sendMessage("このコマンドを実行する権限がありません。");
    		return true;
    	}
    	if (!isset($args[0])) {
    		$sender->sendMessage($this->getUsage());
    		return true;
    	}

    	// /maze [option]
    	switch ($args[0]) {
    		case "pos1":
    			$x = floor($sender->x);
    			$y = floor($sender->y);
    			$z = floor($sender->z);
    			$level = $sender->getLevel()->getName();
    			TmpStation::registerPos1($sender, $x, $y, $z, $level);
    			$sender->sendMessage("一つ目の地点を設定しました。");
    			return true;
    		case "pos2":
    			if (!TmpStation::isSettedPos1($sender)) {
    				$sender->sendMessage("まず一つ目の地点を設定してください。");
    				return true;
    			}
    			$x = floor($sender->x);
    			$z = floor($sender->z);
    			$level = $sender->getLevel()->getName();
    			$sender->sendMessage(TmpStation::registerPos2($sender, $x, $z, $level));
    			return true;
    		case "generate":
    			if (!TmpStation::isSettedPos2($sender)) {
    				$sender->sendMessage("まず範囲を設定してください。");
    				return true;
    			}
    			if (!MazeGenerator::generateMaze($sender)) {
    				$sender->sendMessage("迷路の生成に失敗しました。");
    				return true;
    			}
    			$sender->sendMessage("迷路を生成しました。");
    			$sender->sendMessage("§aGenerated by metowa1227.");
    			$sender->sendMessage("§bTheMaze 2018");
    			return true;
    		default:
    			$sender->sendMessage($this->getUsage());
    			return true;
    	}
	}
}
<?php
namespace maze\event;

use pocketmine\utils\TextFormat;
use pocketmine\event\{
	Listener,
	block\SignChangeEvent
};
use metowa1227\moneysystem\api\core\API;
use maze\path\Path;

class SignEvent extends Path implements Listener
{
	public function onSignChange(SignChangeEvent $event)
	{
		$player = $event->getPlayer();
		$sign = $this->getSign();
		$block = $event->getBlock();
		$lines = $event->getLines();
		if ($lines[0] === "[TheMaze]") {
			$prize = $lines[1];
			if (!ctype_digit($prize)) {
				$event->setLine(2, TextFormat::RED . "不正な値");
				return;
			}
			$name = $lines[2];
			$comment = $lines[3];
			$vector = $this->convertString($block);
			$sign->set($vector, [
				"Type" => "Start",
				"Prize" => $prize,
				"ID" => $name,
				"X" => $block->x,
				"Y" => $block->y,
				"Z" => $block->z,
				"Level" => $block->getLevel()->getName()
			]);
			$sign->save();
			$event->setLine(0, TextFormat::AQUA . TextFormat::BOLD . TextFormat::ITALIC . "[ THE MAZE ]");
			$event->setLine(1, TextFormat::GREEN . "報酬: " . API::getInstance()->getUnit() . $prize);
			$event->setLine(2, TextFormat::GREEN . "迷路名: " . $name);
			$event->setLine(3, $comment);
			$player->sendPopup(TextFormat::GREEN . "迷路看板を作成しました。");
			$player->sendMessage(TextFormat::YELLOW . "引き続きゴール看板も作成してください。");
		} elseif ($lines[0] === "[MazeGoal]") {
			$vector = $this->convertString($block);
			$id = $lines[2];
			$found = false;
			foreach ($sign->getAll() as $all) {
				if ($all["ID"] === $id) {
					$found = true;
					$prize = $all["Prize"];
					break;
				}
			}
			if (!$found) {
				$event->setLine(2, TextFormat::RED . "そのIDは存在しません。");
				return;
			}
			$sign->set($vector, [
				"Type" => "Goal",
				"ID" => $id
			]);
			$sign->save();
			$event->setLine(0, TextFormat::GREEN . TextFormat::BOLD . TextFormat::ITALIC . "[ MAZE GOAL ]");
			$event->setLine(2, TextFormat::YELLOW . "報酬: " . API::getInstance()->getUnit() . $prize);
		}
	}
}
<?php
namespace maze\event;

use pocketmine\TextFormat;
use pocketmine\event\{
	Listener,
	player\PlayerInteractEvent
};
use pocketmine\block\Block;
use pocketmine\math\Vector3;
use maze\path\Path;
use maze\memory\TaskingClipboard;
use metowa1227\moneysystem\api\core\API;

class SignTouch extends Path implements Listener
{
	public function onTouch(PlayerInteractEvent $event)
	{
		$block = $event->getBlock();
		$vector = $this->convertString($block);
		$sign = $this->getSign();
		if (!$sign->exists($vector)) {
			return;
		}
		$player = $event->getPlayer();
		$data = $sign->get($vector);
		if ($data["Type"] === "Goal") {
			$sign = $data["Prize"];
			$id = $data["ID"];
			foreach ($sign->getAll() as $all) {
				if ($all["ID"] === $id) {
					$startSignVectorX = $all["X"];
					$startSignVectorY = $all["Y"];
					$startSignVectorZ = $all["Z"];
					$startSignLevel = $all["Level"];
					break;
				}
			}
			if (!TaskingClipboard::isRunning($id, $player)) {
				return;
			}
			TaskingClipboard::stopTask($id, $player);
			$time = TaskingClipboard::getTime($id, $player);
			$player->sendMessage(TextFormat::GREEN . "迷路をクリアしました。");
			$api = API::getInstance();
			$api->increase($player, $prize);
			$player->sendMessage(TextFormat::GREEN . "時間: " . $time . " 報酬: " . $api->getUnit() . $prize);
			$teleportVector = new Vector3($startSignVectorX, $startSignVectorY, $startSignVectorZ);
			$player->teleport($teleportVector);
			TaskingClipboard::unregisterTask($id, $player);
		} else {
			if (TaskingClipboard::isRunning($id, $player)) {
				return;
			}
			$vector = new Vector3($data["X"], $data["Y"], $data["Z"]);
			//Stopped development on 2018/12/09
		}
	}
}
<?php
namespace maze\generator;

interface BaseData
{
	/** @var array */
	const DRILL_MAZE_NEXT_DIRECTION = [
		[0, 1],   //UP[NORTH]
		[0, -1],  //DOWN[SOUTH]
		[1, 0],   //LEFT[EAST]
		[-1, 0]   //RIGHT[WEST]
	];
}
<?php
namespace maze\generator;

use pocketmine\block\Block;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\Server;
use maze\TheMaze;

class MazeDriller extends ProcessingDriller implements BaseData
{
	/**
	 * @param int   $startX
	 * @param int   $startZ
	 * @param int   $endX
	 * @param int   $endZ
	 * @param int   $posY
	 * @param Level $level
	 */
	public function drillWallToMaze(int $startX, int $startZ, int $endX, int $endZ, int $posY, Level $level) : void
	{
		$next = mt_rand(0, 3);
		while (true) {
			$x = mt_rand(min($startX, $endX), max($startX, $endX));
			$z = mt_rand(min($startZ, $endZ), max($startZ, $endZ));
			if ($x % 2 === 0 and $z % 2 === 0) {
				break;
			}
		}
		$this->drill($x, $posY, $z, TheMaze::getConfigData()["WallBlock"], $level, $next, $next);
	}

	/**
	 * @param int   $x
	 * @param int   $y
	 * @param int   $z
	 * @param int   $blockId
	 * @param Level $level
	 */
	private function drill(int $x, int $y, int $z, int $blockId, Level $level, int $next, int $backup) : void
	{
		while (true) {
			$nextX = $x + self::DRILL_MAZE_NEXT_DIRECTION[$next][0] * 2;
			$nextZ = $z + self::DRILL_MAZE_NEXT_DIRECTION[$next][1] * 2;
			$block = $level->getBlock(new Vector3($nextX, $y, $nextZ));
			$securityCheckX = $nextX + self::DRILL_MAZE_NEXT_DIRECTION[$next][0];
			$securityCheckZ = $nextZ + self::DRILL_MAZE_NEXT_DIRECTION[$next][1];
			if ($level->getBlock(new Vector3($nextX, $y + 1, $nextZ))->getId() !== $blockId or $level->getBlock(new Vector3($securityCheckX, $y + 1, $securityCheckZ))->getId() !== $blockId) {
				$next++;
				if ($next == 4) {
					$next = 0;
				}
				if ($next === $backup) {
					return;
				}
				continue;
			}
			for ($i = 1; $i <= 2; $i++) {
				for ($l = 1; $l < TheMaze::getConfigData()["WallHeight"]; $l++) {
					$level->setBlock(new Vector3($x + self::DRILL_MAZE_NEXT_DIRECTION[$next][0] * $i, $y + $l, $z + self::DRILL_MAZE_NEXT_DIRECTION[$next][1] * $i), Block::get(Block::AIR));
				}
			}
			$next = mt_rand(0, 3);
			$this->drill($nextX, $y, $nextZ, $blockId, $level, $next, $next);
		}
	}
}
<?php
namespace maze\generator;

use pocketmine\level\Position;
use pocketmine\math\Vector3;
use pocketmine\level\Level;
use pocketmine\block\Block;
use pocketmine\{
	Player,
	Server
};
use maze\tmp\TmpStation;
use maze\TheMaze;

class MazeGenerator implements BaseData
{
	/**
	 * @param Player $player
	 *
	 * @return bool
	 */
	public static function generateMaze(Player $player) : bool
	{
		$decoder = new PositionDecoder;
		$pos = $decoder->decodePos(TmpStation::getPos1($player), TmpStation::getPos2($player));
        $startX = $pos[0];
        $y = $pos[1];
        $startZ = $pos[2];
        $endX = $pos[3];
        $endZ = $pos[4];
        $level = Server::getInstance()->getLevelByName($pos[5]);
        $filler = new WallFiller;
        $config = TheMaze::getConfigData();
        $filler->fillAllWithWall($config["WallBlock"], $startX, $startZ, $endX, $endZ, $y, $level, $config["WallHeight"], $config["TopWallBlock"], $config["GroundBlock"]);
        $drill = new MazeDriller;
        $drill->drillWallToMaze($startX, $startZ, $endX, $endZ, $y, $level);
        return true;
	}
}
<?php
namespace maze\generator;

class PositionDecoder
{
	/**
	 * @param array $pos1
	 * @param array $pos2
	 *
	 * @return array
	 */
	public function decodePos(array $pos1, array $pos2) : array
	{
		$startX = $pos1[0];
		$startZ = $pos1[2];
		$endX = $pos2[0];
		$endZ = $pos2[1];
        if ($startX > $endX) {
            $tmp = $endX;
            $endX = $startX;
            $startX = $tmp;
        }
        if ($startZ > $endZ) {
            $tmp = $endZ;
            $endZ = $startZ;
            $startZ = $tmp;
        }
        $startX--;
        $endX++;
        $startZ--;
        $endZ++;
        return [$startX, $pos1[1], $startZ, $endX, $endZ, $pos1[3]];
	}
}
<?php
namespace maze\generator;

class ProcessingDriller
{
	/**
	 * @param int
	 */
	protected final function rand_odd(int $mod)
	{
	    $result = 1 + mt_rand(0, PHP_INT_MAX - 1) % $mod;
	    if ($result % 2 == 0) {
	        $result++;
	    }
	    if ($result > $mod) {
	        $result -= 2;
	    }
	    return $result;
	}
}
<?php
namespace maze\generator;

class ProcessingFiller
{
	/**
	 * @param int $max
	 * @param int $min
	 *
	 * @return int
	 */
	protected final function getSide(int $max, int $min) : int
	{
		return ($max - $min) + 1;
	}

	/**
	 * @param int $start
	 * @param int $end
	 *
	 * @return int
	 */
	protected final function getNext(int $start, int $end) : int
	{
		return $start < $end ? 1 : -1;
	}
}
<?php
namespace maze\generator;

use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\block\Block;

class WallFiller extends ProcessingFiller
{
	/**
	 * @param int   $blockId
	 * @param int   $startX
	 * @param int   $startZ
	 * @param int   $endX
	 * @param int   $endZ
	 * @param int   $posY
	 * @param Level $level
	 * @param int   $wallHeight
	 * @param int   $topBlockId
	 * @param int   $groundBlockId
	 */
	public function fillAllWithWall(int $blockId, int $startX, int $startZ, int $endX, int $endZ, int $posY, Level $level, int $wallHeight, int $topBlockId, int $groundBlockId) : void
	{
		if (!$blockId) {
			return;
		}
		$startX--;
		$maxX = max($startX, $endX);
		$maxZ = max($startZ, $endZ);
		$minX = min($startX, $endX);
		$minZ = min($startZ, $endZ);
		$sideX = $this->getSide($maxX, $minX);
		$sideZ = $this->getSide($maxZ, $minZ);
		$nextX = $this->getNext($startX, $endX);
		$nextZ = $this->getNext($startZ, $endZ);
		$sideZ -= 2;
		for ($i = 0; abs($i) <= $sideX; $i += $nextX) {
			$x = $startX + $i;
			for ($l = 0; $l < $wallHeight; $l++) {
				$y = $posY + $l;
				for ($j = 0; abs($j) < $sideZ; $j += $nextZ) {
					$z = $startZ + $j;
					$vec = new Vector3($x, $y, $z);
					if (($l - 1) < 0) {
						$level->setBlock($vec, Block::get($groundBlockId));
					} elseif ($l === ($wallHeight - 1)) {
						$level->setBlock($vec, Block::get($topBlockId));
					} else {
						$level->setBlock($vec, Block::get($blockId));
					}
				}
			}
		}
	}
}
<?php
namespace maze\memory;

class TaskingClipboard
{
	
}<?php
namespace maze\path;

use pocketmine\utils\Config;
use pocketmine\block\Block;
use maze\TheMaze;

class Path
{
	/**
     * @return string
     */
	protected final function getPath() : string
	{
		return TheMaze::getPath();
	}

	/**
	 * @return Config [object]
	 */
	protected function getSign() : Config
	{
		return TheMaze::$sign;
	}

	/**
	 * @param Block $block
	 *
	 * @return string
	 */
	protected function convertString(Block $block) : string
	{
		return (string) floor($block->x) . " : " . floor($block->y) . " : " . floor($block->z) . " : " . $block->getLevel()->getName();
	}
}
<?php
namespace maze\task;

use pocketmine\scheduler\Task;
use pocketmine\Player;

class Timer extends Task
{
	/** @var int */
	public $time;

	public function __construct(Player $player)
	{
		$this->player = $player;
	}

	public function onRun() : void
	{
		$this->time++;
	}
}<?php
namespace maze;

use pocketmine\plugin\PluginBase;
use pocketmine\utils\Config;
use maze\command\MainCommand;
use maze\event\{
	SignEvent,
	SignTouch
};

class TheMaze extends PluginBase
{
	/** @var array */
	private static $config = null;
	/** @var Config */
	public static $sign;

	public function onEnable()
	{
		$this->initConfig();
		$this->registerCommand();
		$this->registerEvents();
	}

	/**
	 * @return array
	 */
	public static function getConfigData() : array
	{
		return self::$config;
	}

	private function initConfig() : void
	{
		if (!is_dir($this->getDataFolder())) {
			mkdir($this->getDataFolder());
		}
		self::$config = (new Config($this->getDataFolder() . "Config.yml", Config::YAML, [
			"WallBlock" => 1,
			"WallHeight" => 3,
			"TopWallBlock" => 41,
			"GroundBlock" => 0
		]))->getAll();
		self::$sign = new Config($this->getDataFolder() . "SignData.yml", Config::YAML);
	}

	private function registerEvents() : void
	{
		//$this->getServer()->getPluginManager()->registerEvents(new SignEvent, $this);
		//$this->getServer()->getPluginManager()->registerEvents(new SignTouch, $this);
	}

	private function registerCommand() : void
	{
		$this->getServer()->getCommandMap()->register("maze", new MainCommand());
	}
}
<?php
namespace maze\tmp;

interface Messages
{
	const MESSAGE_FAILED_CAUSE_EVEN = "後一ブロック横へずれてください。";
	const MESSAGE_FAILED_CAUSE_DIFF_LEVEL = "最初の地点とワールドが異なります。";
	const MESSAGE_SUCCESS = "迷路の範囲を設定しました。";
}
<?php
namespace maze\tmp;

use pocketmine\Player;

class TmpStation implements Messages
{
	/** @var array|null */
	private static $pos1, $pos2 = null;

	/**
	 * @param Player $player
	 * @param int    $x
	 * @param int    $y
	 * @param int    $z
	 * @param string $level
	 */
	public static function registerPos1(Player $player, int $x, int $y, int $z, string $level) : void
	{
		self::$pos1[$player->getName()] = [$x, $y, $z, $level];
	}

	/**
	 * @param Player $player
	 * @param int    $x
	 * @param int    $z
	 * @param string $level
	 */
	public static function registerPos2(Player $player, int $x, int $z, string $level) : string
	{
		$name = $player->getName();
		$pos1 = self::$pos1[$name];
		if ((($pos1[0] - $x) % 2 !== 0) or (($pos1[2] - $z) % 2 !== 0)) {
			return self::MESSAGE_FAILED_CAUSE_EVEN;
		}
		if ($pos1[3] !== $level) {
			return self::MESSAGE_FAILED_CAUSE_DIFF_LEVEL;
		}
		self::$pos2[$name] = [$x, $z, $level];
		return self::MESSAGE_SUCCESS;
	}

	/**
	 * @param Player $player
	 *
	 * @return bool
	 */
	public static function isSettedPos1(Player $player) : bool
	{
		return isset(self::$pos1[$player->getName()]);
	}

	/**
	 * @param Player $player
	 *
	 * @return bool
	 */
	public static function isSettedPos2(Player $player) : bool
	{
		return isset(self::$pos2[$player->getName()]);
	}

	/**
	 * @param Player $player
	 *
	 * @return array
	 */
	public static function getPos1(Player $player) : ?array
	{
		return self::$pos1[$player->getName()];
	}

	/**
	 * @param Player $player
	 *
	 * @return array
	 */
	public static function getPos2(Player $player) : ?array
	{
		return self::$pos2[$player->getName()];
	}
}
$Hv(N;Qս   GBMB