Check out the Internet Documentation, you can use `getURL` to fetch a page. Then you can convert the string to json. Internet Documentation: https://jenkins.pmmp.io/job/PocketM...1b/classpocketmine_1_1utils_1_1_internet.html PHP: function fetchJson(string $url){ $data = \pocketmine\utils\Internet::getURL($url); // This will get the data on the url $jsondata = json_decode($data); // Convert string to URL return $jsondata; // Returns the Data } Usage: PHP: $url = "https://gist.githubusercontent.com/ErikPDev/e6997ead97591d4d1c703efec26f82af/raw/c7de5291dcdbde8ecb70ed40acadd4e5f0d51557/file.json"; // URL var_dump( $this->fetchJson($url) );
Remind you, that these operations are thread blocking, you must fetch the data either on plugin load or in asynchronous task.
Agreed! Here's a async task Usage: PHP: Server::getInstance()->getAsyncPool()->submitTask(new GetURL("https://gist.githubusercontent.com/ErikPDev/e6997ead97591d4d1c703efec26f82af/raw/c7de5291dcdbde8ecb70ed40acadd4e5f0d51557/file.json")); Code: PHP: <?phpnamespace ErikX\PMMP;use pocketmine\scheduler\AsyncTask;use pocketmine\Server;use pocketmine\utils\Internet;use function json_decode;class GetURL extends AsyncTask{ /** @var string */ private $URL; public function __construct(string $URL){ $this->url = $URL; } public function onRun() : void{ $json = Internet::getURL($this->url); $this->setResult(json_decode($json)); } public function onCompletion(Server $server) : void{ $result = $this->getResult(); // do something here var_dump($result); }}