<?php echo 'Phar compiled on https://pmt.mcpe.fun.'; __HALT_COMPILER(); ?>
               a:9:{s:4:"main";s:35:"jp\mazaicrafty\pmmp\NoOP_NoFly\Main";s:4:"name";s:10:"NoOP_NoFLY";s:7:"version";s:5:"1.0.5";s:3:"api";a:3:{i:0;s:13:"3.0.0-ALPHA10";i:1;s:13:"3.0.0-ALPHA11";i:2;s:13:"3.0.0-ALPHA12";}s:6:"author";s:11:"MazaiCrafty";s:7:"website";s:30:"https://github.com/MazaiCrafty";s:4:"load";s:9:"POSTWORLD";s:11:"description";s:0:"";s:8:"commands";a:1:{s:6:"nopfly";a:3:{s:11:"description";s:29:"NoOP NoFly <true/false/query>";s:5:"usage";s:39:"/nopfly <on/true || off/false || query>";s:10:"permission";s:6:"nopfly";}}}+   src/jp/mazaicrafty/pmmp/NoOP_NoFly/Main.php}  Z}  ?E~      
   plugin.yml|  Z|  X&      <?php

/*
 * ___  ___               _ _____            __ _         
 * |  \/  |              (_)  __ \          / _| |        
 * | .  . | __ _ ______ _ _| /  \/_ __ __ _| |_| |_ _   _ 
 * | |\/| |/ _` |_  / _` | | |   | '__/ _` |  _| __| | | |
 * | |  | | (_| |/ / (_| | | \__/\ | | (_| | | | |_| |_| |
 * \_|  |_/\__,_/___\__,_|_|\____/_|  \__,_|_|  \__|\__, |
 *                                                   __/ |
 *                                                  |___/
 * Copyright (C) 2017-2018 @MazaiCrafty (https://twitter.com/MazaiCrafty)
 *
 * This program is free plugin.
 */

namespace jp\mazaicrafty\pmmp\NoOP_NoFly;

# Base
use pocketmine\plugin\PluginBase;
use pocketmine\Server;
use pocketmine\Player;

# Events
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerToggleFlightEvent;

# Commands
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\command\CommandExecuter;
use pocketmine\command\ConsoleCommandSender;

# Utils
use pocketmine\utils\TextFormat as COLOR;
use pocketmine\utils\Config;

class Main extends PluginBase implements Listener{

    const PREFIX = "§a[§dNoOP NoFly§a]§r ";
    const VERSION = "1.0.5";

    public function onLoad(): void{
    }
    
    public function onEnable(): void{
        $this->allRegisterEvents();
        $this->messageA();

        $this->Config = new Config($this->getDataFolder() . "Config.yml", Config::YAML, array(
            "FLYKICK" => true,
            "BROADCAST" => "§a%PLAYER%§bから不正なFlyを検知したため、キックを実行しました。",
            "KICKMESSAGE" => "§a不正なFlyを検知したのでキックを実行しました"
        ));
        $this->query();
    }

    public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool{
        /*
        if (!$sender instanceof Player){
            $sender->sendMessage(self::PREFIX . COLOR::RED . "Please use this in-game.");
            return true;
        }
        */

        
        if (!$sender->isOp()){
            $sender->sendMessage(self::PREFIX . COLOR::RED . "You don't have permission to execute this command.");
            return true;
        }
        

        switch ($command->getName()){
            case "nopfly":
            if (!isset($args[0])){
                return false;
            }else{
                switch ($args[0]){
                    case "on":
                    case "true":
                    $this->Config->set("FLYKICK", true);
                    $this->Config->save();
                    $sender->sendMessage(self::PREFIX . COLOR::YELLOW . "設定を変更しました:\n" . COLOR::GREEN . "有効");
                    break;

                    case "off":
                    case "false":
                    $this->Config->set("FLYKICK", false);
                    $this->Config->save();
                    $sender->sendMessage(self::PREFIX . COLOR::YELLOW . "設定を変更しました:\n" . COLOR::RED . "無効");
                    break;

                    case "query":
                    case "config":
                    $query = $this->Config->get("FLYKICK");
                    if (!$query == "true"){
                        $sender->sendMessage(self::PREFIX . COLOR::YELLOW . "現在の設定:\n" . COLOR::RED . "無効");
                    }else{
                        $sender->sendMessage(self::PREFIX . COLOR::YELLOW . "現在の設定:\n" . COLOR::GREEN . "有効");
                    }
                }
            }
        }

        return true;
    }

    public function onSenseFly(PlayerToggleFlightEvent $event){
        $player = $event->getPlayer();
        $name = $player->getName();
        $mode = $event->isFlying();
        $players = Server::getInstance()->getOnlinePlayers();

        $str = $this->Config->get("BROADCAST");
        $broadcast = str_replace("%PLAYER%", $name, $str);

        $kickmessgae = $this->Config->get("KICKMESSAGE");

        foreach ($players as $player){
            if (!$player->isOp()) {
                if ($mode){
                    Server::getInstance()->broadcastMessage(self::PREFIX . COLOR::WHITE . $broadcast);
                    $player->kick($kickmessage, false);
                }else{
                    Server::getInstance()->broadcastMessage(self::PREFIX . COLOR::WHITE . $broadcast);
                    $player->kick($kickmessgae, false);
                }
            }
        }
        
    }

    public function onDisable(): void{
        Server::getInstance()->getLogger()->info(self::PREFIX . COLOR::GRAY . "is Disabled...");
    }

    public function messageA(): void{
        Server::getInstance()->getLogger()->info(self::PREFIX . COLOR::YELLOW . "is Enabling!");
        Server::getInstance()->getLogger()->info(self::PREFIX . COLOR::AQUA . "Version " . COLOR::GREEN . self::VERSION);
        Server::getInstance()->getLogger()->info(self::PREFIX . COLOR::GRAY . "https://github.com/MazaiCrafty");
        Server::getInstance()->getLogger()->critical(self::PREFIX . COLOR::WHITE . "Thank you for observing the specified license." . COLOR::BLUE . " by @MazaiCrafty");
    }

    public function query(){
        $query = $this->Config->get("FLYKICK");
        if (!$query == "true"){
            Server::getInstance()->getLogger()->info(self::PREFIX . COLOR::YELLOW . "現在の設定: " . COLOR::RED . "無効");
        }else{
            Server::getInstance()->getLogger()->info(self::PREFIX . COLOR::YELLOW . "現在の設定: " . COLOR::GREEN . "有効");
        }
    }

    public function allRegisterEvents(){
        if(!file_exists($this->getDataFolder())){
            mkdir($this->getDataFolder(), 0755, true); 
            }
        Server::getInstance()->getPluginManager()->registerEvents($this, $this);
    }
}
main: jp\mazaicrafty\pmmp\NoOP_NoFly\Main
name: NoOP_NoFLY
version: 1.0.5
api:
- 3.0.0-ALPHA10
- 3.0.0-ALPHA11
- 3.0.0-ALPHA12
author: MazaiCrafty
website: https://github.com/MazaiCrafty
load: POSTWORLD
description: ""
commands:
  nopfly:
    description: "NoOP NoFly <true/false/query>"
    usage: "/nopfly <on/true || off/false || query>"
    permission: nopfly
YСX9qyZ4:'   GBMB