Muqsit / PlayerVaults

Per-player GUI-based vaults plugin for PocketMine-MP
https://poggit.pmmp.io/p/PlayerVaults
GNU Lesser General Public License v2.1
41 stars 33 forks source link

open a player vault from a plugin #105

Closed EmporiumPvP closed 1 year ago

EmporiumPvP commented 1 year ago

How can i send a vault to a player when they click on an item in an invmenu? i tried using the API from the plugin but idk what dataFolder, file or resourceProvider is

Muqsit commented 1 year ago

There is currently no API method to access vaults of a player. For now, you may execute $player->chat("/pv {$number}");

EmporiumPvP commented 1 year ago

ok thanks

Muqsit commented 1 year ago

I've introduced a few API methods in v3.5.0. This method should be sufficient for your use-case:

/** @var Player $player */
/** @var PlayerVaults $plugin */
$plugin = Server::getInstance()->getPluginManager()->getPlugin("PlayerVaults");

$plugin->openVaultWithPermission($player, $player->getName(), 1);

README contains some more example API usages: https://github.com/Muqsit/PlayerVaults#example-api-usage As poggit is down, you may use the phar file linked with the tag v0.3.5: https://github.com/Muqsit/PlayerVaults/releases/tag/v3.5.0

EmporiumPvP commented 1 year ago

thank you I appreciate it

EmporiumPvP commented 1 year ago

i think the phar is messed up, if i use the source code it works fine but with the phar it cant find anything

EmporiumPvP commented 1 year ago

playervaults error

Muqsit commented 1 year ago

playervaults error

An IDE wouldn't be able to resolve the exact type of $vaults in this context unless you write a PHPDoc type:

use muqsit\playervaults\PlayerVaults;
...
/** @var PlayerVaults $vaults */
$vaults = Server::getInstance()->getPluginManager()->getPlugin("PlayerVaults");