mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-29 22:25:52 +00:00
TimingsCommand: some code cleanup
This commit is contained in:
parent
a97c7d3132
commit
a4aee98cba
@ -105,23 +105,23 @@ class TimingsCommand extends VanillaCommand{
|
|||||||
|
|
||||||
$host = $sender->getServer()->getProperty("timings.host", "timings.pmmp.io");
|
$host = $sender->getServer()->getProperty("timings.host", "timings.pmmp.io");
|
||||||
|
|
||||||
$sender->getServer()->getAsyncPool()->submitTask(new class([
|
$sender->getServer()->getAsyncPool()->submitTask(new class($sender, $host, $agent, $data) extends BulkCurlTask{
|
||||||
["page" => "https://$host?upload=true", "extraOpts" => [
|
|
||||||
CURLOPT_HTTPHEADER => [
|
|
||||||
"User-Agent: $agent",
|
|
||||||
"Content-Type: application/x-www-form-urlencoded"
|
|
||||||
],
|
|
||||||
CURLOPT_POST => true,
|
|
||||||
CURLOPT_POSTFIELDS => http_build_query($data),
|
|
||||||
CURLOPT_AUTOREFERER => false,
|
|
||||||
CURLOPT_FOLLOWLOCATION => false
|
|
||||||
]]
|
|
||||||
], $sender, $host) extends BulkCurlTask{
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $host;
|
private $host;
|
||||||
|
|
||||||
public function __construct(array $operations, $complexData = null, string $host){
|
public function __construct(CommandSender $sender, string $host, string $agent, array $data){
|
||||||
parent::__construct($operations, $complexData);
|
parent::__construct([
|
||||||
|
["page" => "https://$host?upload=true", "extraOpts" => [
|
||||||
|
CURLOPT_HTTPHEADER => [
|
||||||
|
"User-Agent: $agent",
|
||||||
|
"Content-Type: application/x-www-form-urlencoded"
|
||||||
|
],
|
||||||
|
CURLOPT_POST => true,
|
||||||
|
CURLOPT_POSTFIELDS => http_build_query($data),
|
||||||
|
CURLOPT_AUTOREFERER => false,
|
||||||
|
CURLOPT_FOLLOWLOCATION => false
|
||||||
|
]]
|
||||||
|
], $sender);
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,17 +136,13 @@ class TimingsCommand extends VanillaCommand{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(isset($result[0]) && is_array($response = json_decode($result[0], true)) && isset($response["id"])){
|
if(isset($result[0]) && is_array($response = json_decode($result[0], true)) && isset($response["id"])){
|
||||||
$pasteId = $response["id"];
|
|
||||||
}
|
|
||||||
if(isset($pasteId)){
|
|
||||||
$sender->sendMessage(new TranslationContainer("pocketmine.command.timings.timingsRead",
|
$sender->sendMessage(new TranslationContainer("pocketmine.command.timings.timingsRead",
|
||||||
["https://" . $this->host . "/?id=" . $pasteId]));
|
["https://" . $this->host . "/?id=" . $response["id"]]));
|
||||||
}else{
|
}else{
|
||||||
$sender->sendMessage(new TranslationContainer("pocketmine.command.timings.pasteError"));
|
$sender->sendMessage(new TranslationContainer("pocketmine.command.timings.pasteError"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
fclose($fileTimings);
|
fclose($fileTimings);
|
||||||
$sender->sendMessage(new TranslationContainer("pocketmine.command.timings.timingsWrite", [$timings]));
|
$sender->sendMessage(new TranslationContainer("pocketmine.command.timings.timingsWrite", [$timings]));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user