Ekonomy
What does this plugin do?
Similar to EconomyAPI, This economy plugin is optimized with asynchronous query libraries such as libasynql and await-generator, this plugin strictly supports API version 4.0.0 with PHP8.
Usage
API Plugin
This plugin works as API and economy management plugin.
Commands:
Command | Description | Permission | Default |
---|---|---|---|
/givemoney |
Gives money to a player from your account. | ekonomy.cmd.givemoney |
op |
/mymoney |
See your money. | ekonomy.cmd.mymoney |
true |
/pay |
Pay amount of money to a player. | ekonomy.cmd.pay |
true |
/seemoney |
See a player's money. | ekonomy.cmd.seemoney |
op |
/setmoney |
Set the player's money to specified amount. | ekonomy.cmd.setmoney |
op |
/takemoney |
Takes money from player's account. | ekonomy.cmd.takemoney |
op |
/topmoney |
See the top richest players in server. | ekonomy.cmd.topmoney |
true |
API Documentation
Getting a player's money
use octopush\ekonomy\api\EkonomyAPI;
/**
* @param string|Player $player The player from whom you want to get the money.
* @return int|float the player's money
*/
public static function myMoney(string|Player $player): int|float;
Setting player's money
use octopush\ekonomy\api\EkonomyAPI;
/**
* @param string|Player $player The player from whom you want to set the money.
* @param int|float $amount The money amount
* @return void
*/
public static function setMoney(string|Player $player, int|float $amount): void;
Adding amount of money to a player
use octopush\ekonomy\api\EkonomyAPI;
/**
* @param string|Player $player The player from whom you want to add the money.
* @param int|float $amount The money amount
* @return void
*/
public static function addMoney(string|Player $player, int|float $amount): void;
Reducing amount of money to a player
use octopush\ekonomy\api\EkonomyAPI;
/**
* @param string|Player $player
* @param int|float $amount
* @return void
*/
public static function reduceMoney(string|Player $player, int|float $amount): void;
Getting all the money from database
use octopush\ekonomy\api\EkonomyAPI;
/**
* @return array all the player's money
*/
#[ArrayShape(["name" => "int|float"])]
public static function getAllMoney(): array;
This function returns an username => money
array.
Event Handling
AddMoneyEvent
use octopush\ekonomy\event\money\AddMoneyEvent;
public function onAddMoney(AddMoneyEvent $event): void {
$receiver = $event->getReceiver();
$issuer = $event->getIssuer();
$amount = $event->getAmount();
$onlineReceiver = $event->getOnlineReceiver(); // Returns the player's object in case it is online.
}
MoneyChangeEvent
use octopush\ekonomy\event\money\MoneyChangeEvent;
public function onMoneyChange(MoneyChangeEvent $event): void {
$player = $event->getPlayer(); // The player to whom the money was changed.
$issuer = $event->getIssuer();
$amount = $event->getAmount();
$oldMoney = $event->getOldMoney();
$newMoney = $event->getNewMoney();
$onlinePlayer = $event->getOnlinePlayer(); // Returns the player's object in case it is online.
}
MoneyReduceEvent
use octopush\ekonomy\event\money\MoneyReduceEvent;
public function onMoneyReduce(MoneyReduceEvent $event): void {
$player = $event->getPlayer(); // The player to whom the money was reduced.
$issuer = $event->getIssuer();
$amount = $event->getAmount(); // The amount reduced
$onlinePlayer = $event->getOnlinePlayer(); // Returns the player's object in case it is online.
}
MoneySetEvent
use octopush\ekonomy\event\money\MoneySetEvent;
public function onMoneySet(MoneySetEvent $event): void {
$player = $event->getPlayer(); // The player to whom the money was setted.
$issuer = $event->getIssuer();
$money = $event->getMoney(); // The new player money
$onlinePlayer = $event->getOnlinePlayer(); // Returns the player's object in case it is online.
}
PlayerBankruptEvent
use octopush\ekonomy\event\player\PlayerBankruptEvent;
public function onPlayerBankrupt(PlayerBankruptEvent $event): void {
$player = $event->getPlayer(); // The bankrupt player.
}
PlayerPayEvent
use octopush\ekonomy\event\player\PlayerPayEvent;
public function onPlayerPay(PlayerPayEvent $event): void {
$receiver = $event->getReceiver();
$sender = $event->getSender();
$amount = $event->getAmount();
$onlineReceiver = $event->getOnlineReceiver(); // Returns the player's object in case it is online.
}
Frequently Asked Questions
Q. What is the difference between this plugin and EconomyAPI?
A. This plugin is designed with best practices of asynchronous programming, you will have no lags or overloads on your PocketMine server.