<?php echo "PocketMine-MP plugin EconomyCShop v0.6.2\nThis file has been generated using DevTools v1.12.10 at Thu, 26 Apr 2018 22:47:17 +0930\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:12:"EconomyCShop";s:7:"version";s:5:"0.6.2";s:4:"main";s:26:"FAMIMA\ECShop\EconomyCShop";s:3:"api";a:8:{i:0;s:12:"3.0.0-ALPHA7";i:1;s:12:"3.0.0-ALPHA8";i:2;s:12:"3.0.0-ALPHA9";i:3;s:13:"3.0.0-ALPHA10";i:4;s:13:"3.0.0-ALPHA11";i:5;s:13:"3.0.0-ALPHA12";i:6;s:13:"3.0.0-ALPHA13";i:7;s:13:"3.0.0-ALPHA14";}s:6:"depend";a:0:{}s:11:"description";s:0:"";s:7:"authors";a:1:{i:0;s:6:"FAMIMA";}s:7:"website";s:0:"";s:12:"creationDate";i:1524748637;}   ECShopPos.sqlite3 0  ]Z 0        
   FpMemo.txtJ  ]ZJ  l         LICENSE  ]Z  7Ͷ         Message.yml@  ]Z@  4      
   plugin.yml   ]Z   U*      	   README.md  ]Z  |ql         resource/config.yml    ]Z                 resource/message_jpn.yml    ]Z              %   src/FAMIMA/ECShop/DatabaseManager.phpp  ]Zp  Q      "   src/FAMIMA/ECShop/EconomyCShop.php  ]Z  k3      #   src/FAMIMA/ECShop/EventListener.php  ]Z  &Q      SQLite format 3   @                                                                     .    c                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 P++Ytablesqlite_sequencesqlite_sequenceCREATE TABLE sqlite_sequence(name,seq)tableshopshopCREATE TABLE shop(
			id INTEGER PRIMARY KEY AUTOINCREMENT,
			owner TEXT NOT NULL,
			cx INTEGER NOT NULL,
			cy INTEGER NOT NULL,
			cz INTEGER NOT NULL,
			sx INTEGER NOT NULL,
			sy INTEGER NOT NULL,
			sz INTEGER NOT NULL,
			itemid INTEGER NOT NULL,
			itemmeta INTEGER NOT NULL,
			itemamount INTEGER NOT NULL,
			price INTEGER NOT NULL,
			levelname TEXT NOT NULL
		)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            0.0.1 -  8-03  8:48 EconomyCShop作成開始
0.0.2 -        8:49 0.0.1でのエラーを修正
0.0.3 -        8:52 0.0.2でのエラーを修正,ファイル構成の見直し
0.1.0 -       10:05 EventListenerの追加
0.1.1 -       10:41 EventListenerの起動をお知らせするように変更
0.1.2 -       10:42 DatabaseManagerの追加
0.1.3 -       10:50 DatabaseManagerのバグの修正
0.1.4 -  8-06 20:34 DatabaseManagerとEconomyCShopの更新
0.2.0 -  8-08 14:36 DatabaseManager, メソッドの追加
0.2.1 -  8-09 13:15 EventListenerへのイベント追加
0.2.2 -       13:17 EconomyCShopの修正
0.2.3 -       13:18 EventListenerの修正
0.2.4 -       13:20 EventListenerの修正
0.2.4.1       13:22 デバッグバージョンの作成
0.2.5 -       13:25 EventListenerの修正
0.2.6 -       13:26 EventListenerの修正
0.3.0 -       15:14 Chestの取得方法の追加
0.3.1 -       15:56 EconomyCShopの作成方法の追加
0.3.2 -       16:06 EconomyCShopの修正
0.3.3 -       16:09 EventListenerの修正
0.3.4 -       17:03 EventListenerの修正
0.3.5 -       17:12 EventListenerの修正
0.3.6 -       17:15 DatabaseManagerの修正
0.3.7 -       17:17 DatabaseManagerの修正
0.3.8 -       17:19 DatabaseManagerの修正
0.3.9 -       17:23 DatabaseManagerの修正
0.4.0 -       17:XX ChestShopSystemの実装開始
0.4.0.1       20:45 デバッグバージョンの作成
0.4.1 -  8-10  9:20 ChestShopSystem_v0.1-アイテムの確認
0.4.2 -        9:33 バグの修正
0.4.3 -        9:34 バグの修正
0.4.4 -        9:39 バグの修正
0.4.5 -        9:41 バグの修正
0.4.6 -        9:53 バグの修正
0.5.0 -       12:28 ChestShopSystem_v0.2-アイテム購入の手続きの追加
0.5.1 -       14:00 ChestShopSystem_v0.3-閉店!
0.5.2 -       18:44 EconomyAPIとの連帯
0.5.3 -       20:15 Item購入の実装完了
0.5.3.1       20:16 デバッグバージョンの作成
0.5.4 -       20:44 おそらく完成版
0.5.4 -  8-11 12:30 リリース
0.6.2 -184-26 21:00 SignChangeEventの仕様変更によるバグの修正
                   GNU LESSER GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.


  This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.

  0. Additional Definitions.

  As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.

  "The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.

  An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.

  A "Combined Work" is a work produced by combining or linking an
Application with the Library.  The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".

  The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.

  The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.

  1. Exception to Section 3 of the GNU GPL.

  You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.

  2. Conveying Modified Versions.

  If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:

   a) under this License, provided that you make a good faith effort to
   ensure that, in the event an Application does not supply the
   function or data, the facility still operates, and performs
   whatever part of its purpose remains meaningful, or

   b) under the GNU GPL, with none of the additional permissions of
   this License applicable to that copy.

  3. Object Code Incorporating Material from Library Header Files.

  The object code form of an Application may incorporate material from
a header file that is part of the Library.  You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:

   a) Give prominent notice with each copy of the object code that the
   Library is used in it and that the Library and its use are
   covered by this License.

   b) Accompany the object code with a copy of the GNU GPL and this license
   document.

  4. Combined Works.

  You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:

   a) Give prominent notice with each copy of the Combined Work that
   the Library is used in it and that the Library and its use are
   covered by this License.

   b) Accompany the Combined Work with a copy of the GNU GPL and this license
   document.

   c) For a Combined Work that displays copyright notices during
   execution, include the copyright notice for the Library among
   these notices, as well as a reference directing the user to the
   copies of the GNU GPL and this license document.

   d) Do one of the following:

       0) Convey the Minimal Corresponding Source under the terms of this
       License, and the Corresponding Application Code in a form
       suitable for, and under terms that permit, the user to
       recombine or relink the Application with a modified version of
       the Linked Version to produce a modified Combined Work, in the
       manner specified by section 6 of the GNU GPL for conveying
       Corresponding Source.

       1) Use a suitable shared library mechanism for linking with the
       Library.  A suitable mechanism is one that (a) uses at run time
       a copy of the Library already present on the user's computer
       system, and (b) will operate properly with a modified version
       of the Library that is interface-compatible with the Linked
       Version.

   e) Provide Installation Information, but only if you would otherwise
   be required to provide such information under section 6 of the
   GNU GPL, and only to the extent that such information is
   necessary to install and execute a modified version of the
   Combined Work produced by recombining or relinking the
   Application with a modified version of the Linked Version. (If
   you use option 4d0, the Installation Information must accompany
   the Minimal Corresponding Source and Corresponding Application
   Code. If you use option 4d1, you must provide the Installation
   Information in the manner specified by section 6 of the GNU GPL
   for conveying Corresponding Source.)

  5. Combined Libraries.

  You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:

   a) Accompany the combined library with a copy of the same work based
   on the Library, uncombined with any other library facilities,
   conveyed under the terms of this License.

   b) Give prominent notice with the combined library that part of it
   is a work based on the Library, and explaining where to find the
   accompanying uncombined form of the same work.

  6. Revised Versions of the GNU Lesser General Public License.

  The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.

  Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.

  If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
---
Message1: §aEconomyCShopの作成が完了しました
Message2: §cChestが見つかりません!,横にChestがあるか確認してください
Message3: §cこれはあなたのSHOPです
Message4: §cインベントリにアイテムが追加できません
Message5: §cChestにアイテムがありません, 補充してもらいましょう(´・ω・｀)
Message6: §cお金が足りないため購入できませんでした
Message7: §cあなたはこのchestを開けることができません!
Message8: §6§6%item§aを§b%amount個§a購入しました
Message9: §9%itemを購入しますか?(%price円です)
Message10: §cあなたはこのShopを破壊することができません
Message11: §cあなたはこのChestを破壊することができません
Message12: §cShopを閉店しました
...
name: EconomyCShop
main: FAMIMA\ECShop\EconomyCShop
author: FAMIMA
version: 0.6.2
api: [3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9, 3.0.0-ALPHA10, 3.0.0-ALPHA11, 3.0.0-ALPHA12, 3.0.0-ALPHA13, 3.0.0-ALPHA14]
# EconomyCShop
ChestShop for EconomyAPI. I write All code!

# 注意
php_sqlite3.dllを読み込まないと使用できません  
bin/phpの中のphp.iniの
```ini:sample
;php_sqlite3.dll
```
を
```ini:sample
php_sqilte3.dll
```
に変更してください
<?php

namespace FAMIMA\ECShop;

class DatabaseManager
{

	public $db;

	public function __construct($path)
	{
		$this->db = new \SQLite3($path);
		$this->db->exec(
		"CREATE TABLE IF NOT EXISTS shop(
			id INTEGER PRIMARY KEY AUTOINCREMENT,
			owner TEXT NOT NULL,
			cx INTEGER NOT NULL,
			cy INTEGER NOT NULL,
			cz INTEGER NOT NULL,
			sx INTEGER NOT NULL,
			sy INTEGER NOT NULL,
			sz INTEGER NOT NULL,
			itemid INTEGER NOT NULL,
			itemmeta INTEGER NOT NULL,
			itemamount INTEGER NOT NULL,
			price INTEGER NOT NULL,
			levelname TEXT NOT NULL
		)");
	}

	public function createChestShop($cx, $cy, $cz, $sx, $sy, $sz, $owner, $itemid, $itemmeta, $itemamount, $price, $worldname)
	{
		$this->db->exec("INSERT INTO
			shop(owner, cx, cy, cz, sx, sy, sz, itemid, itemmeta, itemamount, price, levelname)
			VALUES(\"$owner\", $cx, $cy, $cz, $sx, $sy, $sz, $itemid, $itemmeta, $itemamount, $price, \"$worldname\")");
	}

	public function updateChestShopData($sx, $sy, $sz, $owner, $itemid, $itemmeta, $itemamount, $price, $worldname)
	{
		$this->db->exec("UPDATE shop SET owner = \"$owner\", itemid = $itemid, itemmeta = $itemmeta, itemamount = $itemamount, price = $price WHERE sx = $sx and sy = $sy and sz = $sz and levelname = \"$worldname\"");
	}

	public function isShopExists($x, $y, $z, $levelname)
	{
		$sql = $this->db->prepare("SELECT * from shop WHERE sx = :x and sy = :y and sz = :z and levelname = :levelname");
		$sql->bindValue(':x', $x, SQLITE3_INTEGER);
		$sql->bindValue(':y', $y, SQLITE3_INTEGER);
		$sql->bindValue(':z', $z, SQLITE3_INTEGER);
		$sql->bindValue(':levelname', $levelname, SQLITE3_TEXT);
		$result = $sql->execute();

		return $result->fetchArray() !== false;
	}

	public function isShopChestExists($x, $y, $z, $levelname)
	{
		$sql = $this->db->prepare("SELECT * from shop WHERE cx = :x and cy = :y and cz = :z and levelname = :levelname");
		$sql->bindValue(':x', $x, SQLITE3_INTEGER);
		$sql->bindValue(':y', $y, SQLITE3_INTEGER);
		$sql->bindValue(':z', $z, SQLITE3_INTEGER);
		$sql->bindValue(':levelname', $levelname, SQLITE3_TEXT);
		$result = $sql->execute();

		return $result->fetchArray() !== false;
	}

	public function getShopData($x, $y, $z, $levelname)
	{
		$sql = $this->db->prepare("SELECT * from shop WHERE ( (sx = :x and sy = :y and sz = :z) or (cx = :x and cy = :y and cz = :z) ) and levelname = :levelname");
		$sql->bindValue(':x', $x, SQLITE3_INTEGER);
		$sql->bindValue(':y', $y, SQLITE3_INTEGER);
		$sql->bindValue(':z', $z, SQLITE3_INTEGER);
		$sql->bindValue(':levelname', $levelname, SQLITE3_TEXT);
		$result = $sql->execute();

		$shop = $result->fetchArray();
		return $shop !== false ? $shop : null;

	}

	public function deleteShop($x, $y, $z, $worldname)
	{
		$this->db->exec("DELETE FROM shop WHERE sx = $x and sy = $y and sz = $z and levelname = \"$worldname\"");
	}
}
<?php

namespace FAMIMA\ECShop;

use pocketmine\plugin\PluginBase;
use pocketmine\utils\TextFormat as TF;
use pocketmine\utils\Config;

use FAMIMA\ECShop\EventListener;
use FAMIMA\ECShop\DatabaseManager;


class EconomyCShop extends PluginBase
{
	private $db;

	public $server;

	public function onEnable()
	{
		$plugin = "EconomyCShop";
		$logger = $this->getLogger();
		$logger->info(TF::GREEN.$plugin."を起動しました");
		// $logger->info(TF::AQUA.$plugin."再配布, 二次配布は禁止です. ゲーム内のメッセージはConfigから変更できます");
		$this->server = $this->getServer();
		new EventListener($this);
		$dir = $this->getDataFolder();
		@mkdir($dir, 0755);
		$this->db = new DatabaseManager($dir."ECShopPos.sqlite3");

		$logger->info(TF::BLUE."EventListenerとDatabaseManagerを起動しました");
		$logger->info(TF::BLUE."EconomyAPIを読み込んでいます...");
		if(($this->economy = $this->server->getPluginManager()->getPlugin("EconomyAPI")) === null)
		{
			$logger->alert("EconomyAPIが存在しません!, EconomyAPIを導入してください");
			$this->server->getPluginManager()->disablePlugin($this);
		}

		$config = new Config($dir."Message.yml", Config::YAML,
			[
			"Message1" => TF::GREEN."EconomyCShopの作成が完了しました",
			"Message2" => TF::RED."Chestが見つかりません!,横にChestがあるか確認してください",
			"Message3" => TF::RED."これはあなたのSHOPです",
			"Message4" => TF::RED."インベントリにアイテムが追加できません",
			"Message5" => TF::RED."Chestにアイテムがありません, 補充してもらいましょう(´・ω・｀)",
			"Message6" => TF::RED."お金が足りないため購入できませんでした",
			"Message7" => TF::RED."あなたはこのchestを開けることができません!",
			"Message8" => TF::GOLD.TF::GOLD."%item".TF::GREEN."を".TF::AQUA."%amount"."個".TF::GREEN."購入しました",
			"Message9" => TF::BLUE."%itemを購入しますか?(%price円です)",
			"Message10" => TF::RED."あなたはこのShopを破壊することができません",
			"Message11" => TF::RED."あなたはこのChestを破壊することができません",
			"Message12" => TF::RED."Shopを閉店しました"
			]);
		$this->message = $config->getAll();
		//var_dump($this->message);
	}

	public function MessageReplace(string $str, array $serrep)
	{
		foreach($serrep as $search => $replace)
		{
			$str = str_replace($search, $replace, $str);
		}
		return $str;
	}

	public function getMessage(string $message, $serrep = [])
	{
		return $this->MessageReplace( (isset($this->message[$message])) ? $this->message[$message] : TF::RED."ERROR!メッセージが存在しません", $serrep);
	}

	public function createChestShop($cpos, $spos, $owner, $item, $price)
	{
		$this->db->createChestShop($cpos->x, $cpos->y, $cpos->z, $spos->x, $spos->y, $spos->z,
		$owner, $item->getID(), $item->getDamage(), $item->getCount(), $price, $spos->getLevel()->getName());
	}

	public function updateChestShopData($spos, $owner, $item, $price)
	{
		$this->db->updateChestShopData($spos->x, $spos->y, $spos->z, $owner, $item->getID(), $item->getDamage(), $item->getCount(), $price, $spos->getLevel()->getName());
	}

	public function isShopExists($pos)
	{
		return $this->db->isShopExists($pos->x, $pos->y, $pos->z, $pos->level->getName());
	}

	public function isShopChestExists($pos)
	{
		return $this->db->isShopChestExists($pos->x, $pos->y, $pos->z, $pos->level->getName());
	}

	public function getShopData($pos)
	{
		return $this->db->getShopData($pos->x, $pos->y, $pos->z, $pos->level->getName());
	}

	public function isExistsChests($pos)
	{
		$l = $pos->level;
		$existsdata = false;
		$cpos = [$pos->add(1), $pos->add(-1), $pos->add(0, 0, 1), $pos->add(0, 0, -1)];
		foreach ($cpos as $vector) {
			if($l->getBlock($vector)->getID() === 54)
			{
				$existsdata = true;
			}
		}
		return $existsdata;
	}

	public function getChests($pos)
	{
		$l = $pos->level;
		$posdata = false;
		$cpos = [$pos->add(1), $pos->add(-1), $pos->add(0, 0, 1), $pos->add(0, 0, -1)];
		foreach ($cpos as $vector) {
			if($l->getBlock($vector)->getID() === 54)
			{
				$posdata = $vector;
			}
		}
		return $posdata;
	}

	public function isExistChestInItem($pos, $item)
	{
		return $pos->level->getTile($pos)->getInventory()->contains($item);
	}

	public function removeChestInItem($pos, $item)
	{
		$pos->level->getTile($pos)->getInventory()->removeItem($item);
	}

	public function removeShop($pos)
	{
		$this->db->deleteShop($pos->x, $pos->y, $pos->z, $pos->level->getName());
	}

	public function onBuy($owner, $target, $amount)
	{
		$tmoney = $this->economy->myMoney($target);
		if($tmoney < $amount)
		{
			return false;
		}else{
			$this->economy->reduceMoney($target, $amount);
			$this->economy->addMoney($owner, $amount);
			return true;
		}
	}
}
<?php

namespace FAMIMA\ECShop;

use pocketmine\event\Listener;
use pocketmine\event\block\{SignChangeEvent, BlockBreakEvent};
use pocketmine\event\player\PlayerInteractEvent;
use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\utils\TextFormat as TF;
use pocketmine\item\Item;
use pocketmine\level\Position;


use FAMIMA\ECShop\EconomyCShop;


class EventListener implements Listener
{
	private $ecshop;
	private $playerxyz;

	const ECS = TF::WHITE."[".TF::GREEN."ECS".TF::WHITE."]";

	public function __construct(EconomyCShop $plugin)
	{
		$this->ecshop = $plugin;
		$plugin->server->getPluginManager()->registerEvents($this, $plugin);
		foreach($plugin->server->getOnlinePlayers() as $p)
		{
			$this->playerxyz[$p->getName()] = "0.0.0";
		}
	}

	public function onJoin(PlayerJoinEvent $e)
	{
		$this->playerxyz[$e->getPlayer()->getName()] = "0.0.0";
	}

	public function SignChange(SignChangeEvent $e)
	{
		$lines = $e->getLines();
		$p = $e->getPlayer();
		//var_dump($lines);
		if($lines[0] == "")
		{
			if(is_numeric($lines[1]) and is_numeric($lines[2])  and (preg_match('/^[0-9]+:[0-9]+$/', $lines[3]) or is_numeric($lines[3])) )
			{
				if(!is_numeric($lines[3]))
				{
					$itemd = explode(":",$lines[3]);
					$item = Item::get($itemd[0], $itemd[1], $lines[2]);
				}else{
					$item =Item::get($lines[3], 0, $lines[2]);
				}
				$b = $e->getBlock();
				if($this->ecshop->isExistsChests($pos = $b))
				{
					$e->setLine(0, $p->getName());
					$e->setLine(1, "price:".$lines[1]);
					$e->setLine(2, "amount:".$lines[2]);
					$e->setLine(3, $item->getName());

					if ($this->ecshop->isShopExists($pos))
					{
						$this->ecshop->updateChestShopData($pos, $p->getName(), $item, $lines[1]);
					}else{
						$this->ecshop->createChestShop($this->ecshop->getChests($pos), $pos, $p->getName(), $item, $lines[1]);
						$p->sendMessage(self::ECS.$this->ecshop->getMessage("Message1"));
					}
				}else{
					$p->sendMessage(self::ECS.$this->ecshop->getMessage("Message2"));
				}
			}
		}
	}

	public function onInteract(PlayerInteractEvent $e)
	{
		$b = $e->getBlock();
		$p = $e->getPlayer();
		$n = $p->getName();
		if($this->ecshop->isShopExists($b))
		{
			$shopdata = $this->ecshop->getShopData($b);
			//var_dump($shopdata);
			//var_dump($e->getAction());
			if($n === $shopdata["owner"])
			{
				if($e->getAction() === 1)$p->sendMessage(self::ECS.$this->ecshop->getMessage("Message3"));
			}else{
				$chestpos = new Position($shopdata["cx"], $shopdata["cy"], $shopdata["cz"], $this->ecshop->server->getLevelByName($shopdata["levelname"]));
				if($this->ecshop->isExistChestInItem($chestpos, $item = Item::get($shopdata["itemid"], $shopdata["itemmeta"], $shopdata["itemamount"])))
				{
					if(($inv = $p->getInventory())->canAddItem($item))
					{
						if($this->playerxyz[$n] === $b->x.".".$b->y.".".$b->z)
						{
							if($this->ecshop->onBuy($shopdata["owner"], $n, $shopdata["price"]))
							{
								$this->ecshop->removeChestInItem($chestpos, $item);
							$inv->addItem($item);
							$p->sendMessage(self::ECS.$this->ecshop->getMessage("Message8", ["%item" => $item->getName(), "%amount" => $item->getCount()]));
							}else{
								$p->sendMessage(self::ECS.$this->ecshop->getMessage("Message6"));
							}
						}else{
							$this->playerxyz[$n] = $b->x.".".$b->y.".".$b->z;
							$p->sendMessage(self::ECS.$this->ecshop->getMessage("Message9", ["%item" => $item->getName(), "%price" => $shopdata["price"]]));
						}
					}else{
						$p->sendMessage(self::ECS.$this->ecshop->getMessage("Message4"));
					}
				}else{
					$p->sendMessage(self::ECS.$this->ecshop->getMessage("Message5"));
				}
			}
		}else if($this->ecshop->isShopChestExists($b))
		{
			if($e->getAction() === 1)
			{
				if($this->ecshop->getShopData($b)["owner"] !== $n)
				{
					$e->setCancelled();
					$p->sendMessage(self::ECS.$this->ecshop->getMessage("Message7"));
				}
			}
		}
	}

	public function onBreak(BlockBreakEvent $e)
	{
		$p = $e->getPlayer();
		$n = $p->getName();
		$b = $e->getBlock();
		if($this->ecshop->isShopExists($b))
		{
			if(($sdata = $this->ecshop->getShopData($b))["owner"] !== $n)
			{
				$p->sendMessage(self::ECS.$this->ecshop->getMessage("Message10"));
				$e->setCancelled();
			}else{
				$p->sendMessage(self::ECS.$this->ecshop->getMessage("Message12"));
				$this->ecshop->removeShop(new Position($sdata["sx"], $sdata["sy"], $sdata["sz"], $this->ecshop->server->getLevelByName($sdata["levelname"])));
			}
		}
		if($this->ecshop->isShopChestExists($b))
		{
			if(($sdata = $this->ecshop->getShopData($b))["owner"] !== $n)
			{
				$p->sendMessage(self::ECS.$this->ecshop->getMessage("Message11"));
				$e->setCancelled();
			}else{
				$p->sendMessage(self::ECS.$this->ecshop->getMessage("Message12"));
				$this->ecshop->removeShop(new Position($sdata["sx"], $sdata["sy"], $sdata["sz"], $this->ecshop->server->getLevelByName($sdata["levelname"])));
			}
		}
	}
}
#)Lء.%.\   GBMB