Pocketmine Git client !
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
1.6 KiB

  1. <?php
  2. namespace Ad5001\Gitable;
  3. use pocketmine\command\CommandSender;
  4. use pocketmine\command\Command;
  5. use pocketmine\event\Listener;
  6. use pocketmine\plugin\PluginBase;
  7. use pocketmine\utils\TextFormat as C;
  8. use pocketmine\Server;
  9. use pocketmine\utils\Utils;
  10. use pocketmine\Player;
  11. class Main extends PluginBase implements Listener {
  12. protected $git;
  13. const PREFIX = C::BLACK . "[" . C::LIGHT_GRAY . "Git" . C::BLACK . "] " . C::LIGHT_GRAY;
  14. public function onEnable() {
  15. $this->getServer()->getPluginManager()->registerEvents($this, $this);
  16. if(Utils::getOS() == "win") {
  17. $this->git = new Windows($this, $this->getDataFolder());
  18. } elseif(Utils::getOS() == "linux") {
  19. $this->git = new Linux($this, $this->getDataFolder());
  20. } elseif(Utils::getOS() == "mac") {
  21. $this->git = new Mac($this, $this->getDataFolder());
  22. }
  23. }
  24. public function onCommand(CommandSender $sender, Command $cmd, $label, array $args){
  25. switch($cmd->getName()){
  26. case 'git':
  27. if(count($args) >= 2) {
  28. switch($args[0]) {
  29. case "cd":
  30. $this->git->cd($args[1]);
  31. $sender->sendMessage("New path: " . $this->git->getDir());
  32. break;
  33. }
  34. return true;
  35. }
  36. break;
  37. }
  38. return false;
  39. }
  40. public function getGitClient() {
  41. return $this->git;
  42. }
  43. public function setGitClient(GitClient $client) {
  44. $this->git = $client;
  45. return $this->git == $client;
  46. }
  47. }