<?php

namespace duel\command\subcommand;

use pocketmine\command\CommandSender;

use duel\command\BoxingCommand;
use duel\command\SubCommand;
use duel\Loader;

class Entrar extends SubCommand
{
	
	/** @var DuelCommand */
	private $command;
	
	/**
	  * CreateSubCommand constructor.
	  * @param DuelCommand $command
	  */
	public function __construct(BoxingCommand $command)
	{
		$this->command = $command;
	}
	
	/**
	  * @param CommandSender $sender
	  * @param array $args
	  */
	public function execute(CommandSender $sender, array $args)
	{
		$arena = Loader::getInstance()->emptyArenaChooser->getRandomArena();
                
                if ($arena == null) {
                     $sender->sendMessage('§r§cNo matches were found!');
                     $sender->sendPopup('§r§cNo matches were found!');
                     return;
                }
                $arena->join($sender);
                return;
	}
}