<?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