
<?php
echo "PocketMine-MP plugin ThunderSword v2.1.0
This file has been generated using DevTools v1.15.0 at Sat, 26 Feb 2022 17:33:47 +0800
----------------
Name: ThunderSword
Version: 2.1.0
Main: ThunderSword\\Main
Api: 4.0.0
Depend: 
Description: 
Authors: 
Website: 
CreationDate: 1645868027
";
__HALT_COMPILER(); ?>
Í             ò   a:9:{s:4:"name";s:12:"ThunderSword";s:7:"version";s:5:"2.1.0";s:4:"main";s:17:"ThunderSword\Main";s:3:"api";s:5:"4.0.0";s:6:"depend";s:0:"";s:11:"description";s:0:"";s:7:"authors";s:0:"";s:7:"website";s:0:"";s:12:"creationDate";i:1645868027;}
   plugin.yml  ûób  …3…�¶         resources/config.yml  ûób  ]Ç#¶      "   src/ThunderSword/EventListener.phpŸ  ûóbŸ  ³$ä¶         src/ThunderSword/Main.phpÞ  ûóbÞ  ã×¶      name: ThunderSword
main: ThunderSword\Main
version: 2.1.0
api: 4.0.0
author: haya1007

commands:
  sword:
    description: "雷を落とす剣を入手"
    usage: "/sword"
    permission: command.sword
permissions:
  command.sword:
    description: 
    default: true---
#剣の名前
NAME: "§eThunderSword"

#アイテムの説明
LORE: "雷を落とす剣"

#攻撃力
ATK: 5

#壊れないようにするか (true or false)
Unbreakable: true

#ブロックタップでも雷を落とすようにするか (true or false)
BlockTap: true
...<?php

namespace ThunderSword;

use pocketmine\player\Player;
use pocketmine\entity\Entity;
use pocketmine\event\Listener;
use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\event\player\PlayerInteractEvent;
use pocketmine\world\particle\BlockBreakParticle;

use pocketmine\network\mcpe\protocol\AddActorPacket;
use pocketmine\network\mcpe\protocol\PlaySoundPacket;

class EventListener implements Listener{

	public function __construct(private Main $plugin){}

	public function onDamage(EntityDamageByEntityEvent $event){
		$damager = $event->getDamager();
		if($damager instanceof Player){
			$item_tag = $damager->getInventory()->getItemInHand()->getNamedTag();
			$entity = $event->getEntity();
			if($item_tag->getTag("thunder") !== null){
				$this->Lightning_falls($entity);
				$event->setBaseDamage($item_tag->getTag("atk")->getValue());
			}
		}
	}

	public function onTap(PlayerInteractEvent $event){
		if($this->plugin->config->get("BlockTap")){
			if($event->getAction() === 0 || $event->getAction() === 1){
				if($event->getPlayer()->getInventory()->getItemInHand()->getNamedTag()->getTag("thunder") !== null){
					$this->Lightning_falls($event->getBlock());
				}
			}
		}
	}

	public function Lightning_falls($entity) : void{
		$pos = $entity->getPosition();
		$pk = AddActorPacket::create(Entity::nextRuntimeId(),1,"minecraft:lightning_bolt",$pos->asVector3(),null, 0,0,0.0,[],[],[]);
		$pk2 = PlaySoundPacket::create("ambient.weather.thunder", $pos->getX(), $pos->getY(), $pos->getZ(), 1, 1);
		$server = $this->plugin->getServer();
		$server->broadcastPackets($server->getOnlinePlayers(), [$pk, $pk2]);
	}
}<?php

namespace ThunderSword;

use pocketmine\command\Command;
use pocketmine\command\CommandSender;

use pocketmine\plugin\PluginBase;
use pocketmine\item\ItemFactory;
use pocketmine\utils\Config;

use pocketmine\nbt\tag\IntTag;

class Main extends PluginBase{
	public function onEnable() : void{
		$this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this);

		if(!file_exists($this->getDataFolder())){mkdir($this->getDataFolder(), 0744, true);}

		$this->saveDefaultConfig();
		$this->config = new Config($this->getDataFolder() . "config.yml", Config::YAML);

		// 雷の剣
		$this->sword = ItemFactory::getInstance()->get(283, 0); // 金の剣の取得
		$this->sword->setCustomName($this->config->get('NAME')); // 名前の変更
		$this->sword->setLore([$this->config->get('LORE')]); // アイテムの説明欄
		if($this->config->get("Unbreakable")){
   			$this->sword->setUnbreakable(); // 壊れないようにする
   		}
		$tag = $this->sword->getNamedTag(); // nbt取得
		$tag->setTag("thunder", new IntTag(1)); // 雷の剣なのかの判定用
		$tag->setTag("atk", new IntTag($this->config->get("ATK"))); // ダメージ量
		$this->sword->setNamedTag($tag); // nbtの適用
	}

	public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool{
		switch($command->getName()){
			case "sword":
				$sender->getInventory()->addItem($this->sword);

				return true;
		}
	}
}‡¢Žá]‹{ѳBÜÌ'#ӊ·-k   GBMB