Muqsit / Tebex

Tebex plugin for PocketMine-MP servers
https://poggit.pmmp.io/ci/Muqsit/Tebex
32 stars 6 forks source link
api3 buycraft phpstan-l8 phpstan-strict plugin pmmp pocketmine tebex

Tebex

Tebex webstore integration for PocketMine-MP.

Features

Developer Docs

At the moment, there isn't a method to interact with this plugin. The plugin however has the Tebex API and handling split — tebex/handler/* makes use of TebexAPI. You can create a new TebexAPI instance and supply any valid secret to it and call tebex endpoints. All method calls in TebexAPI are run on child thread(s) so you'll need to supply a TebexResponseHandler $callback to retrieve responses.

TebexAPI::getInformation(TebexResponseHandler $callback) : void

You may construct a new TebexResponseHandler(Closure<TebexResponse, void> $on_success, Closure<TebexException, void> $on_failure), or use the helper methods:

$api->getInformation(TebexResponseHandler::onSuccess(function(TebexInformation $information) : void{ $account_info = $this->information->getAccount(); $server_info = $this->information->getServer(); }));

$api->lookup("Steve", TebexResponseHandler::onSuccess(function(TebexUser $user) : void{ var_dump($user->getChargebackRate()); }));

$api->lookup("Alex", TebexResponseHandler::debug(TebexUser::class)); // var_dump()s the TebexUser on success

$api->waitAll(); // wait until all queued requests have received responses $api->shutdown(); // shutdown connection (stops all threads and unlinks temp SSL files)


Not all Tebex endpoints have been implemented in TebexAPI. You may create an issue or a PR adding the missing ones or create one yourself (take a look at classes in `tebex\api`, use `TebexAPI::request(TebexRequest, TebexResponseHandler)` to dispatch custom ones).

## Notes
The [official Tebex plugin for PocketMine](https://github.com/tebexio/BuycraftPM) runs refresh tasks on main thread, freezing the server based on Tebex <-> Your Minecraft Server
latency. It executes Tebex API calls while having `CURLOPT_SSL_VERIFYPEER` disabled, thereby allowing man-in-the-middle (MITM) attacks and has some unnecessary commands that
do not suit Bedrock Edition (the `/buy` GUI command) which is why I decided to write a tebex integration plugin from scratch.