Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/muqsit/playervaults
Per-player GUI-based vaults plugin for PocketMine-MP
https://github.com/muqsit/playervaults
pmmp pocketmine-mp pocketmine-mp-plugin
Last synced: 3 months ago
JSON representation
Per-player GUI-based vaults plugin for PocketMine-MP
- Host: GitHub
- URL: https://github.com/muqsit/playervaults
- Owner: Muqsit
- License: lgpl-2.1
- Created: 2017-04-28T13:21:28.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-07-23T04:27:56.000Z (over 1 year ago)
- Last Synced: 2024-10-09T23:03:59.285Z (3 months ago)
- Topics: pmmp, pocketmine-mp, pocketmine-mp-plugin
- Language: PHP
- Homepage: https://poggit.pmmp.io/p/PlayerVaults
- Size: 407 KB
- Stars: 41
- Watchers: 11
- Forks: 33
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PlayerVaults
[![](https://poggit.pmmp.io/shield.dl.total/PlayerVaults)](https://poggit.pmmp.io/p/PlayerVaults)
[![](https://poggit.pmmp.io/shield.api/PlayerVaults)](https://poggit.pmmp.io/p/PlayerVaults)A PocketMine-MP plugin that gives players a secondary portable inventor(y/ies) of 54 slots in size. These inventories can be accessed anywhere!
## Usage
Run `/pv 1` to access your personal Vault #1.
![img.png](images/screenshot-vault-1.png)## Wiki
Refer to the [PlayerVaults Wiki](https://github.com/Muqsit/PlayerVaults/wiki) to get help with commands and permissions.## Example API Usage
Opening player's vault #1 as a `$player`.```php
use muqsit\playervaults\PlayerVaults;
use muqsit\playervaults\PlayerVaultsException;use muqsit\playervaults\vault\Vault;use pocketmine\player\Player;
use pocketmine\Server;/** @var Player $player */
/** @var PlayerVaults $plugin */
$plugin = Server::getInstance()->getPluginManager()->getPlugin("PlayerVaults");// without debug messages:
$plugin->openVaultWithPermission($player, $player->getName(), 1);// with debug messages:
$plugin->openVaultWithPermission($player, $player->getName(), 1, function(Vault $vault) use($player) : void{
$player->sendMessage("Successfully opened vault");
}, function(PlayerVaultsException $exception) use($plugin) : void{
$plugin->getLogger()->debug("Failed to open vault: {$exception->getMessage()} (code: {$exception->getCode()})");
});
```Opening another player (`Alex`)'s vault #1 as a `$player`.
```php
use muqsit\playervaults\PlayerVaults;
use pocketmine\player\Player;
use pocketmine\Server;/** @var Player $player */
/** @var PlayerVaults $plugin */
$plugin = Server::getInstance()->getPluginManager()->getPlugin("PlayerVaults");
$plugin->openVaultWithPermission($player, "Alex", 1);
```Forcefully (skipping permission checks) opening another player (`Alex`)'s vault #1 as a `$player`.
```php
use muqsit\playervaults\PlayerVaults;
use pocketmine\player\Player;
use pocketmine\Server;/** @var Player $player */
/** @var PlayerVaults $plugin */
$plugin = Server::getInstance()->getPluginManager()->getPlugin("PlayerVaults");
$plugin->openVault($player, "Alex", 1);
```Reading and writing to a specific vault (player `Alex`'s vault #1).
```php
use muqsit\playervaults\PlayerVaults;
use muqsit\playervaults\vault\Vault;
use muqsit\playervaults\vault\VaultAccess;
use pocketmine\item\VanillaItems;
use pocketmine\Server;/** @var PlayerVaults $plugin */
$plugin = Server::getInstance()->getPluginManager()->getPlugin("PlayerVaults");
$plugin->loadVault("Alex", 1, function(Vault $vault, VaultAccess $access) : void{
$inventory = $vault->getInventory();
$item = $inventory->getItem(0); // item in first slot
$inventory->addItem(VanillaItems::APPLE());
$access->release(); // unloads vault and if necessary, saves vault
});
```Writing to a specific vault asynchronously.
```php
use muqsit\playervaults\PlayerVaults;
use muqsit\playervaults\vault\Vault;
use muqsit\playervaults\vault\VaultAccess;
use pocketmine\item\VanillaItems;
use pocketmine\scheduler\ClosureTask;/** @var PlayerVaults $plugin */
$scheduler = $plugin->getScheduler();
$plugin->loadVault("Alex", 1, function(Vault $vault, VaultAccess $access) use($scheduler) : void{
$inventory = $vault->getInventory();
$scheduler->scheduleRepeatingTask(new ClosureTask(function() use($inventory, $access) : void{
$inventory->addItem(VanillaItems::APPLE());
$access->release();
}), 100);
});
```