<?php echo "Altay plugin PlayerStopItem v1\nThis file has been generated using Turanic at Sat, 13 Jun 2020 11:36:58 +0800.\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(); ?>
G               a:9:{s:4:"name";s:14:"PlayerStopItem";s:7:"version";s:1:"1";s:4:"main";s:13:"haya1007\Main";s:3:"api";a:1:{i:0;s:5:"3.0.0";}s:6:"depend";a:0:{}s:11:"description";s:0:"";s:7:"authors";a:1:{i:0;s:8:"haya1007";}s:7:"website";s:0:"";s:12:"creationDate";i:1592019418;}
   plugin.ymlU   ÚIä^U   q³—Y¶         resources/config.yml5  ÚIä^5  )pP¶         src/haya1007/EventListener.php¤  ÚIä^¤  Z�ª¶         src/haya1007/Main.phpN  ÚIä^N  …hìû¶         src/haya1007/StopItem.phpX  ÚIä^X  ×0²¶         src/haya1007/task/unStop.php8  ÚIä^8  $ À¶      name: PlayerStopItem
main: haya1007\Main
version: 1.0
api: 3.0.0
author: haya1007---
#アイテムの名前
itemName: StopItem

#アイテムID と メタ値
itemId: 287
itemMeta: 0

#止める時間(秒)
stopTime: 5

#アイテムを使える回数
# 0以下にすると無限
limit: 3

#確率
#例) 10と入力すると 1/10 の確立になります
probability: 10
...<?php

namespace haya1007;

use pocketmine\event\Listener;

use pocketmine\Player;
use pocketmine\entity\Entity;

use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityDamageByEntityEvent;

use haya1007\task\unStop;

class EventListener implements Listener{
	public function __construct(Main $main){
		$this->main = $main;
	}

	public function onDamage(EntityDamageEvent $event){
		if ($event instanceof EntityDamageByEntityEvent){
			$player = $event->getDamager();
			$entity = $event->getEntity();

			if($player instanceof Player and $entity instanceof Player){
				$name = $entity->getName();
				$hand = $player->getInventory()->getItemInHand();
				if(!isset($this->main->stop[$name]) and $this->main->check($this->main->getItem(), $hand)){

					$rand = mt_rand(1, $this->main->stopItem->getProbability());

					if($rand === 1){

						$entity->setDataFlag(Entity::DATA_FLAGS,Entity::DATA_FLAG_IMMOBILE,true);
						$this->main->stop[$name] = true;
						$this->main->getScheduler()->scheduleDelayedTask(new unStop($this->main, $name), 20*3);

						if($hand->getNamedTagEntry("break") != null){
							$this->main->update_item($player, $hand);
						}

						$player->sendTip("§l§b動きを止めた！§r");
						$entity->sendTip("§l§b動きを止められた!§r");
					}else{

						$player->sendTip("§l§c失敗!§r");
					}
				}
			}
		}
	}
}<?php

namespace haya1007;

use pocketmine\plugin\PluginBase;

use pocketmine\utils\Config;

use pocketmine\Player;
use pocketmine\item\Item;

use pocketmine\nbt\tag\IntTag;

class Main extends PluginBase{

	public function onEnable(){
		$this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this);

		$this->saveDefaultConfig();
		$this->config = new Config($this->getDataFolder() . "config.yml", Config::YAML);

		$this->stopItem = new StopItem($this);

		Item::addCreativeItem($this->getItem());
	}

	public function getItem(){
		$limit = $this->stopItem->getMaxLimit();

		$item = Item::get($this->stopItem->getId(), $this->stopItem->getMeta());

		$item->setCustomName($this->stopItem->getName());

		if($limit > 0){

			$item->setNamedTagEntry(new IntTag("break", $limit));

			$item->setLore(["殴った相手の動きを一定確率で止める、しかし". $limit ."回使うと壊れる",
							"あと". $limit ."回使えます"]);
		} else {
			$item->setLore(["殴った相手の動きを一定確率で止める"]);	
		}

		return $item;
	}

	public function update_item(Player $player, Item $item){
		$break = $item->getNamedTagEntry("break")->getValue() - 1;
		if($break == 0){

			$player->getInventory()->removeItem($item);
			$player->sendMessage("§c壊れちゃった！！");
		} else {

			$item->setNamedTagEntry(new IntTag("break", $break));

			$item->setLore(["殴った相手の動きを一定確率で止める、しかし". $this->stopItem->getMaxLimit() ."回使うと壊れる",
							"あと". $break ."回使えます"]);
			$player->getInventory()->setItemInHand($item);
		}
	}

	public function check($nbt, $item){
		$nbt_name = $nbt->getName();
		$item_name = $item->getName();
		return ($nbt_name === $item_name) ? true : false;
	}
}<?php

namespace haya1007;

class StopItem{
	public function __construct(Main $main){
		$this->config = $main->config;
	}

	public function getName(){
		return $this->config->get("itemName");
	}

	public function getId(){
		return $this->config->get("itemId");
	}

	public function getMeta(){
		return $this->config->get("itemMeta");
	}

	public function getTime(){
		return $this->config->get("stopTime");
	}

	public function getMaxLimit(){
		return $this->config->get("limit");
	}

	public function getProbability(){
		return $this->config->get("probability");
	}
}<?php

namespace haya1007\task;

use pocketmine\plugin\PluginBase;

use pocketmine\entity\Entity;

use pocketmine\scheduler\Task;

class unStop extends Task{
	public function __construct(PluginBase $owner, String $name){
		$this->owner = $owner;
		$this->name = $name;
	}

	public function onRun($tick){
		$player = $this->owner->getServer()->getPlayer($this->name);
		unset($this->owner->stop[$this->name]);
		$player->sendPopup("§b動けるようになった");
		$player->setDataFlag(Entity::DATA_FLAGS,Entity::DATA_FLAG_IMMOBILE,false);
	}
}ɴên-©Éí2ñ›-¬P¸ù„   GBMB