<?php

$web = 'index.php';

if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
Phar::interceptFileFuncs();
set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
Phar::webPhar(null, $web);
include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
return;
}

if (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {
Extract_Phar::go(true);
$mimes = array(
'phps' => 2,
'c' => 'text/plain',
'cc' => 'text/plain',
'cpp' => 'text/plain',
'c++' => 'text/plain',
'dtd' => 'text/plain',
'h' => 'text/plain',
'log' => 'text/plain',
'rng' => 'text/plain',
'txt' => 'text/plain',
'xsd' => 'text/plain',
'php' => 1,
'inc' => 1,
'avi' => 'video/avi',
'bmp' => 'image/bmp',
'css' => 'text/css',
'gif' => 'image/gif',
'htm' => 'text/html',
'html' => 'text/html',
'htmls' => 'text/html',
'ico' => 'image/x-ico',
'jpe' => 'image/jpeg',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'js' => 'application/x-javascript',
'midi' => 'audio/midi',
'mid' => 'audio/midi',
'mod' => 'audio/mod',
'mov' => 'movie/quicktime',
'mp3' => 'audio/mp3',
'mpg' => 'video/mpeg',
'mpeg' => 'video/mpeg',
'pdf' => 'application/pdf',
'png' => 'image/png',
'swf' => 'application/shockwave-flash',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'wav' => 'audio/wav',
'xbm' => 'image/xbm',
'xml' => 'text/xml',
);

header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

$basename = basename(__FILE__);
if (!strpos($_SERVER['REQUEST_URI'], $basename)) {
chdir(Extract_Phar::$temp);
include $web;
return;
}
$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));
if (!$pt || $pt == '/') {
$pt = $web;
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);
exit;
}
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
header('HTTP/1.0 404 Not Found');
echo "<html>\n <head>\n  <title>File Not Found<title>\n </head>\n <body>\n  <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
exit;
}
$b = pathinfo($a);
if (!isset($b['extension'])) {
header('Content-Type: text/plain');
header('Content-Length: ' . filesize($a));
readfile($a);
exit;
}
if (isset($mimes[$b['extension']])) {
if ($mimes[$b['extension']] === 1) {
include $a;
exit;
}
if ($mimes[$b['extension']] === 2) {
highlight_file($a);
exit;
}
header('Content-Type: ' .$mimes[$b['extension']]);
header('Content-Length: ' . filesize($a));
readfile($a);
exit;
}
}

class Extract_Phar
{
static $temp;
static $origdir;
const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'index.php';
const LEN = 6685;

static function go($return = false)
{
$fp = fopen(__FILE__, 'rb');
fseek($fp, self::LEN);
$L = unpack('V', $a = (binary)fread($fp, 4));
$m = (binary)'';

do {
$read = 8192;
if ($L[1] - strlen($m) < 8192) {
$read = $L[1] - strlen($m);
}
$last = (binary)fread($fp, $read);
$m .= $last;
} while (strlen($last) && strlen($m) < $L[1]);

if (strlen($m) < $L[1]) {
die('ERROR: manifest length read was "' .
strlen($m) .'" should be "' .
$L[1] . '"');
}

$info = self::_unpack($m);
$f = $info['c'];

if ($f & self::GZ) {
if (!function_exists('gzinflate')) {
die('Error: zlib extension is not enabled -' .
' gzinflate() function needed for zlib-compressed .phars');
}
}

if ($f & self::BZ2) {
if (!function_exists('bzdecompress')) {
die('Error: bzip2 extension is not enabled -' .
' bzdecompress() function needed for bz2-compressed .phars');
}
}

$temp = self::tmpdir();

if (!$temp || !is_writable($temp)) {
$sessionpath = session_save_path();
if (strpos ($sessionpath, ";") !== false)
$sessionpath = substr ($sessionpath, strpos ($sessionpath, ";")+1);
if (!file_exists($sessionpath) || !is_dir($sessionpath)) {
die('Could not locate temporary directory to extract phar');
}
$temp = $sessionpath;
}

$temp .= '/pharextract/'.basename(__FILE__, '.phar');
self::$temp = $temp;
self::$origdir = getcwd();
@mkdir($temp, 0777, true);
$temp = realpath($temp);

if (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {
self::_removeTmpFiles($temp, getcwd());
@mkdir($temp, 0777, true);
@file_put_contents($temp . '/' . md5_file(__FILE__), '');

foreach ($info['m'] as $path => $file) {
$a = !file_exists(dirname($temp . '/' . $path));
@mkdir(dirname($temp . '/' . $path), 0777, true);
clearstatcache();

if ($path[strlen($path) - 1] == '/') {
@mkdir($temp . '/' . $path, 0777);
} else {
file_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));
@chmod($temp . '/' . $path, 0666);
}
}
}

chdir($temp);

if (!$return) {
include self::START;
}
}

static function tmpdir()
{
if (strpos(PHP_OS, 'WIN') !== false) {
if ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {
return $var;
}
if (is_dir('/temp') || mkdir('/temp')) {
return realpath('/temp');
}
return false;
}
if ($var = getenv('TMPDIR')) {
return $var;
}
return realpath('/tmp');
}

static function _unpack($m)
{
$info = unpack('V', substr($m, 0, 4));
 $l = unpack('V', substr($m, 10, 4));
$m = substr($m, 14 + $l[1]);
$s = unpack('V', substr($m, 0, 4));
$o = 0;
$start = 4 + $s[1];
$ret['c'] = 0;

for ($i = 0; $i < $info[1]; $i++) {
 $len = unpack('V', substr($m, $start, 4));
$start += 4;
 $savepath = substr($m, $start, $len[1]);
$start += $len[1];
   $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));
$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]
& 0xffffffff);
$ret['m'][$savepath][7] = $o;
$o += $ret['m'][$savepath][2];
$start += 24 + $ret['m'][$savepath][5];
$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;
}
return $ret;
}

static function extractFile($path, $entry, $fp)
{
$data = '';
$c = $entry[2];

while ($c) {
if ($c < 8192) {
$data .= @fread($fp, $c);
$c = 0;
} else {
$c -= 8192;
$data .= @fread($fp, 8192);
}
}

if ($entry[4] & self::GZ) {
$data = gzinflate($data);
} elseif ($entry[4] & self::BZ2) {
$data = bzdecompress($data);
}

if (strlen($data) != $entry[0]) {
die("Invalid internal .phar file (size error " . strlen($data) . " != " .
$stat[7] . ")");
}

if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
die("Invalid internal .phar file (checksum error)");
}

return $data;
}

static function _removeTmpFiles($temp, $origdir)
{
chdir($temp);

foreach (glob('*') as $f) {
if (file_exists($f)) {
is_dir($f) ? @rmdir($f) : @unlink($f);
if (file_exists($f) && is_dir($f)) {
self::_removeTmpFiles($f, getcwd());
}
}
}

@rmdir($temp);
clearstatcache();
chdir($origdir);
}
}

Extract_Phar::go();
__HALT_COMPILER(); ?>j                  
   plugin.ymlì   €•WZì   V†‚ï¶         src/Warehouse/Main.phpY7  €•WZY7  њw…¶      name: Warehouse
main: Warehouse\Main
version: 1.0.0
api: [1.10.0,3.0.0, 3.0.0-ALPHA10,2.0.0]
load: POSTWORLD
description: バーチャル倉庫を追加します
commands:
 whouse:
  description: バーチャル倉庫を開く
<?php

namespace Warehouse;

use pocketmine\Player;
use pocketmine\Plugin\PluginBase;
use pocketmine\Server;
use pocketmine\network\mcpe\protocol\ModalFormRequestPacket;
use pocketmine\network\mcpe\protocol\ModalFormResponsePacket;
use pocketmine\event\server\DataPacketReceiveEvent;
use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\inventory\PlayerInventory;
use pocketmine\inventory\Inventory;
use pocketmine\item\Item;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\event\Listener;
use pocketmine\utils\TextFormat;
use pocketmine\utils\Config;

class Main extends PluginBase implements Listener{

	public function onEnable(){
		if(!file_exists($this->getDataFolder())){
    		mkdir($this->getDataFolder(), 0744, true);
	}

	/*コンフィグ*/
	$this->getServer()->getPluginManager()->registerEvents($this, $this);
	$this->WH = new Config($this->getDataFolder() . "wh.yml", Config::YAML);
	$this->WHI = new Config($this->getDataFolder() . "info.yml", Config::YAML);
	/*コンフィグ*/
	$this->info = [];

	}

//API	/*==========================================================================================================================*/

	public function sendForm(Player $player, $title, $come, $buttons, $id) {
		
	$pk = new ModalFormRequestPacket(); 
	$pk->formId = $id;
	$this->pdata[$pk->formId] = $player;
	$data = [ 
	'type'    => 'form', 
	'title'   => $title, 
	'content' => $come, 
	'buttons' => $buttons 
	]; 
	$pk->formData = json_encode( $data, JSON_PRETTY_PRINT | JSON_BIGINT_AS_STRING | JSON_UNESCAPED_UNICODE );
	$player->dataPacket($pk);
	$this->lastFormData[$player->getName()] = $data;
	}

	public function sendModal(Player $player, $title, $come, $up, $down, $id) {
		
	$pk = new ModalFormRequestPacket(); 
	$pk->formId = $id;
	$data = [ 
	'type'    => 'modal', 
	'title'   => $title, 
	'content' => $come, 
	'button1' => $up,
	'button2' => $down 
	]; 
	$pk->formData = json_encode( $data, JSON_PRETTY_PRINT | JSON_BIGINT_AS_STRING | JSON_UNESCAPED_UNICODE );
	$player->dataPacket($pk);
	}

	public function sendCustom(Player $player, $title, $elements, $id) {
		
	$pk = new ModalFormRequestPacket(); 
	$pk->formId = $id;
	$this->pdata[$pk->formId] = $player;
	$data = [ 
	'type'    => 'custom_form', 
	'title'   => $title, 
	'content' => $elements
	]; 
	$pk->formData = json_encode( $data, JSON_PRETTY_PRINT | JSON_BIGINT_AS_STRING | JSON_UNESCAPED_UNICODE );
	$player->dataPacket($pk);
	}

	public function startMenu($player) {
		
	$user = $player->getName();
	$buttons[] = [ 
	'text' => "倉庫を使用する", 
	'image' => [ 'type' => 'path', 'data' => "" ] 
	]; //0
	$buttons[] = [ 
	'text' => "持ち物をすべて倉庫に移動させる", 
	'image' => [ 'type' => 'path', 'data' => "" ] 
	]; //1
	$buttons[] = [ 
	'text' => "倉庫を消去する", 
	'image' => [ 'type' => 'path', 'data' => "" ] 
	]; //2
	$this->sendForm($player,"§lメニュー","何をしますか？\n\n",$buttons,2001);
	$this->info[$user] = "form";
	}

//API	/*==========================================================================================================================*/

	public function onJoin(PlayerJoinEvent $event){
	$player = $event->getPlayer();
	$user = $player->getName();
	$this->info[$user] = "";
	}

	public function onSYORIDESU(DataPacketReceiveEvent $event){

	$player = $event->getPlayer();
	$pk = $event->getPacket();
	$user = $player->getName();
		if($pk->getName() == "ModalFormResponsePacket" and isset($this->info[$user])){
		$usera = "1"."$user";
		$data = $pk->formData;
			if($data == "null\n"){
			}else{
				switch($this->info[$user]){
				case "modal":
					switch($pk->formId){
					case 2000://アカウント登録
						if($data == "true\n"){
						$this->WHI->set($user,true);
						$this->WHI->save();
						$this->sendForm($player,"§l完了","アカウント登録が完了しました。\n利用するにはもう一度コマンドを実行してください。",[],0);
						$this->info[$user] = "";
						}elseif($data == "false\n"){
						$this->info[$user] = "";
						}
					break;
					case 2200://持ち物すべて移動
						if($data == "true\n"){
						$si = $player->getInventory()->getSize();
							for($is = 1; $is <= $si; ++$is){
							$item = $player->getInventory()->getItem($is-1);
							$i = 1;
							if($item->getId() !== 0){
								while($i){
								$ib = $i."$user";
									if($this->WH->exists($ib)){
									$it = $this->WH->get($ib);
										if($it["NAME"] == $item->getName()){//かぶってるアイテムがあったら
										$a = $it["CO"]+$item->getCount();
										$this->WH->set($ib,["ID"=>$it["ID"],"META"=>$it["META"],"CO"=>$a,"NAME"=>$it["NAME"],"CU"=>$it["CU"]]);
										$this->WH->save();
										break;
										}else{
										$i++;
										}
									}elseif(!$this->WH->exists($ib) and $is !== $si){
									$ibs = $i."$user";
									$value = $item->hasCustomName() ? $value = true : $value = false;
									$this->WH->set($ibs,["ID"=>$item->getID(),"META"=>$item->getDamage(),"CO"=>$item->getCount(),"NAME"=>$item->getName(),"CU"=>$value]);
									$this->WH->save();
									break;
									}else{
									$i--;
									break;
									}
								}
							}
							}
						$this->sendForm($player,"§l完了","倉庫への移動が完了しました。",[],0);
						$player->getInventory()->clearAll();
						$this->info[$user] = "";
						}else{
						$this->startMenu($player);
						}

					break;
					case 2300://持ち物すべて移動
						if($data == "true\n"){
						$i = 1;
							while($i){
							$ib = $i."$user";
								if($this->WH->exists($ib)){
								$this->WH->remove($ib);
								$this->WH->save();
								$i++;
								}else{
								$i--;
								break;
								}
							}
						$this->WHI->remove($user);
						$this->WHI->save();
						$this->sendForm($player,"§l完了","倉庫が完全に消去されました。",[],0);
						$this->info[$user] = "";
						}else{
						$this->startMenu($player);
						}

					break;
					}
				case "form":
					switch($pk->formId){
					case 2001:
						if($data == 0){
						$buttons[] = [ 
						'text' => "自分の持ち物", 
						]; //0
						$buttons[] = [ 
						'text' => "自分の倉庫", 
						]; //1
						$buttons[] = [ 
						'text' => "戻る", 
						]; //2
						$this->sendForm($player,"§lメニュー/倉庫を使用する","何をしますか？\n\n",$buttons,2100);
						}elseif($data == 1){
						$this->sendModal($player,"§lメニュー/持ち物をすべて倉庫に移動させる","本当に実行しますか？\n*§a持ち物からアイテムはなくなります§f*\n","はい","戻る",2200);
						$this->info[$user] = "modal";
						}elseif($data == 2){
						$this->sendModal($player,"§lメニュー/倉庫を消去する","本当に実行しますか？\n*§c倉庫のアイテムは完全に消えます§f*\n","はい","戻る",2300);
						$this->info[$user] = "modal";
						}
					break;
					case 2100:
						if($data == 0){//自分の持ち物
						$si = $player->getInventory()->getSize();
						$buttons[] = [ 
						'text' => "戻る", 
						]; 
							for($is = 1; $is <= $si; ++$is){
							$item = $player->getInventory()->getItem($is-1);
								if($item->getId() !== 0){
								$buttons[] = [ 
								'text' => "§l§2名前§8: ".$item->getName()." (".$item->getCount()."個)", 
								]; 
								$this->MYITEM[$user][$is] = $item;
								}
							}	
						$this->sendForm($player,"§l倉庫を使用する/自分の持ち物","倉庫に送るアイテムを選んでください。\n\n",$buttons,3000);
						}elseif($data == 1){//自分の倉庫
						$i = 1;
						$buttons[] = [ 
						'text' => "戻る", 
						]; 
							while($i){
							$ib = $i."$user";
								if($this->WH->exists($ib)){
								$it = $this->WH->get($ib);
								$buttons[] = [ 
								'text' => "§l§3名前§8: ".$it["NAME"]." (".$it["CO"]."個)", 
								]; 
								$this->WHITEM[$user][$i] = $it;
								$i++;
								}else{
								$i--;
								break;
								}
							}
						$this->sendForm($player,"§l倉庫を使用する/自分の倉庫","手持ちに送るアイテムを選んでください。\n\n",$buttons,4000);
						}elseif($data == 2){
						$this->startMenu($player);
						}
					break;

					case 3000://倉庫にアイテム送信
						if($data == 0){//自分の持ち物
						$this->startMenu($player);
						}else{//自分の倉庫
						$da = json_decode($data);
						$item = $this->MYITEM[$user][$da];
						$elements[] = [ 
						'type' => "label",
						'text' => "".$item->getName()." を§a倉庫§fに送信します。\n*§c0個の場合、送信ができません。§f*\n", 
						]; 
						for($i = 0; $i <= $item->getCount(); $i++){
						$a[] = "".$i."";
						}
						$elements[] = [ 
						'type' => "step_slider",
						'text' => "送信する数", 
						'steps' => $a,
						'defaultIndex' => "1"
						]; 
						$this->MYITEMS[$user] = $item;
						$this->sendCustom($player,"§l自分の持ち物/倉庫に送信",$elements,3001);
						$this->info[$user] = "custom";
						}
					break;

					case 4000://手持ちにアイテム送信
						if($data == 0){//自分の持ち物
						$this->startMenu($player);
						}else{//自分の倉庫
						$da = json_decode($data);
						$item = $this->WHITEM[$user][$da];
						$elements[] = [ 
						'type' => "label",
						'text' => "".$item["NAME"]." を§b手持ち§fに送信します。\n*§c一度に64個までしか送信できません。§f*\n*§c0個の場合、送信ができません。§f*\n", 
						]; 
						for($i = 0; $i <= $item["CO"]; $i++){
						$a[] = "".$i."";
						}
						$elements[] = [ 
						'type' => "step_slider",
						'text' => "送信する数", 
						'steps' => $a,
						'defaultIndex' => "0"
						]; 
						$this->WHITEMS[$user] = $da;
						$this->sendCustom($player,"§l自分の倉庫/手持ちに送信",$elements,4001);
						$this->info[$user] = "custom";
						}
					break;
					}
				case "custom":
					switch($pk->formId){
					case 3001://倉庫に送信
					$da = json_decode($data)[1]++;//個数
					if($da == 0){
					$this->sendForm($player,"§lエラー","§c0個の場合、送信ができません。\nもう一度やり直してください。",[],0);
					$this->startMenu($player);
					}else{
					$item = $this->MYITEMS[$user];
					$player->getInventory()->removeItem($item);
					$item->setCount($item->getCount() - $da);
					$player->getInventory()->addItem($item);
					$i = 1;
					$a = false;
						while($i){
						$ib = $i."$user";
							if($this->WH->exists($ib)){
							$it = $this->WH->get($ib);
								if($it["NAME"] == $item->getName()){//かぶってるアイテムがあったら
								$a = $it["CO"]+$da;
								$this->WH->set($ib,["ID"=>$it["ID"],"META"=>$it["META"],"CO"=>$a,"NAME"=>$it["NAME"],"CU"=>$it["CU"]]);
								$this->WH->save();
								$a = true;
								break;
								}else{
								$i++;
								}
							}elseif(!$this->WH->exists($ib) and $a !== true){
							$ibs = $i."$user";
							$value = $item->hasCustomName() ? $value = true : $value = false;
							$this->WH->set($ibs,["ID"=>$item->getID(),"META"=>$item->getDamage(),"CO"=>$da,"NAME"=>$item->getName(),"CU"=>$value]);
							$this->WH->save();
							break;
							}else{
							$i--;
							break;
							}
						}
					$this->sendForm($player,"§l完了","倉庫への移動が完了しました。",[],0);
					$this->info[$user] = "";
					}
					break;
					case 4001://手持ちに送信
					$da = json_decode($data)[1]++;//個数
					if($da == 0){
					$this->sendForm($player,"§lエラー","§c0個の場合、送信ができません。\nもう一度やり直してください。",[],0);
					$this->startMenu($player);
					}else{
					$count = $this->WHITEMS[$user];
					$ib = $this->WHITEMS[$user]."$user";
					$it = $this->WH->get($ib);
					$a = $it["CO"] - $da;
						if($a == 0){
						$this->WH->remove($ib);
						$this->WH->save();
						$counts = $count+1;
							while($counts){
							$ibs = $counts."$user";
								if($this->WH->exists($ibs)){ 
								$its = $this->WH->get($ibs);
								$coun = $counts-1;
								$ibss = $coun."$user";
								$this->WH->set($ibss,["ID"=>$its["ID"],"META"=>$its["META"],"CO"=>$its["CO"],"NAME"=>$its["NAME"],"CU"=>$its["CU"]]);
								$this->WH->remove($ibs);
								$this->WH->save();
								$counts++;
								}else{
								$counts--;
								break;
								}
							}
						}else{
						$this->WH->set($ib,["ID"=>$it["ID"],"META"=>$it["META"],"CO"=>$a,"NAME"=>$it["NAME"],"CU"=>$it["CU"]]);
						$this->WH->save();
						}
					$items = Item::get($it["ID"],$it["META"],$da);
					if($it["CU"] == true){
					$items->setCustomName($it["NAME"]);
					}
					$player->getInventory()->addItem($items);
					$this->sendForm($player,"§l完了","手持ちへの移動が完了しました。",[],0);
					$this->info[$user] = "";
					}
					break;
					}
				break;
				}
			}
		}
	}





    public function onCommand(CommandSender $sender, Command $command, string $label, array $args):bool{
        
	if($sender->getName() === "CONSOLE") {
	$sender->sendMessage(">>§cこのコマンドはゲーム内で使ってください");
	return false;
        }else{
	switch ($command->getName()) {

	case "whouse":
		$player = $sender;
		$user = $sender->getName();
		$usera = "1"."$user";
			if(!$this->WHI->exists($user)){
			$this->sendModal($player,"§lアカウント登録","あなたにはまだ自分の倉庫がありません。\n作成しますか？\n","はい","いいえ",2000);
			$this->info[$user] = "modal";
			}else{
			$this->startMenu($player);
			}
		return true;
		}
	}
}
}Éâ÷¢÷}ç‘~âmºvü]}`Ü   GBMB