
<?php
echo "PocketMine-MP plugin Countdown v1.1.0
This file has been generated using DevTools v1.13.0 at Tue, 31 Dec 2019 17:45:37 +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(); ?>
             4  a:9:{s:4:"name";s:9:"Countdown";s:7:"version";s:5:"1.1.0";s:4:"main";s:30:"Saisana299\countdown\Countdown";s:3:"api";a:1:{i:0;s:5:"3.0.0";}s:6:"depend";s:0:"";s:11:"description";s:21:"カウントダウン";s:7:"authors";a:1:{i:0;s:14:"DaisukeDaisuke";}s:7:"website";s:0:"";s:12:"creationDate";i:1577781937;}
   plugin.yml#  
^#  qͶ      &   src/Saisana299/countdown/Countdown.php.  
^.  9a[      6   src/Saisana299/countdown/entity/CountdownFireworks.php  
^  tͶ      /   src/Saisana299/countdown/task/CountdownTask.php  
^  c.      6   src/Saisana299/countdown/utils/FireworksCompounder.php  
^  ؤr      ---
name: Countdown
main: Saisana299\countdown\Countdown
version: 1.1.0
api: [3.0.0]
load: POSTWORLD
author: Saisana299
authors: [DaisukeDaisuke]
description: カウントダウン
commands:
  countdown:
    description: カウントダウン開始！
    permission: true
...
<?php

//なに解凍してんだ、帰れ！(ﾟДﾟ)

declare(strict_types = 1);

namespace Saisana299\countdown;

use pocketmine\plugin\PluginBase;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\Server;
use pocketmine\utils\Config;
use pocketmine\entity\Entity;

use Saisana299\countdown\entity\CountdownFireworks;
use Saisana299\countdown\task\CountdownTask;

class Countdown extends PluginBase
{

	private const config_ver = 2;

	private $configs = [
		"config_ver"     => self::config_ver,
		"DATE"           => "2020-01-01 00:00:00",
		"onStart"        => "§e§l2020年までカウントダウン開始！",
		"onCount"        => "§e2020年まで...",
		"onEnd"          => "§e§lWelcome §a2§b0§a2§b0 §f!!",
		"Count"          => "残り # 秒",
		"Sound"          => "random.levelup",
		"Fireworks"      => true,
		"Fireworks_Time" => 15
	];

	public $isCountdown = false;
	public $isEnd = false;
	
	public function onEnable()
	{
		date_default_timezone_set("Asia/Tokyo");
		$this->config = new Config($this->getDataFolder() . "config.yml", Config::YAML, $this->configs);
		if($this->config->get("config_ver") !== self::config_ver)
		{
			$this->config->setAll($this->configs);
			$this->config->save();
			$this->getLogger()->warning("Configのバージョンが異なっていたため初期化致しました");
			$this->getLogger()->warning("現在のコンフィグバージョン = ".self::config_ver);
		}
		Entity::registerEntity(CountdownFireworks::class, false, ["CountdownFireworks"]);
	}
	
	public function onCommand(CommandSender $sender, Command $command, string $label, array $args) :bool
	{
		switch (strtolower($command->getName()))
		{
			case "countdown":
				if(isset($args[0]))
				{
					if($args[0] === "reload"){
						$this->config->reload();
						$sender->sendMessage("[Countdown] §aConfigをリロードしました");
					}
					return true;
				}

				if($this->isCountdown === true){
					$this->getServer()->broadcastMessage("[Countdown] §eカウントダウンがキャンセルされました");
					$this->isCountdown = false;
					$this->isEnd = false;
					return true;
				}

				$message = $this->config->get("onStart");
				$date = $this->config->get("DATE");
				$date2 = date("Y-m-d H:i:s");
				$date3 = $this->date_time_diff($date, $date2);

				if($date3 <= 0){
					$sender->sendMessage("[Countdown] §c過去に向けたカウントダウンはできません！");
					return true;
				}

				$this->getServer()->broadcastPopup($message);
				$this->getServer()->broadcastMessage("[Countdown] ".$message);
				foreach(Server::getInstance()->getOnlinePlayers() as $player)
				{
					$player->addTitle($message, $date." まで", 1*20, 3*20, 1*20);
				}
				$this->getScheduler()->scheduleRepeatingTask(new CountdownTask($this), 20);
				$this->isCountdown = true;
				$this->isEnd = false;
				break;
		}
		return true;
	}

	public function date_time_diff($d1, $d2): int
	{
		$timeStamp1 = strtotime($d1);
		$timeStamp2 = strtotime($d2);
		$diffSeconds = $timeStamp1 - $timeStamp2;
		return $diffSeconds;
	}
}<?php

declare(strict_types = 1);

namespace Saisana299\countdown\entity;

use pocketmine\entity\Entity;
use pocketmine\level\Level;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\network\mcpe\protocol\ActorEventPacket;

class CountdownFireworks extends Entity {

	public const NETWORK_ID = Entity::FIREWORKS_ROCKET;

	public const DATA_FIREWORK_ITEM = 16;

	public $width = 0.25;
	public $height = 0.25;

	public function __construct(Level $level, CompoundTag $nbt, CompoundTag $fireworks){
		parent::__construct($level, $nbt);
        $this->propertyManager->setCompoundTag(self::DATA_FIREWORK_ITEM, $fireworks);
	}

	public function entityBaseTick(int $tickDiff = 1): bool {
		if($this->closed) {
			return false;
		}
		$hasUpdate = parent::entityBaseTick($tickDiff);
		if(!$this->isFlaggedForDespawn()) {
			$this->broadcastEntityEvent(ActorEventPacket::FIREWORK_PARTICLES);
			$this->flagForDespawn();
			$hasUpdate = true;
		}
		return $hasUpdate;
	}
}<?php

declare(strict_types = 1);

namespace Saisana299\countdown\task;

use pocketmine\scheduler\Task;
use pocketmine\Server;
use pocketmine\network\mcpe\protocol\PlaySoundPacket;
use pocketmine\entity\Entity;
use pocketmine\Player;
use pocketmine\math\Vector3;
use pocketmine\scheduler\ClosureTask;

use Saisana299\countdown\entity\CountdownFireworks;
use Saisana299\countdown\utils\FireworksCompounder;
use Saisana299\countdown\Countdown;

class CountdownTask extends Task
{

	private $Countdown;

	public function __construct(Countdown $Countdown)
	{
		$this->Countdown = $Countdown;
	}

	public function onRun(int $tick)
	{
		if($this->Countdown->isCountdown === false){
			$this->getHandler()->cancel();
			return;
		}
		$d1 = $this->Countdown->config->get("DATE");
		$d2 = date("Y-m-d H:i:s");
		$d3 = $this->Countdown->date_time_diff($d1, $d2);

		if($d3 <= 0){
			if($this->Countdown->isEnd !== true){
				$message = $this->Countdown->config->get("onEnd");
				$date = $this->Countdown->config->get("DATE");
				$this->Countdown->getServer()->broadcastMessage("[Countdown] ".$message);
				foreach(Server::getInstance()->getOnlinePlayers() as $player)
				{
					$player->addTitle($message, $date." になりました", 1*20, 5*20, 1*20);
				}
				$this->Countdown->isEnd = true;

				$sound = $this->Countdown->config->get("Sound");
				if(!empty($sound)) $this->addSound($sound);
			}
			$particle = $this->Countdown->config->get("Fireworks");
			if(!empty($particle)){
				$this->addFireworks();
				$time = $this->Countdown->config->get("Fireworks_Time");
				if(!empty($time)){
					if($d3 < - intval($time)){
						$this->Countdown->isCountdown = false;
						$this->Countdown->isEnd = false;
						$this->getHandler()->cancel();
					}
				}else{
					$this->Countdown->isCountdown = false;
					$this->Countdown->isEnd = false;
					$this->getHandler()->cancel();
				}
			}else{
				$this->Countdown->isCountdown = false;
				$this->Countdown->isEnd = false;
				$this->getHandler()->cancel();
			}
			
		}elseif($d3 <= 3){
			$message = $this->Countdown->config->get("onCount");
			$count = str_replace("#", "§l§c".strval($d3)."§r§f", $this->Countdown->config->get("Count"));
			$this->Countdown->getServer()->broadcastPopup($message."\n§r§f".$count);
			foreach(Server::getInstance()->getOnlinePlayers() as $player)
			{
				$player->addTitle("§l§c".strval($d3), "", 0*20, 1*20, 0*20);
				$pk = new PlaySoundPacket;
				$pk->soundName = "random.click";
				$pk->x = $player->x;
				$pk->y = $player->y;
				$pk->z = $player->z;
				$pk->volume = 0.5;
				$pk->pitch = 1;
				$player->sendDataPacket($pk);
			}

		}elseif($d3 <= 10){
			$message = $this->Countdown->config->get("onCount");
			$count = str_replace("#", "§l§e".strval($d3)."§r§f", $this->Countdown->config->get("Count"));
			$this->Countdown->getServer()->broadcastPopup($message."\n§r§f".$count);
			foreach(Server::getInstance()->getOnlinePlayers() as $player)
			{
				$player->addTitle("§l§e".strval($d3), "", 0*20, 1*20, 0*20);
				$pk = new PlaySoundPacket;
				$pk->soundName = "random.click";
				$pk->x = $player->x;
				$pk->y = $player->y;
				$pk->z = $player->z;
				$pk->volume = 0.5;
				$pk->pitch = 1;
				$player->sendDataPacket($pk);
			}

		}else{
			$message = $this->Countdown->config->get("onCount");
			$count = str_replace("#", "§l§a".strval($d3)."§r§f", $this->Countdown->config->get("Count"));
			$this->Countdown->getServer()->broadcastPopup($message."\n§r§f".$count);
		}
	}

	public function addSound(string $sound): void
	{
		foreach(Server::getInstance()->getOnlinePlayers() as $player)
		{
			$pk = new PlaySoundPacket;
			$pk->soundName = $sound;
			$pk->x = $player->x;
			$pk->y = $player->y;
			$pk->z = $player->z;
			$pk->volume = 0.5;
			$pk->pitch = 1;
			$player->sendDataPacket($pk);
		}
	}

	public function addFireworks(): void
	{
		foreach(Server::getInstance()->getOnlinePlayers() as $player)
		{
			$s = mt_rand(1, 3);
			for ($i = 1; $i <= $s; $i ++) { 
				$this->Countdown->getScheduler()->scheduleDelayedTask(new ClosureTask(
					function (int $currentTick) use ($player): void
					{
						$compounder = new FireworksCompounder();
						$fireworks = $compounder->setCompoundTag();
						$Entity = Entity::createEntity("CountdownFireworks", $player->getLevel(), Entity::createBaseNBT($this->randomVector3($player, $player->asVector3()), $player->getMotion()), $fireworks);
						$Entity->spawnToAll();
					}
				), (intval(20 / $s)) * $i);
			}
		}
	}

	public function randomVector3(Player $player, Vector3 $v3): Vector3{
		$direction = $player->getDirection();
		if($direction === 0){
			$new_v3 = $v3->add(mt_rand(15, 20) , mt_rand(8, 13), mt_rand(-20, 20));
		}elseif($direction === 1){
			$new_v3 = $v3->add(mt_rand(-20, 20) , mt_rand(8, 13), mt_rand(15, 20));
		}elseif($direction === 2){
			$new_v3 = $v3->add(mt_rand(-20, -15) , mt_rand(8, 13), mt_rand(-20, 20));
		}elseif($direction === 3){
			$new_v3 = $v3->add(mt_rand(-20, 20) , mt_rand(8, 13), mt_rand(-20, -15));
		}
		return $new_v3;
	}
}
<?php

declare(strict_types = 1);

namespace Saisana299\countdown\utils;

use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\ListTag;

class FireworksCompounder{

	public $types = [
		"TYPE_SMALL_SPHERE" => 0,
		"TYPE_HUGE_SPHERE" => 1,
		"TYPE_STAR" => 2,
		"TYPE_CREEPER_HEAD" => 3,
		"TYPE_BURST" => 4
	];

	public $colors = [
		"COLOR_RED" => "\x01",
		"COLOR_DARK_GREEN" => "\x02",
		"COLOR_BROWN" => "\x03",
		"COLOR_BLUE" => "\x04",
		"COLOR_DARK_PURPLE" => "\x05",
		"COLOR_DARK_AQUA" => "\x06",
		"COLOR_PINK" => "\x09",
		"COLOR_GREEN" => "\x0a",
		"COLOR_YELLOW" => "\x0b",
		"COLOR_LIGHT_AQUA" => "\x0c",
		"COLOR_DARK_PINK" => "\x0d",
		"COLOR_GOLD" => "\x0e",
		"COLOR_WHITE" => "\x0f"
	];

    public function setCompoundTag(): CompoundTag
    {
    	$args = $this->FireworksLottery();
		$explosion = new CompoundTag();
		$explosions = new ListTag("Explosions");
		$pretag = new CompoundTag("Fireworks");
		$tag = new CompoundTag("Fireworks");

		$explosion->setByte("FireworkType", $args[0]);
		$explosion->setByteArray("FireworkColor", $args[1]);
		$explosion->setByteArray("FireworkFade", "");
        $explosion->setByte("FireworkFlicker", $args[2] ? 1 : 0);
        $explosion->setByte("FireworkTrail", $args[3] ? 1 : 0);

		$explosions->push($explosion);

		$pretag->setTag($explosions);
		$pretag->setByte("Flight", 1);
		
		$tag->setTag($pretag);

        return $tag;
	}

	public function FireworksLottery(): array{
		$args = [];
		$type = array_rand($this->types, 1);
		$color = array_rand($this->colors, 1);
		$flicker = mt_rand(0, 1);
		$trail = mt_rand(0, 1);
		array_push($args, $this->types[$type], $this->colors[$color], $flicker, $trail);
		return $args;
	}
}7 (5O4^!{v`Ծ   GBMB