-
Notifications
You must be signed in to change notification settings - Fork 11
PluginAPI
PluginAPI is important if you make a plugin which has any affects to the gameplay including block breaking, exploits, or any kind of features that flags to the Zuri.
You need to import these following class:
use ReinfyTeam\Zuri\API;
After API
is imported, you can use the following functions that are available to plugin:
You may see them on API.php
To create your own event listener, here's some example on how to do it:
-
CheckFailedEvent
: When player failed a module.. Here's breif example://... public function onFail(CheckFailedEvent $event) : void { $playerAPI = $event->getPlayer(); $api = $event->getAPI(); $player->getPlayer()->sendMessage($event->getSupplier() . " " . "(" . $event->getSubType() . ") has been canceled due to test."); $event->cancel(); // cancel the failure... } //...
These are the Tutorials on how to use PluginAPI to your plugin:
To get the PlayerAPI instance, all you need to do is call this function:
$player = API::getPlayer(<string|pocketmine\player\Player class>);
To get the module, you can use these functions:
$module = API::getModule(<module_name: (cAse SeNsItIvE) ex. Speed>, <subType: ex. A>); // returns null when module is not found.
$module->enabled = false; // disable the module.
To do this, all you need to do is:
$modules = API::getAllModules(); // returns array of modules in class
// ex. display them all
foreach($modules as $module) {
$this->getLogger()->info($module->getName() . " " . $module->getSubType());
}
$info = API::allModulesInfo(); // returns array of modules in strings
// ex. display them all
foreach($modules as $module) {
$this->getLogger()->info($info["name"] . " " . $info["subType"]);
}
If you want to access the Zuri PluginBase just use:
$plugin = API::getPluginInstance(); // returns Zuri PluginBase if it is enabled.
If the server you are using a method intended for the digging of special players:
// $player must instance of Player from PMMP //
$player = API::getPlayer($player);
$api->setAttackSpecial(< true or false >);
$api->setBlocksBrokeASec(< it must is number >);
To get ConfigManager instance, just use:
$config = API::getConfig();
// example:
$message = $config->getData($config::PREFIX . " Hello world!");
$player->sendMessage($message);
To get discord webhook config, just use:
$config = API::getDiscordWebhookConfig();