
<?php
echo "PocketMine-MP plugin Voting v0.0.1
This file has been generated using DevTools v1.13.0 at Tue, 09 Jul 2019 17:27:30 +0930
----------------
";

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:6:"Voting";s:7:"version";s:5:"0.0.1";s:4:"main";s:19:"tatchan\Voting\Main";s:3:"api";s:5:"3.8.5";s:6:"depend";s:0:"";s:11:"description";s:0:"";s:7:"authors";s:0:"";s:7:"website";s:0:"";s:12:"creationDate";i:1562659050;}
   plugin.ymlÑ  êH$]Ñ  <ôq¶         src/tatchan/Voting/Main.phpê  êH$]ê  ”$P¶      #Name of your plugin. This is self-explanatory. Plugin names SHOULD NOT contain spaces.
name: Voting

#Fully-qualified class-name of your plugin's main class. This is usually the one that extends PluginBase.
#Since PocketMine-MP's autoloader is PSR-0, your plugin's main-class namespace will usually be the same as the folder path.
main: tatchan\Voting\Main

#Version name/number of your plugin
version: 0.0.1

#API version that your plugin supports. If your plugin's API is not compatible with that of the server, the server will refuse to load your plugin.
#The API version is changed when:
# - Breaking changes are made to a development version, things that might cause your plugin to crash.
#     This is denoted by an API suffix, for example 3.0.0-ALPHA4. If the version does not match as a whole on a development version, the plugin will not be loaded. (Suffixes are non-case-sensitive.)
# - Breaking changes are made to a release version, things that might cause your plugin to crash.
#     This usually warrants a major API bump, e.g. 2.0.0 -> 3.0.0. If the major version does not match, the plugin will not be loaded.
# - Feature additions which do not break existing plugins.
#     This is denoted by a minor API bump, e.g. 2.0.0 -> 2.1.0. The server will load plugins with an equivalent or older minor version.
# - Minor bug fixes or insignificant alterations to the API.
#     This is denoted by a patch bump, e.g. 1.13.0 -> 1.13.1
api: 3.8.5

#When to load the plugin. There are currently two options for this: STARTUP and POSTWORLD. Usually POSTWORLD will do fine.
load: POSTWORLD

#Name of the person who wrote the plugin. This can be anything you like.
author: tatchan

#Simple description of what the plugin is or does. Try to keep this short.oved if your plugin will not have any commands.
commands:

 vote:
  #Description to show in the Help command
  default: true
  description: "投票するためのformを出すよ"
  #Usage message shown to the user if they type the command in incorrectly.
 setvote:
  default: false
  description: "投票をセットするためのformを出すよ"
  
 vlist:
  default: false
  description: "投票の状態を出すよ"

 reset:
  default: false
  description: "投票をリセットするよ"
<?php


namespace tatchan\Voting;
use Frago9876543210\EasyForms\forms\CustomFormResponse;
use pocketmine\utils\Config;
use Frago9876543210\EasyForms\forms\ModalForm;
use Frago9876543210\EasyForms\forms\MenuForm;
use Frago9876543210\EasyForms\forms\CustomForm;
use pocketmine\plugin\PluginBase;
use pocketmine\command\CommandSender;
use pocketmine\command\Command;
use pocketmine\network\mcpe\protocol\ModalFormResponsePacket;
use pocketmine\network\mcpe\protocol\ModalFormRequestPacket;
use pocketmine\event\server\DataPacketReceiveEvent;
use Frago9876543210\EasyForms\elements\Button;
use Frago9876543210\EasyForms\elements\Image;
use Frago9876543210\EasyForms\elements\Dropdown;
use Frago9876543210\EasyForms\elements\Input;
use Frago9876543210\EasyForms\elements\Slider;
use Frago9876543210\EasyForms\elements\Toggle;
use pocketmine\Player;
use Frago9876543210\EasyForms\elements\Label;
use Frago9876543210\EasyForms\elements\StepSlider;
use Frago9876543210\EasyForms\elements\GameMode;
class Main extends PluginBase{

	public function onEnable() : void{
		$this->formId = 00001;
		$this->getLogger()->info("Hello World!");

//キーが設定されているConfigの作成
$this->list = new Config($this->getDataFolder() . "list.yml", Config::YAML);

$this->player = new Config($this->getDataFolder() . "player.yml", Config::YAML);

$this->config = new Config($this->getDataFolder() . "config.yml", Config::YAML, array(
'プレイヤー1' => 'name',
'プレイヤー2' => 'name',
'プレイヤー3' => 'name',
'プレイヤー4' => 'name',
'プレイヤー5' => 'name',
'状態' => 'true of false',
));
}

	public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool{
		switch($command->getName()){
case "setvote":
$player = $sender;
$sender->sendForm(new CustomForm("§e～～～投票セットアップ～～～",
	[	
		new Input("プレイヤー1", $this->config->get("プレイヤー1")),
		new Input("プレイヤー2", $this->config->get("プレイヤー2")),
		new Input("プレイヤー3", $this->config->get("プレイヤー3")),
		new Input("プレイヤー4", $this->config->get("プレイヤー4")),
		new Input("プレイヤ5", $this->config->get("プレイヤー5")),
		new Toggle("投票状態", $this->config->get("状態")),
	],
	function(Player $player, CustomFormResponse $response) : void{
		list($player1, $player2, $player3, $player4,$player5,$enableCreative) = $response->getValues();
		$this->config->set("プレイヤー1",$player1);
		$this->config->set("プレイヤー2",$player2);
		$this->config->set("プレイヤー3",$player3);
		$this->config->set("プレイヤー4",$player4);
		$this->config->set("プレイヤー5",$player5);
		$enableCreative ? $this->config->set("状態",true) : $this->config->set("状態",false);


	}
));
return true;

case "vlist":
	$data = [
           "type" => "custom_form",
           "title" => "§a～～～投票結果～～～",
           "content" => [
           	[
           	"type" => "label",
           	"text" => "
{$this->config->get("プレイヤー1")}:{$this->list->get($this->config->get("プレイヤー1"))}
{$this->config->get("プレイヤー2")}:{$this->list->get($this->config->get("プレイヤー2"))}
{$this->config->get("プレイヤー3")}:{$this->list->get($this->config->get("プレイヤー3"))}
{$this->config->get("プレイヤー4")}:{$this->list->get($this->config->get("プレイヤー4"))}
{$this->config->get("プレイヤー5")}:{$this->list->get($this->config->get("プレイヤー5"))}"

           ],
       ]
          
    ];

    $pk = new ModalFormRequestPacket();
    $pk->formId = $this->formId;
    $pk->formData = json_encode($data);
    $sender->dataPacket($pk);
				return true;
case "reset":

$this->config->set("状態", false);
$all = $this->list->getAll(true);
$all2 = $this->player->getALL(true);

foreach($all as $key){ 
$this->list->remove($key); 
$this->list->save(); 
}

foreach($all2 as $key){ 
$this->player->remove($key); 
$this->player->save(); 
}
$sender->sendMessage("投票をリセットしました");
return true;
			case "vote":
			if($this->config->get("状態") == "ture"){
				$name = $sender->getPlayer()->getName();
    if(!$this->player->exists($name)){
    	  $this->player->set($name,true);
        $this->player->save();
			$player = $sender;
$sender->sendForm(new MenuForm(
	"§a～～～投票フォーム～～～", "§c投票したい人を選んでね", [new Button($this->config->get("プレイヤー1")), new Button($this->config->get("プレイヤー2")), new Button($this->config->get("プレイヤー3")),new Button($this->config->get("プレイヤー4")), new Button($this->config->get("プレイヤー5"))], 
	function(Player $player, Button $selected) : void{
		$player->sendMessage($selected->getText() . "に投票しました");
$text = $selected->getText();
 if(!$this->list->exists($text)){
    	  $this->list->set($text,1);
        $this->list->save();
}else{
	  $this->list->set($text,$this->list->get($text) + 1);
        $this->list->save();
}
}
));
return true;
}else{
$sender->sendMessage("§eあなたはもう投票済みです");
return true;
}
}else{
$sender->sendMessage("§c投票を開始していません");
return true;
}

}
}

	public function onDisable() : void{
		$this->getLogger()->info("投票PLを終了します");
	}
}
J‚­´†§êã‚Yæñ.||E   GBMB