
<?php
echo "PocketMine-MP plugin old v1.0.0
This file has been generated using DevTools v1.13.0 at Sat, 30 May 2020 12:01:56 +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(); ?>
R                a:9:{s:4:"name";s:3:"old";s:7:"version";s:5:"1.0.0";s:4:"main";s:8:"old\Main";s:3:"api";s:5:"3.0.0";s:6:"depend";s:0:"";s:11:"description";s:4:"unko";s:7:"authors";s:0:"";s:7:"website";s:0:"";s:12:"creationDate";i:1590807716;}
   plugin.ymlX   ^X   U         src/old/Callback.php  ^  E;      "   src/old/command/SettingCommand.php9  ^9  Ս         src/old/data/Data.php  ^           src/old/EventListener.php  ^  [Ϭ         src/old/form/SettingForm.php  ^  8l         src/old/Main.php  ^  :ȶ      name: old
main: old\Main 
version: 1.0.0
api: 3.0.0
author: tinko
description: unko<?php
namespace old;
use pocketmine\scheduler\Task;
class Callback extends Task{

	public function __construct(callable $callable, array $args = []){
		$this->callable = $callable;
		$this->args = $args;
		$this->args[] = $this;
	}

	public function getCallable(){
		return $this->callable;
	}

	public function onRun($currentTicks){
		call_user_func_array($this->callable, $this->args);
	}

}<?php

namespace old\command;

use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\command\utils\CommandException;

use old\form\SettingForm;

class SettingCommand extends Command {

	private $plugin;

	public function __construct($plugin)
	{
		parent::__construct("setting","設定用フォーム","/setting");
		$this->plugin = $plugin;
	}

	public function execute(CommandSender $sender, string $label, array $args) 
	{
		if(!$sender->isOP()) return;
		$sender->sendForm(new SettingForm($this->plugin));
	}
}<?php

namespace old\data;

use pocketmine\utils\Config;

class Data extends Config {

	/*Mainオブジェクト*/
	private $plugin;

	public function __construct($plugin)
	{
		$this->plugin = $plugin;
		parent::__construct($this->plugin->getDataFolder() . "Data.yml", Config::YAML);
		if (!(file_exists($this->plugin->getDataFolder()))) @mkdir($this->plugin->getDataFolder(), 0777);
		new Config($this->plugin->getDataFolder()."data.yml",Config::YAML,array(
			'run' => false,
			'food' => false,
		));
	}

	public function setTrue($data)
	{
		$this->set($data,true);
	}

	public function setFalse($data)
	{
		$this->set($data,false);
	}
}<?php

namespace old;

use pocketmine\event\Listener;
use pocketmine\event\player\PlayerItemConsumeEvent;

class EventListener implements Listener {

	/*Mainオブジェクト*/
	private $plugin;

	public function __construct($plugin)
	{
		$this->plugin = $plugin;
	}

	public function onItemConsume(PlayerItemConsumeEvent $event)
	{
		$this->plugin->setHealth($event->getPlayer());
	}


}<?php

namespace old\form;

use old\Main;
use pocketmine\Player;
use pocketmine\form\Form;

class SettingForm implements Form {

	private $plugin;

	public function __construct($plugin)
	{
		$this->plugin = $plugin;

	}

	public function handleResponse($player,$data): void
	{
		if($data === null) return;

		switch($data[0])
		{
			case true:
			$this->plugin->data->setTrue('run');
			break;

			case false;
			$this->plugin->data->setFalse('run');
			break;

		}

		switch($data[1])
		{
			case true:
			$this->plugin->data->setTrue('food');
			break;

			case false:
			$this->plugin->data->setFalse('food');
			break;
		}

		$this->plugin->data->save();
		$this->plugin->setHunger();
		$this->plugin->setHungerForFood();
	}

	public function jsonSerialize()
	{
		return [

			'type' => 'custom_form',
            'title' => '設定用フォーム',
            'content' => [

            	[
            		'type' => 'toggle',
            	    'text' => '走れない機能'
			    ],
			    [
			    	'type' => 'toggle',
			        'text' => '直接回復できる機能',
			    ]
			]
		];
	}
}<?php

namespace old;

use pocketmine\plugin\PluginBase;

use old\data\Data;

use pocketmine\Player;
use pocketmine\item\Item;

use old\command\SettingCommand;

class Main extends PluginBase {

	/*データ*/
	public $data;

	public function onEnable()
	{
		$this->getServer()->getPluginManager()->registerEvents(new EventListener($this),$this);
		$this->getServer()->getCommandMap()->register("setting",new SettingCommand($this));
		$this->data = new Data($this);
		$this->setHungerForFood();
		$this->setHunger();
	}

	public function setHealth($player)
	{
		if($this->data->get('food') === false) return;

		switch($player->getInventory()->getItemInHand()->getId())
		{			/*1ハート = 4*/
			case 260: //apple
			$player->setHealth($player->getHealth() + 4);
			break;

			case 393: //BakedPotato
			$player->setHealth($player->getHealth() + 8);
			break;

			case 297: //bread
			$player->setHealth($player->getHealth() + 4);
			break;

			case 391: //carrot
			$player->setHealth($player->getHealth() + 4);
			break;

			case 364: //stake
			$player->setHealth($player->getHealth() + 8);
			break;

			case 360: //melon
			$player->setHealth($player->getHealth() + 2);
			break;
		}

	}

	public function setHunger()
	{
		if($this->data->get('run') === false) return;
		if($this->getServer()->getOnlinePlayers() >= 1){
			foreach($this->getServer()->getOnlinePlayers() as $players){
				$players->setFood(1);
			}
		}				

		$this->getScheduler()->scheduleDelayedTask(new Callback([$this,'setHunger'],[]), 20);
	}

	public function setHungerForFood()
	{
		if($this->data->get('food') === false) return;
		if($this->getServer()->getOnlinePlayers() >= 1){
			foreach($this->getServer()->getOnlinePlayers() as $players){
				$players->setFood(9);
			}
		}				

		$this->getScheduler()->scheduleDelayedTask(new Callback([$this,'setHungerForFood'],[]), 20);

	}

}BEm:A_?+S   GBMB