BedrockEconomy
An extremely customizable Economy plugin designed for scalability and simplicity
Install / Use
/learn @cooldogepm/BedrockEconomyREADME
BedrockEconomy
BedrockEconomy is an economy plugin made for PocketMine-MP focused on stability and simplicity. <br>
Table of Contents
Commands
| Name | Description | Usage | Permission |
|---------------| ----------- |---------------------------------------------------|----------------------------------------|
| balance | Show your and others balance | balance [player: string] | bedrockeconomy.command.balance |
| pay | Pay others with your balance | pay <player: string> <amount: number> | bedrockeconomy.command.pay |
| rich | View the top balances | rich [page: number] | bedrockeconomy.command.rich |
| addbalance | Add points to others balance | addbalance <player: string> <amount: number> | bedrockeconomy.command.addbalance |
| removebalance | Remove points from others balance | removebalance <player: string> <amount: number> | bedrockeconomy.command.removebalance |
| setbalance | Set others balance | setbalance <player: string> <balance: number> | bedrockeconomy.command.setbalance |
Features
- [x] MySQL Database
- [x] SQLite Database
- [x] Async API
- [x] Closure API
- [x] Customizable
- [x] Easy to use
- [x] Lightweight
- [x] Fast and efficient
- [x] Cache system
Examples
Retrieving a Player's Balance
You can retrieve a player's balance using the get method. Here's an example:
BedrockEconomyAPI::CLOSURE()->get(
xuid: "123456789",
username: "Doge",
onSuccess: static function (array $result): void {
echo "Balance: " . $result["amount"] . " Decimals: " . $result["decimals"] . " Position: " . $result["position"];
},
onError: static function (SQLException $exception): void {
if ($exception instanceof RecordNotFoundException) {
echo "Record not found";
return;
}
echo $exception->getMessage();
}
);
// Using async-await
Await::f2c(
function (): Generator {
try {
$result = yield from BedrockEconomyAPI::ASYNC()->get(
xuid: "123456789",
username: "Doge",
);
} catch (RecordNotFoundException) {
echo "Account not found";
return;
} catch (SQLException) {
echo "Database error";
return;
}
echo "Balance: " . $result["amount"] . " Decimals: " . $result["decimals"] . " Position: " . $result["position"];
}
);
Retrieving Multiple Player Balances
You can retrieve multiple player balances using the bulk method. Here's an example:
BedrockEconomyAPI::CLOSURE()->bulk(
list: ["Doge", "123456789"], // You can use both username and xuid
onSuccess: static function (array $result): void {
foreach ($result as $data) {
echo "Player: " . $data["username"] . " Balance: " . $data["amount"] . " Decimals: " . $data["decimals"] . " Position: " . $data["position"];
}
},
onError: static function (SQLException $exception): void {
if ($exception instanceof RecordNotFoundException) {
echo "No records found";
return;
}
echo $exception->getMessage();
}
);
// Using async-await
Await::f2c(
function (): Generator {
try {
$result = yield from BedrockEconomyAPI::ASYNC()->bulk(
list: ["Doge", "123456789"], // You can use both username and xuid
);
} catch (RecordNotFoundException) {
echo "No records found";
return;
} catch (SQLException) {
echo "Database error";
return;
}
foreach ($result as $data) {
echo "Player: " . $data["username"] . " Balance: " . $data["amount"] . " Decimals: " . $data["decimals"] . " Position: " . $data["position"];
}
}
);
Adding Funds to a Player's Balance
You can add funds to a player's balance using the add method. Here's an example:
BedrockEconomyAPI::CLOSURE()->add(
xuid: "123456789",
username: "Doge",
amount: 55,
decimals: 25,
onSuccess: static function (): void {
echo 'Balance updated successfully.';
},
onError: static function (SQLException $exception): void {
if ($exception instanceof RecordNotFoundException) {
echo 'Account not found';
return;
}
echo 'An error occurred while updating the balance.';
}
);
// Using async-await
Await::f2c(
function () use ($player): Generator {
try {
yield from BedrockEconomyAPI::ASYNC()->add(
xuid: "123456789",
username: "Doge",
amount: 55,
decimals: 25,
);
echo 'Balance updated successfully.';
} catch (RecordNotFoundException) {
echo 'Account not found';
} catch (SQLException) {
echo 'An error occurred while updating the balance.';
}
}
);
Subtracting Funds from a Player's Balance
You can subtract funds from a player's balance using the subtract method. Here's an example:
BedrockEconomyAPI::CLOSURE()->subtract(
xuid: "123456789",
username: "Doge",
amount: 55,
decimals: 25,
onSuccess: static function (): void {
echo 'Balance updated successfully.';
},
onError: static function (SQLException $exception): void {
if ($exception instanceof RecordNotFoundException) {
echo 'Account not found';
return;
}
if ($exception instanceof InsufficientFundsException) {
echo 'Insufficient funds';
return;
}
echo 'An error occurred while updating the balance.';
}
);
// Using async-await
Await::f2c(
function () use ($player): Generator {
try {
yield from BedrockEconomyAPI::ASYNC()->subtract(
xuid: "123456789",
username: "Doge",
amount: 55,
decimals: 25,
);
echo 'Balance updated successfully.';
} catch (RecordNotFoundException) {
echo 'Account not found';
} catch (InsufficientFundsException) {
echo 'Insufficient funds';
} catch (SQLException) {
echo 'An error occurred while updating the balance.';
}
}
);
Transferring Funds Between Players
You can transfer funds from one player to another using the transfer method. Here's an example:
$sourcePlayer = ['xuid' => 'source_xuid', 'username' => 'source_username'];
$targetPlayer = ['xuid' => 'target_xuid', 'username' => 'target_username'];
BedrockEconomyAPI::CLOSURE()->transfer(
source: $sourcePlayer,
target: $targetPlayer,
amount: 55,
decimals: 25,
onSuccess: static function (): void {
echo 'Balance transfer successful.';
},
onError: static function (SQLException $exception): void {
if ($exception instanceof RecordNotFoundException) {
echo 'Account not found';
return;
}
if ($exception instanceof InsufficientFundsException) {
echo 'Insufficient funds';
return;
}
echo 'An error occurred during the balance transfer.';
}
);
// Using async-await
Await::f2c(
function () use ($sourcePlayer, $targetPlayer): Generator {
try {
yield from BedrockEconomyAPI::ASYNC()->transfer(
source: $sourcePlayer,
target: $targetPlayer,
amount: 55,
decimals: 25,
);
echo 'Balance transfer successful.';
} catch (RecordNotFoundException) {
echo 'Account not found';
} catch (InsufficientFundsException) {
echo 'Insufficient funds';
} catch (SQLException) {
echo 'An error occurred during the balance transfer.';
}
}
);
These examples demonstrate how to perform common operations using the BedrockEconomy API, such as retrieving player balances, adding and subtracting funds, and transferring funds between players.
Tools
License
This project is released under the MIT License. For more information, please refer to the LICENSE file.
Related Skills
gh-issues
354.3kFetch GitHub issues, spawn sub-agents to implement fixes and open PRs, then monitor and address PR review comments. Usage: /gh-issues [owner/repo] [--label bug] [--limit 5] [--milestone v1.0] [--assignee @me] [--fork user/repo] [--watch] [--interval 5] [--reviews-only] [--cron] [--dry-run] [--model glm-5] [--notify-channel -1002381931352]
oracle
354.3kBest practices for using the oracle CLI (prompt + file bundling, engines, sessions, and file attachment patterns).
taskflow
354.3kUse when work should span one or more detached tasks but still behave like one job with a single owner context. TaskFlow is the durable flow substrate under authoring layers like Lobster, ACPX, plugins, or plain code. Keep conditional logic in the caller; use TaskFlow for flow identity, child-task linkage, waiting state, revision-checked mutations, and user-facing emergence.
tmux
354.3kRemote-control tmux sessions for interactive CLIs by sending keystrokes and scraping pane output.
