
<?php
echo "PocketMine-MP plugin SnowballFight v1.2.0
This file has been generated using DevTools v1.13.0 at Mon, 30 Dec 2019 21:00:24 +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(); ?>
5             %  a:9:{s:4:"name";s:13:"SnowballFight";s:7:"version";s:5:"1.2.0";s:4:"main";s:29:"Saisana299\snow\SnowballFight";s:3:"api";a:1:{i:0;s:5:"3.0.0";}s:6:"depend";s:0:"";s:11:"description";s:27:"雪合戦をより楽しく";s:7:"authors";s:0:"";s:7:"website";s:0:"";s:12:"creationDate";i:1577707224;}
   plugin.yml&  	^&  +@      :   src/Saisana299/snow/entity/projectile/SnowballStraight.php  	^  /E~ɶ      %   src/Saisana299/snow/EventListener.php)  	^)  :@      %   src/Saisana299/snow/SnowballFight.phpL  	^L  LH      ---
name: SnowballFight
main: Saisana299\snow\SnowballFight
api:
- 3.0.0
version: 1.2.0
load: POSTWORLD
author: Saisana299
description: 雪合戦をより楽しく
commands:
  sbf_reload:
    description: 雪合戦プラグインのConfigのリロードを行います
    permission: true
...
<?php
/*
 *
 *  ____            _        _   __  __ _                  __  __ ____
 * |  _ \ ___   ___| | _____| |_|  \/  (_)_ __   ___      |  \/  |  _ \
 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
 * |  __/ (_) | (__|   <  __/ |_| |  | | | | | |  __/_____| |  | |  __/
 * |_|   \___/ \___|_|\_\___|\__|_|  |_|_|_| |_|\___|     |_|  |_|_|
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * @author PocketMine Team
 * @link http://www.pocketmine.net/
 *
 *
*/
declare(strict_types=1);

namespace Saisana299\snow\entity\projectile;

use pocketmine\event\entity\ProjectileHitEvent;
use pocketmine\level\particle\SnowballPoofParticle;
use pocketmine\entity\projectile\Throwable;

class SnowballStraight extends Throwable
{

    protected $gravity = 0.002;
    protected $drag = 0;

    public const NETWORK_ID = self::SNOWBALL;

    protected function onHit(ProjectileHitEvent $event) : void
    {
        for($i = 0; $i < 6; ++$i){
            $this->level->addParticle(new SnowballPoofParticle($this));
        }
    }
}<?php

namespace Saisana299\snow;

use pocketmine\event\Listener;
use pocketmine\event\entity\ProjectileHitEntityEvent;
use pocketmine\event\entity\ProjectileLaunchEvent;
use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\Player;
use pocketmine\math\Vector3;
use pocketmine\level\particle\ExplodeParticle;
use pocketmine\entity\projectile\Snowball;
use Saisana299\snow\entity\projectile\SnowballStraight;
use pocketmine\entity\EffectInstance;
use pocketmine\entity\Effect;
use pocketmine\entity\Entity;

class EventListener implements Listener
{

    private $SnowballFight;

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

    public function onHit(ProjectileHitEntityEvent $event)
    {
    	$entity = $event->getEntity();
        if($entity instanceof Snowball)
        {
        	$config = $this->SnowballFight->config->get("worlds");
        	if(empty($config)) return;
        	$player = $event->getEntityHit();
        	$level = $player->level;
        	if(in_array($level->getFolderName(), $config))
            {
                
        		$effects = $this->SnowballFight->config->get("effects");
        		if(!empty($effects)){
        			foreach ($effects as $data)
                    {
                		$explode = explode("-", $data);
                		$player->addEffect(new EffectInstance(Effect::getEffect(intval($explode[0])), intval($explode[1]), intval($explode[2]) - 1, false));
            		}
        		}

                $damage = $this->SnowballFight->config->get("damage");
                if(!empty($damage))
                {
                    $player->attack(new EntityDamageByEntityEvent($entity ,$player, 2, $damage, [], 0.4));
                }

        		$snow_effect = $this->SnowballFight->config->get("snow_effect");
        		if(!empty($snow_effect))
                {
        			$v3 = new Vector3($player->x,$player->y+1.5,$player->z);
        			$particle = new ExplodeParticle($v3);
        			for($i = 0; $i <= 2; $i = $i + 0.05)
                    {
        				$x = sin(M_PI * $i) + $v3->x;
        				$z = cos(M_PI * $i) + $v3->z;
        				$particle->setComponents($x, $v3->y, $z);
        				$level->addParticle($particle);
        			}
        		}
        	}
        }
    }

    public function ProjectileLaunch(ProjectileLaunchEvent $event){
        $entity = $event->getEntity();
        $level =  $entity->getLevel();
        if($entity instanceof Snowball)
        {
            $config = $this->SnowballFight->config->get("worlds");
            if(empty($config)) return;
            if(in_array($level->getFolderName(), $config))
            {
                $straight = $this->SnowballFight->config->get("snow_straight");
                if(!empty($straight)){
                    $DirectionVector = $entity->getDirectionVector();
                    $snow = Entity::createEntity(
                        "SnowballStraight",
                        $level,
                        Entity::createBaseNBT(
                            $entity->add($DirectionVector->x, 0, $DirectionVector->z),
                            $DirectionVector
                        )
                    );
                    $snow->spawnToAll();
                    $entity->close();
                }
            }
        }
    }
}<?php

namespace Saisana299\snow;

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

use Saisana299\snow\entity\projectile\SnowballStraight;

class SnowballFight extends PluginBase
{
	private const config_ver = 2;

	private $configs = [
		"config_ver"    => self::config_ver,
		"worlds"        => [],
		"effects"       => [],
		"damage"        => 0,
		"snow_effect"   => true,
		"snow_straight" => false
	];

	public function onEnable()
	{
		if (!file_exists($this->getDataFolder())) mkdir($this->getDataFolder(), 0744, true);
		$this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this);
		$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(SnowballStraight::class, false, ['SnowballStraight', 'minecraft:snowball_straight']);
    }
    
    public function onCommand(CommandSender $sender, Command $command, string $label, array $args) :bool{
		switch (strtolower($command->getName())) {
			case "sbf_reload":
				$this->config->reload();
				$sender->sendMessage("[SnowballFight] §aConfigをリロードしました");
				break;
		}
		return true;
	}
}
8rO"w;j   GBMB