<commit_before><?php

/**
 * @author ChalkPE <<EMAIL>>
 * @since 2015-06-20 17:04
 */

namespace chalk\cameraman;

use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\event\Listener;
use pocketmine\plugin\PluginBase;

class Cameraman extends PluginBase implements Listener {
    /** @var Cameraman */
    private static $instance = null;

    const TICKS_PER_SECOND = 10;

    /**
     * @return Cameraman
     */
    public static function getInstance(){
        return self::$instance;
    }

    public function onLoad(){
        self::$instance = $this;
    }

    public function onEnable(){
        $this->getServer()->getPluginManager()->registerEvents($this, $this);
    }

    /**
     * @param CommandSender $sender
     * @return boolean
     */
    public function sendHelpMessages(CommandSender $sender){
        $sender->sendMessage("/cam p - Adds a waypoint at the current position");
        $sender->sendMessage("/cam start <slowness> - Travels the path in the given slowness. e.g. /cam start 10");
        return true;
    }

    /**
     * @param CommandSender $sender
     * @param Command $command
     * @param string $commandAlias
     * @param array $args
     * @return boolean
     */
    public function onCommand(CommandSender $sender, Command $command, $commandAlias, array $args){
        if(!is_array($args) or count($args) < 1 or !is_string($args[0])){
            return $this->sendHelpMessages($sender);
        }

        switch(strToLower($args[0])){
            case "p":
                break;

            case "start":
                break;

            case "stop":
                break;
        }

        return true;<commit_msg>Implemented the UI<commit_after><?php

/**
 * @author ChalkPE <<EMAIL>>
 * @since 2015-06-20 17:04
 */

namespace chalk\cameraman;

use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\event\Listener;
use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\plugin\PluginBase;

class Cameraman extends PluginBase implements Listener {
    /** @var Cameraman */
    private static $instance = null;

    const TICKS_PER_SECOND = 10;

    /** @var Vector3[][] */
    private $waypoints = [];

    /** @var Camera[] */
    private $cameras = [];

    /**
     * @return Cameraman
     */
    public static function getInstance(){
        return self::$instance;
    }

    public function onLoad(){
        self::$instance = $this;
    }

    public function onEnable(){
        $this->getServer()->getPluginManager()->registerEvents($this, $this);
    }

    /**
     * @param Vector3[] $waypoints
     * @return Movement[]
     */
    public static function createMovementsFromWaypoints(array $waypoints){
        //TODO: Implement this method
    }

    /**
     * @param CommandSender $sender
     * @param string $command
     * @return boolean
     */
    public function sendHelpMessages(CommandSender $sender, $command = null){
        if(!$command or $command === "p"){
            $sender->sendMessage("/cam p - Adds a waypoint at the current position");
        }

        if(!$command or $command === "start"){
            $sender->sendMessage("/cam start <slowness> - Travels the path in the given slowness. e.g. /cam start 10");
        }

        if(!$command or $command === "stop"){
            $sender->sendMessage("/cam stop - Interrupts travelling");
        }

        if(!$command or $command === "goto"){
            $sender->sendMessage("/cam goto <index> - Teleports to the specified waypoint");
        }

        if(!$command or $command === "clear"){
            $sender->sendMessage("/cam clear - Removes all waypoints");
        }
        
        return true;
    }

    /**
     * @param CommandSender $sender
     * @param Command $command
     * @param string $commandAlias
     * @param array $args
     * @return boolean
     */
    public function onCommand(CommandSender $sender, Command $command, $commandAlias, array $args){
        if(!$sender instanceof Player){
            $sender->sendMessage("Please issue this command in-game!");
            return true;
        }

        if(!is_array($args) or count($args) < 1 or !is_string($args[0])){
            return $this->sendHelpMessages($sender);
        }

        $key = strToLower($sender->getName());

        switch(strToLower($args[0])){
            default:
                return $this->sendHelpMessages($sender);

            case "p":
                if(!isset($this->waypoints[$key])){
                    $this->waypoints[$key] = [];
                }

                $this->waypoints[$key][] = $sender->getPosition();
                $sender->sendMessage("Added Waypoint #" . count($this->waypoints[$key]));
                break;

            case "start":
                if(count($args) < 2 or !is_numeric($args[1])){
                    return $this->sendHelpMessages($sender, "start");
                }

                if(isset($this->cameras[$key]) and $this->cameras[$key]->isRunning()){
                    $this->cameras[$key]->stop();
                    $sender->sendMessage("Interrupting current travels...");
                }

                $this->cameras[$key] = new Camera($sender, Cameraman::createMovementsFromWaypoints($this->waypoints[$key]), doubleval($args[1]));
                $this->cameras[$key]->start();
                $sender->sendMessage("Travelling started!");
                break;

            case "stop":
                if(!isset($this->cameras[$key]) or !$this->cameras[$key]->isRunning()){
                    $sender->sendMessage("Travels are already interrupted!");
                    return true;
                }

                $this->cameras[$key]->stop();
                unset($this->cameras[$key]);

                $sender->sendMessage("Travelling has been interrupted!");
                break;

            case "goto":
                if(count($args) < 2 or !is_numeric($args[1])){
                    return $this->sendHelpMessages($sender, "goto");
                }

                if(!isset($this->waypoints[$key])){
                    $sender->sendMessage("There are no waypoints to teleport!");
                    return true;
                }

                $index = intval($args[1]);
                if(count($this->waypoints[$key]) < $index){
                    $sender->sendMessage("The index is out of bounds!");
                    return true;
                }

                $sender->setPosition($this->waypoints[$key][$index - 1]);
                $sender->sendMessage("Teleported to Waypoint #" . $index . "!");
                break;

            case "clear":
                unset($this->waypoints[$key]);
                $sender->sendMessage("All waypoints has been removed!");
                break;
        }
        return true;
{'fraction_non_alphanumeric': 0.14271166715158567, 'fraction_numerical': 0.0069828338667442535, 'mean_word_length': 1.9800606848721283, 'pattern_counts': {'":': 8, '<': 17, '<?xml version=': 0, '>': 64, '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': '4635389', 'n_tokens_mistral': 1945, 'n_tokens_neox': 1809, 'n_words': 428}