Skip to content
This repository was archived by the owner on Oct 21, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: TimeCommander
main: LDX\TimeCommander\Main
version: 2.1
api: [1.0.0, 2.0.0]
api: [3.0.0]
author: LDX
load: POSTWORLD
website: https://github.com/LDX-MCPE/TimeCommander
29 changes: 16 additions & 13 deletions src/LDX/TimeCommander/Main.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
<?php
namespace LDX\TimeCommander;

use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\command\CommandExecuter;
use pocketmine\command\ConsoleCommandSender;
use pocketmine\Player;
use pocketmine\plugin\PluginBase;
use pocketmine\Server;
class Main extends PluginBase {
public function onEnable() {
$this->saveDefaultConfig();
$c = $this->getConfig()->getAll();
foreach ($c["Commands"] as $i) {
$this->getServer()->getScheduler()->scheduleRepeatingTask(new TimeCommand($this,$i["Command"]),$i["Time"] * 1200);
}
}
public function runCommand($cmd) {
$this->getServer()->dispatchCommand(new ConsoleCommandSender(),$cmd);
}
}
?>

class Main extends PluginBase{

public function onEnable(){
$this->saveDefaultConfig();
$c = $this->getConfig()->getAll();
foreach ($c["Commands"] as $i) {
$this->getScheduler()->scheduleRepeatingTask(new TimeCommand($this,$i["Command"]),$i["Time"] * 1200);
}
}

public function runCommand($cmd) {
$this->getServer()->dispatchCommand(new ConsoleCommandSender(),$cmd);
}
}
35 changes: 18 additions & 17 deletions src/LDX/TimeCommander/TimeCommand.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<?php
namespace LDX\TimeCommander;
use pocketmine\scheduler\PluginTask;

use pocketmine\scheduler\Task;
use pocketmine\Server;
class TimeCommand extends PluginTask {
public function __construct($plugin,$cmd) {
$this->plugin = $plugin;
$this->cmd = $cmd;
$this->start = false;
parent::__construct($plugin);
}
public function onRun($ticks) {
if($this->start) {
$this->plugin->runCommand($this->cmd);
} else {
$this->start = true;
}
}
}
?>

class TimeCommand extends Task {
public function __construct($plugin,$cmd) {
$this->plugin = $plugin;
$this->cmd = $cmd;
$this->start = false;
}
public function onRun(int $currentTick) {
if($this->start) {
$this->plugin->runCommand($this->cmd);
}else{
$this->start = true;
}
}
}