
<?php
echo "PocketMine-MP plugin ReportSystem v1.0.0
This file has been generated using DevTools v1.13.0 at Fri, 03 Apr 2020 22:02:07 +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(); ?>
               a:9:{s:4:"name";s:12:"ReportSystem";s:7:"version";s:5:"1.0.0";s:4:"main";s:21:"smo\ReportSystem\Main";s:3:"api";s:6:"3.11.6";s:6:"depend";s:0:"";s:11:"description";s:12:"ReportSystem";s:7:"authors";s:0:"";s:7:"website";s:0:"";s:12:"creationDate";i:1585918927;}
   plugin.ymlÓ   Ï3‡^Ó   ÒU¶      /   src/smo/ReportSystem/command/CommandManager.phpB  Ï3‡^B  ;-¶      .   src/smo/ReportSystem/command/ReportCommand.php  Ï3‡^  ²و¶      2   src/smo/ReportSystem/command/ReportlistCommand.php  Ï3‡^  †gª¶      &   src/smo/ReportSystem/ConfigManager.php(  Ï3‡^(  µ Yƶ      -   src/smo/ReportSystem/form/CheckReportForm.phpÎ  Ï3‡^Î  "—(&¶      1   src/smo/ReportSystem/form/CheckReportListForm.php  Ï3‡^  Šòõ¶      2   src/smo/ReportSystem/form/RemoveReportListForm.phpB  Ï3‡^B  WJÚè¶      (   src/smo/ReportSystem/form/ReportForm.phpb  Ï3‡^b  ¤zR¶      ,   src/smo/ReportSystem/form/ReportlistForm.phpp  Ï3‡^p  *�¾’¶         src/smo/ReportSystem/Main.php­  Ï3‡^­  w@†í¶      name: ReportSystem

main: smo\ReportSystem\Main

version: 1.0.0

api: 3.11.6

load: POSTWORLD

author: smo

description: ReportSystem

permissions:
 
 report.guest:
  default: true

 reportlist.op:
  default: op<?php

declare(strict_types=1);

namespace smo\ReportSystem\command;

class CommandManager{

	public function __construct($plugin){

		$plugin->getServer()->getCommandMap()->register("report", new ReportCommand());
		$plugin->getServer()->getCommandMap()->register("reportlist", new ReportlistCommand());
	}
}<?php

declare(strict_types=1);

namespace smo\ReportSystem\command;

use pocketmine\command\{Command, CommandSender};
use pocketmine\Player;

use smo\ReportSystem\form\ReportForm;

class ReportCommand extends Command{

	public function __construct(){

		parent::__construct("report", "プレイヤーをレポートします", "/report");
		$this->setPermission("report.guest");
	}

	public function execute(CommandSender $sender, string $commandLabel, array $args){

		if(!$this->testPermission($sender)){
            return false;
        }

        if(!$sender instanceof Player){
        	$sender->sendMessage("§c>> ゲーム内で実行してください");
        	return;
        }

        $sender->sendForm(new ReportForm());
	}
}<?php

declare(strict_types=1);

namespace smo\ReportSystem\command;

use pocketmine\command\{Command, CommandSender};
use pocketmine\Player;

use smo\ReportSystem\form\ReportlistForm;

class ReportlistCommand extends Command{

	public function __construct(){

		parent::__construct("reportlist", "レポートを確認します", "/reportlist");
		$this->setPermission("reportlist.op");
	}

	public function execute(CommandSender $sender, string $commandLabel, array $args){

		if(!$this->testPermission($sender)){
            return false;
        }

        if(!$sender instanceof Player){
        	$sender->sendMessage("§c>> ゲーム内で実行してください");
        	return;
        }

        $sender->sendForm(new ReportlistForm());
	}
}<?php

declare(strict_types=1);

namespace smo\ReportSystem;

use pocketmine\utils\Config;
use pocketmine\Player;

class ConfigManager{

	private $config;
	private $plugin;
	private static $instance = null;

	public function __construct($plugin){

		$this->config = new Config($plugin->getDataFolder() . "Config.yml", Config::YAML,[

			"CanUseID" => 1
		]);
		$this->plugin = $plugin;
		self::$instance = $this;

		date_default_timezone_set("Asia/Tokyo");
	}

	public static function get(): self {

		return self::$instance;
	}

	public function saveConfig(): void {

		if($this->config === null) return;

		$this->config->save();
		$this->plugin->getLogger()->notice("Configをセーブしました");
	}

	public function addReport(Player $sender, string $name, string $reason): void {

		$date = (new \DateTime())->format("Y年n月j日 G時i分s秒");
		$id = $this->config->get("CanUseID");
		$this->config->set("CanUseID", $id + 1);

		$this->config->set($id,[

			"報告者" => $sender->getName(),
			"対象者" => $name,
			"理由" => $reason,
			"時間" => $date
		]);

		$sender->sendMessage("§a>> 報告しました。ありがとうございました。");
	}

	public function removeReport(int $id, Player $sender): void {

		if(!$this->config->exists($id)){
			$sender->sendMessage("§c>> ID: ".$id." のレポートは存在しません");
			return;
		}

		$this->config->remove($id);
		$sender->sendMessage("§a>> ID: ".$id." のレポートを削除しました");
	}

	public function getData(int $id): ?array {

		if(!$this->config->exists($id)){
			return null;
		}

		return $this->config->get($id);
	}

	public function getAll(): array {

		$all = $this->config->getAll();
		unset($all["CanUseID"]);

		return $all;
	}
}<?php

namespace smo\ReportSystem\form;

use pocketmine\form\Form;
use pocketmine\Player;

use smo\ReportSystem\ConfigManager;

class CheckReportForm implements Form{

    private $id;

    public function __construct(int $id){

         $this->id = $id;
    }

    public function handleResponse(Player $player, $data): void {

       return;
    }

    public function jsonSerialize(){

        $data = ConfigManager::get()->getData($this->id);
        $senderName = $data["報告者"];
        $name = $data["対象者"];
        $reason = $data["理由"];
        $date = $data["時間"];

        $content = "ID {$this->id} のレポート:\n\n報告者: {$senderName} \n対象者: {$name} \n理由: {$reason} \n時間: {$date} \n\n";

        return [
            "type" => "form",
            "title" => "レポート確認",
            "content" => $content,
            "buttons" => [["text" => "終了"]]
        ];
    }
}<?php

namespace smo\ReportSystem\form;

use pocketmine\form\Form;
use pocketmine\Player;

use smo\ReportSystem\ConfigManager;

class CheckReportListForm implements Form{

    private $button;
    private $list;

    private $isEmpty = false;

    public function __construct(){

         if(count(ConfigManager::get()->getAll()) === 0){
            $this->isEmpty = true;
            return;
        }

        foreach(ConfigManager::get()->getAll() as $id => $data){
            $this->button[] = ["text" => "ID: ". (string) $id];
            $this->list[] = $id;
        }
    }

    public function handleResponse(Player $player, $data): void {

        if ($data === null) {
            return;
        }

        $player->sendForm(new CheckReportForm( (int) $this->list[$data]));
    }

    public function jsonSerialize(){

        if($this->isEmpty){
            return [
            "type" => "form",
            "title" => "レポート確認",
            "content" => "レポートがありません",
            "buttons" => []
            ];
        }

        return [
            "type" => "form",
            "title" => "レポート確認",
            "content" => "",
            "buttons" => $this->button
        ];
    }
}<?php

namespace smo\ReportSystem\form;

use pocketmine\form\Form;
use pocketmine\Player;

use smo\ReportSystem\ConfigManager;

class RemoveReportListForm implements Form{

    private $button;
    private $list;

    private $isEmpty = false;

    public function __construct(){

        if(count(ConfigManager::get()->getAll()) === 0){
            $this->isEmpty = true;
            return;
        }

        foreach(ConfigManager::get()->getAll() as $id => $data){
            $this->button[] = ["text" => "ID: ". (string) $id];
            $this->list[] = $id;
        }
    }

    public function handleResponse(Player $player, $data): void {

        if($this->isEmpty) return;

        if ($data === null) {
            return;
        }

        ConfigManager::get()->removeReport((int) $this->list[$data], $player);

    }

    public function jsonSerialize(){

        if($this->isEmpty){
            return [
            "type" => "form",
            "title" => "レポート削除",
            "content" => "レポートがありません",
            "buttons" => []
            ];
        }

        return [
            "type" => "form",
            "title" => "レポート削除",
            "content" => "",
            "buttons" => $this->button
        ];
    }
}<?php

namespace smo\ReportSystem\form;

use pocketmine\form\Form;
use pocketmine\Player;

use smo\ReportSystem\ConfigManager;

class ReportForm implements Form{

    public function handleResponse(Player $player, $data): void {

        if ($data === null) {
            return;
        }

        if($data[0] === "" or $data[1] === "") return;

        ConfigManager::get()->addReport($player, $data[0], $data[1]);
    }

    public function jsonSerialize(){

        return [
            "type" => "custom_form",
            "title" => "レポート",
            "content" => [
                [
                    "type" => "input",
                    "text" => "レポートするプレイヤーの名前",
                    "placeholder" => "ここに記入",
                    "default" => ""
                ],

                [
                    "type" => "input",
                    "text" => "レポート理由",
                    "placeholder" => "ここに記入",
                    "default" => ""
                ]
            ]
        ];
    }
}<?php

namespace smo\ReportSystem\form;

use pocketmine\form\Form;
use pocketmine\Player;

use smo\ReportSystem\ConfigManager;

class ReportlistForm implements Form{

    public function handleResponse(Player $player, $data): void {

        if ($data === null) {
            return;
        }

        switch ($data) {
        	case 0:

        	$player->sendForm(new CheckReportListForm());

        	break;

        	case 1:

        	$player->sendForm(new RemoveReportListForm());

        	break;
        }
    }

    public function jsonSerialize(){

        return [
            "type" => "form",
            "title" => "レポート確認",
            "content" => "",
            "buttons" => [
                ["text" => "レポート確認"],
                ["text" => "レポート削除"]
            ]
        ];
    }
}<?php

declare(strict_types=1);

namespace smo\ReportSystem;

use pocketmine\plugin\PluginBase;

use smo\ReportSystem\command\CommandManager;

class Main extends PluginBase{

	public function onEnable(): void {

		$this->getLogger()->notice("ReportSystem を読み込みました");
		(new ConfigManager($this));
		(new CommandManager($this));
	}

	public function onDisable(): void {

		ConfigManager::get()->saveConfig();
	}
}
¬ŠBS;Ÿ{¼ö`¿Ägd£~€   GBMB