Skip to content

Commit

Permalink
Update Task
Browse files Browse the repository at this point in the history
  • Loading branch information
PJK12 committed Jun 6, 2018
1 parent 2e75fbc commit 0c71b76
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion EconomyAPI/src/onebone/economyapi/EconomyAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public function onEnable(){
$this->initialize();

if($this->getConfig()->get("auto-save-interval") > 0){
$this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new SaveTask($this), $this->getConfig()->get("auto-save-interval") * 1200, $this->getConfig()->get("auto-save-interval") * 1200);
$this->getScheduler()->scheduleDelayedRepeatingTask(new SaveTask($this), $this->getConfig()->get("auto-save-interval") * 1200, $this->getConfig()->get("auto-save-interval") * 1200);
}

$this->getServer()->getPluginManager()->registerEvents($this, $this);
Expand Down
10 changes: 6 additions & 4 deletions EconomyAPI/src/onebone/economyapi/task/MySQLPingTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,22 @@


use onebone\economyapi\EconomyAPI;
use pocketmine\scheduler\PluginTask;
use pocketmine\scheduler\Task;

class MySQLPingTask extends PluginTask{
class MySQLPingTask extends Task{
private $mysql;

private $plugin

public function __construct(EconomyAPI $plugin, \mysqli $mysql){
parent::__construct($plugin);
$this->plugin = $plugin;

$this->mysql = $mysql;
}

public function onRun(int $currentTick){
if(!$this->mysql->ping()){
$this->getOwner()->openProvider();
$this->plugin->openProvider();
}
}
}
9 changes: 5 additions & 4 deletions EconomyAPI/src/onebone/economyapi/task/SaveTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@

use onebone\economyapi\EconomyAPI;

use pocketmine\scheduler\PluginTask;
use pocketmine\scheduler\Task;

class SaveTask extends PluginTask {
class SaveTask extends Task {
private $plugin;
public function __construct(EconomyAPI $plugin){
parent::__construct($plugin);
$this->plugin = $plugin;
}

public function onRun(int $currentTick){
$this->getOwner()->saveAll();
$this->plugin->saveAll();
}
}

0 comments on commit 0c71b76

Please sign in to comment.