
<?php
echo "PocketMine-MP plugin AutoClear v1.0.0
This file has been generated using DevTools v1.15.0 at Thu, 06 Jan 2022 15:50:57 +0900
----------------
Name: AutoClear
Version: 1.0.0
Main: roi611\\clear\\Main
Api: 4.0.0, 4.0.0-BETA1
Depend: 
Description: アイテムを削除します
Authors: 
Website: 
CreationDate: 1641451857
";
__HALT_COMPILER(); ?>
             .  a:9:{s:4:"name";s:9:"AutoClear";s:7:"version";s:5:"1.0.0";s:4:"main";s:17:"roi611\clear\Main";s:3:"api";a:2:{i:0;s:5:"4.0.0";i:1;s:11:"4.0.0-BETA1";}s:6:"depend";s:0:"";s:11:"description";s:30:"アイテムを削除します";s:7:"authors";s:0:"";s:7:"website";s:0:"";s:12:"creationDate";i:1641451857;}   src/roi611/clear/Main.php  Qa  GO8      
   plugin.yml\  Qa\  '      <?php
    
namespace roi611\clear;
    
use pocketmine\plugin\PluginBase;

use pocketmine\command\Command;
use pocketmine\command\CommandSender;

use pocketmine\player\Player;
use pocketmine\Server;

use pocketmine\utils\Config;

use pocketmine\world\World;

use pocketmine\entity\object\ItemEntity;

use pocketmine\scheduler\Task;
    
class Main extends PluginBase{
    
    public function onEnable():void{

        $config = new Config($this->getDataFolder()."Config.yml",Config::YAML,array(
            "消去間隔(秒)" => 300,
            "？秒前から全て通知する" => 10
        ));

        date_default_timezone_set('Asia/Tokyo');
        $this->getScheduler()->scheduleRepeatingTask(new Run($config,$this),20);

    }
    
    public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool{

        if(isset($args[0])){
            if(Server::getInstance()->getWorldManager()->isWorldGenerated($args[0]) === false || Server::getInstance()->getWorldManager()->isWorldLoaded($args[0]) === false){
                $sender->sendMessage("ワールド: §e{$args[0]}§r は存在しないか、読み込まれていません。");
                return true;
            } else {
                $world = Server::getInstance()->getWorldManager()->getWorldByName($args[0]);
            }
        } else {
            $world = Server::getInstance()->getWorldManager()->getWorlds();
        }

        $this->remove($world);

        return true;
        
    }

    public function remove(World|array $world){

        if($world instanceof World){

            $entities = $world->getEntities();
            $count = 0;
            foreach($entities as $entity){
                if($entity instanceof ItemEntity){
                    $entity->kill();
                    $count++;
                }
            }

            foreach($world->getPlayers() as $player){
                $player->sendMessage("§cドロップアイテムが §e {$count} 個 §c削除されました！");
            }

        } else {

            foreach($world as $w){
                $entities = $w->getEntities();
                $count = 0;
                foreach($entities as $entity){
                    if($entity instanceof ItemEntity){
                        $entity->kill();
                        $count++;
                    }
                }

                foreach($w->getPlayers() as $player){
                    Server::getInstance()->broadcastmessage("§cドロップアイテムが §e {$count} 個 §c削除されました！");
                }

            }


        }
    }

}



class Run extends Task{
    
    private $count = 0;

    function __construct(Config $config,Main $main){
        $this->config = $config;
        $this->main = $main;
	}

    function onRun():void{

        $this->count++;

        if($this->count >= (int)$this->config->get("消去間隔(秒)")){
            $this->count = 0;
            $this->main->remove(Server::getInstance()->getWorldManager()->getWorlds());
        } else if(($re = (int)$this->config->get("消去間隔(秒)") - $this->count) <= $this->config->get("？秒前から全て通知する")){
            Server::getInstance()->broadcastmessage("§cアイテム削除まであと§e {$re} 秒§r です。");
        }

    }

}name: AutoClear
main: roi611\clear\Main
version: 1.0.0
api:
- 4.0.0
- 4.0.0-BETA1
load: POSTWORLD
author: roi611
description: アイテムを削除します

commands: 
  break:
    description: 落ちているアイテムをすぐに削除します
    usage: /break
    permission: "clear.command"

permissions:
  clear.command:
    default: op

 Af\5Kԅd':   GBMB