2023-11-01 09:51:42 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Console\Commands\BlueprintFramework;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Pterodactyl\BlueprintFramework\Services\VariableService\BlueprintVariableService;
|
|
|
|
use Pterodactyl\BlueprintFramework\Libraries\ExtensionLibrary\Admin\BlueprintAdminLibrary as BlueprintExtensionLibrary;
|
|
|
|
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
|
|
|
|
|
|
|
class SyncCommand extends Command
|
|
|
|
{
|
|
|
|
protected $description = 'Forward some database values to Blueprint.';
|
|
|
|
protected $signature = 'bp:sync';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TelemetryCommand constructor.
|
|
|
|
*/
|
|
|
|
public function __construct(
|
|
|
|
private BlueprintVariableService $bp,
|
|
|
|
private BlueprintExtensionLibrary $blueprint,
|
|
|
|
private SettingsRepositoryInterface $settings,
|
|
|
|
) { parent::__construct(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle execution of command.
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
2023-11-01 09:59:08 -04:00
|
|
|
// TELEMETRY ID
|
|
|
|
// initialize telemetry id
|
2023-11-01 09:51:42 -04:00
|
|
|
if ($this->settings->get('blueprint::panel:id') == "" || $this->bp->version() != $this->settings->get('blueprint::version:cache')) {
|
2023-11-01 09:59:08 -04:00
|
|
|
$this->settings->set('blueprint::panel:id', uniqid(rand())."@".$this->bp->version());
|
|
|
|
$this->settings->set('blueprint::version:cache', $this->bp->version());
|
|
|
|
}
|
|
|
|
// set telemetry to true if empty
|
|
|
|
if ($this->settings->get('blueprint::telemetry') == "") {$this->settings->set('blueprint::telemetry', "true");}
|
|
|
|
// enable/disable telemetry if needed
|
|
|
|
if ($this->settings->get('blueprint::telemetry') == "false") {
|
|
|
|
$this->bp->config('TELEMETRY_ID','KEY_NOT_UPDATED');
|
|
|
|
} else {
|
|
|
|
$this->bp->config('TELEMETRY_ID',$this->settings->get("blueprint::panel:id"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// DEVELOPER MODE
|
2023-11-01 09:51:42 -04:00
|
|
|
$this->bp->config('DEVELOPER', $this->settings->get('blueprint::developer'));
|
|
|
|
}
|
|
|
|
}
|