Starting it...

This commit is contained in:
Ad5001 2016-09-23 17:24:04 +03:00
commit 996d1791e6
7 changed files with 335 additions and 0 deletions

9
plugin.yml Normal file
View file

@ -0,0 +1,9 @@
---
name: Gitable
author: Ad5001
version: 1.0
api: [2.0.0]
main: Ad5001\Gitable\Main
commands: []
permissions: []
...

1
resources/Windows/bin Submodule

@ -0,0 +1 @@
Subproject commit 2209df713ae0598aca431eecad48e8ec8ddf7aec

View file

@ -0,0 +1,101 @@
<?php
namespace Ad5001\Gitable;
use pocketmine\Server;
use pocketmine\Player;
abstract class GitClient {
protected $main;
private $server;
protected $dir;
public function __construct(Main $main, string $dir) {
$this->main = $main;
$this->server = $main->getServer();
$this->dir = $dir;
}
public abstract function commit(string $message) : string;
public abstract function push(string $to = "github", string $from = "master") : string;
public abstract function undoCommit() : string;
public abstract function checkout($message) : string;
public abstract function branch($message) : string;
public abstract function start() : string;
public abstract function init() : string;
public function getDir() {
return $this->dir;
}
public abstract function cd($path) : string;
public abstract function clone($from) : string;
public abstract function logs() : string;
public abstract function remove($path) : string;
public abstract function move($path) : string;
public abstract function headreset() : string;
public abstract function add($path) : string;
public abstract function diff($path) : string;
public abstract function status($path) : string;
public abstract function remote($name, $url) : string;
public abstract function pull($to = "github", $from = "master") : string;
public abstract function status($path) : string;
}

View file

@ -0,0 +1,42 @@
<?php
namespace Ad5001\Gitable;
use pocketmine\Server;
use pocketmine\Player;
use Ad5001\Gitable\Main;
class Dummy {
public function __construct(Main $main) {
$this->main = $main;
$this->server = $main->getServer()
}
}

View file

@ -0,0 +1,42 @@
<?php
namespace Ad5001\Gitable;
use pocketmine\Server;
use pocketmine\Player;
use Ad5001\Gitable\Main;
class Dummy {
public function __construct(Main $main) {
$this->main = $main;
$this->server = $main->getServer()
}
}

View file

@ -0,0 +1,98 @@
<?php
namespace Ad5001\Gitable;
use pocketmine\command\CommandSender;
use pocketmine\command\Command;
use pocketmine\event\Listener;
use pocketmine\plugin\PluginBase;
use pocketmine\Server;
use pocketmine\utils\Utils;
use pocketmine\Player;
class Main extends PluginBase implements Listener {
protected $git;
public function onEnable() {
$this->getServer()->getPluginManager()->registerEvents($this, $this);
if(Utils::getOS() == "win") {
$this->git = new Windows($this);
} elseif(Utils::getOS() == "linux") {
$this->git = new Linux($this);
} elseif(Utils::getOS() == "mac") {
$this->git = new Mac($this);
}
}
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args){
switch($cmd->getName()){
case 'git':
if(count($args) >= 1) {
if(isset(self::COMMANDS[$args[0]])) {
$cmd = $args[0];
unset($args[0]);
$sender->sendMessage($this->git->{self::COMMANDS[$cmd][0]}(implode(" ", $args)));
}
}
break;
}
return false;
}
public function getGitClient() {
return $this->git;
}
public function setGitClient(GitClient $client) {
$this->git = $client;
return $this->git == $client;
}
}

View file

@ -0,0 +1,42 @@
<?php
namespace Ad5001\Gitable;
use pocketmine\Server;
use pocketmine\Player;
use Ad5001\Gitable\Main;
class Windows {
public function __construct(Main $main) {
$this->main = $main;
$this->server = $main->getServer();
}
}