Last active
November 18, 2016 15:57
-
-
Save HimbeersaftLP/a0d0528c298d319cfbda73d41b026bfd to your computer and use it in GitHub Desktop.
AutoMoney for EconomyAPI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: AutoMoney | |
main: AutoMoney\main | |
version: 1.0 | |
api: [2.1.0] | |
author: HimbeersaftLP | |
description: Give players money automatically! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Intervall in minutes to give money | |
time: 5 | |
# How many money? | |
money: 10 | |
# What message to send to the player: | |
msg: "You got 10 money!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AutoMoney; | |
use pocketmine\event\Listener; | |
use pocketmine\plugin\PluginBase; | |
class Main extends PluginBase implements Listener{ | |
public function onEnable(){ | |
$this->saveDefaultConfig(); | |
$server = $this->getServer(); | |
$server->getPluginManager()->registerEvents($this, $this); | |
$server->getScheduler()->scheduleRepeatingTask(new MoneyTask($this, $config = $this->getConfig()->getAll()), $config["time"]*400); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AutoMoney; | |
use pocketmine\scheduler\PluginTask; | |
use onebone\economyapi\EconomyAPI; | |
class MoneyTask extends PluginTask { | |
private $plugin; | |
public $config; | |
public function __construct($plugin, $config){ | |
parent::__construct($plugin); | |
$this->plugin = $this->getOwner(); | |
$this->config = $config; | |
} | |
public function onRun($currentTick){ | |
$this->eco = EconomyAPI::getInstance(); | |
foreach($this->plugin->getServer()->getOnlinePlayers() as $p) { | |
$this->eco->addMoney($p->getName(), $this->config["money"]); | |
$p->sendMessage($this->config["msg"]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment