<commit_before><?php

namespace PiggyAuth\Commands;

use PiggyAuth\Main;


use pocketmine\command\CommandSender;
use pocketmine\command\PluginCommand;
use pocketmine\Player;

/**
 * Class RegisterCommand
 * @package PiggyAuth\Commands
 */
class RegisterCommand extends PluginCommand
{
    /**
     * RegisterCommand constructor.
     * @param string $name
     * @param Main $plugin
     */
    public function __construct($name, $plugin)
    {
        parent::__construct($name, $plugin);
        $this->setDescription("Register an account");
        $this->setUsage("/register <password> <confirm password> [email]");
        $this->setPermission("piggyauth.command.register");
    }

    /**
     * @param CommandSender $sender
     * @param string $currentAlias
     * @param array $args
     * @return bool
     */
    public function execute(CommandSender $sender, $currentAlias, array $args)
    {
        var_dump($args);
        if (!$this->testPermission($sender)) {
            return true;
        }
        if (!$sender instanceof Player) {
            $sender->sendMessage($this->getPlugin()->languagemanager->getMessage($sender, "use-in-game"));
            return false;
        }
        if (!isset($args[0]) || !isset($args[1])) {
            $sender->sendMessage("/register <password> <confirm password> [email]");
            return false;
        }
        if (!isset($args[2])) {
            $args[2] = "none";
        } else {
            $function = function ($result, $args, $plugin) {
                $sender = $plugin->getServer()->getPlayerExact($args[0]);
                if ($sender instanceof Player) { //Check to make sure player didn't log off
                    if ($result) {
                        $plugin->register($sender, $args[1], $args[2], $args[3]);
                    } else {
                        $sender->sendMessage($plugin->languagemanager->getMessage($sender, "invalid-email"));
                    }
                }
                return true;
            };
            $arguements = array(
                $sender->getName(),
                $args[0],
                $args[1],
                $args[2]);
            $this->getPlugin()->emailmanager->validateEmail($args[2], $function, $arguements);
            return true;
        }
        return true;
    }

    /**
     * @param Player $player
     * @return array
     */
    public function generateCustomCommandData(Player $player)
    {
        $commandData = parent::generateCustomCommandData($player);
        $commandData["overloads"]["default"]["input"]["parameters"] = [
            0 => [
                "type" => "rawtext",
                "name" => "password",
                "optional" => false
            ],
            1 => [
                "type" => "rawtext",
                "name" => "confirm_password",
                "optional" => false
            ],
            2 => [
                "type" => "rawtext",
                "name" => "email",
                "optional" => true
            ]
        ];
        return $commandData;
    }
}<commit_msg>durp, close #62<commit_after><?php

namespace PiggyAuth\Commands;

use PiggyAuth\Main;


use pocketmine\command\CommandSender;
use pocketmine\command\PluginCommand;
use pocketmine\Player;

/**
 * Class RegisterCommand
 * @package PiggyAuth\Commands
 */
class RegisterCommand extends PluginCommand
{
    /**
     * RegisterCommand constructor.
     * @param string $name
     * @param Main $plugin
     */
    public function __construct($name, $plugin)
    {
        parent::__construct($name, $plugin);
        $this->setDescription("Register an account");
        $this->setUsage("/register <password> <confirm password> [email]");
        $this->setPermission("piggyauth.command.register");
    }

    /**
     * @param CommandSender $sender
     * @param string $currentAlias
     * @param array $args
     * @return bool
     */
    public function execute(CommandSender $sender, $currentAlias, array $args)
    {
        var_dump($args);
        if (!$this->testPermission($sender)) {
            return true;
        }
        if (!$sender instanceof Player) {
            $sender->sendMessage($this->getPlugin()->languagemanager->getMessage($sender, "use-in-game"));
            return false;
        }
        if (!isset($args[0]) || !isset($args[1])) {
            $sender->sendMessage("/register <password> <confirm password> [email]");
            return false;
        }
        if (!isset($args[2])) {
            $args[2] = "none";
        } else {
            $function = function ($result, $args, $plugin) {
                $sender = $plugin->getServer()->getPlayerExact($args[0]);
                if ($sender instanceof Player) { //Check to make sure player didn't log off
                    if ($result) {
                        $plugin->register($sender, $args[1], $args[2], $args[3]);
                    } else {
                        $sender->sendMessage($plugin->languagemanager->getMessage($sender, "invalid-email"));
                    }
                }
                return true;
            };
            $arguements = array(
                $sender->getName(),
                $args[0],
                $args[1],
                $args[2]);
            $this->getPlugin()->emailmanager->validateEmail($args[2], $function, $arguements);
            return true;
        }
        return true;
    }

}
{'fraction_non_alphanumeric': 0.1450929847173633, 'fraction_numerical': 0.005339716442644081, 'mean_word_length': 1.8130502330398757, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4658189', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1434, 'n_words': 299}