Skip to content

Commit

Permalink
Split Vars class
Browse files Browse the repository at this point in the history
  • Loading branch information
nmtho committed Dec 2, 2023
1 parent d6c3ac5 commit ded95c5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/thebigcrafter/omp/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace thebigcrafter\omp;

use Symfony\Component\Filesystem\Filesystem;
use thebigcrafter\omp\constants\Languages;
use thebigcrafter\omp\lang\Locale;
use function is_dir;
use function mkdir;
Expand All @@ -40,7 +41,7 @@ private static function saveAndLoadLanguageFiles() : void
@mkdir($langFolder);
}

foreach (Vars::AVAILABLE_LANGUAGES as $lang) {
foreach (Languages::AVAILABLE_LANGUAGES as $lang) {
$languageFilePath = OhMyPMMP::getInstance()->getDataFolder() . "lang/$lang.json";

if (!$fs->exists($languageFilePath)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@

declare(strict_types=1);

namespace thebigcrafter\omp;
namespace thebigcrafter\omp\constants;

final class Vars {
public const POGGIT_REPO_URL = "https://poggit.pmmp.io/releases.min.json?fields=name,version,artifact_url,html_url,license,downloads,score,api,deps,description_url,changelog_url";
public const AVAILABLE_LANGUAGES = ["en_US"];
final class Languages {
public const AVAILABLE_LANGUAGES = ["en_US"];
}
18 changes: 18 additions & 0 deletions src/thebigcrafter/omp/constants/Poggit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/*
* This file is part of oh-my-pmmp.
*
* (c) thebigcrafter <[email protected]>
*
* This source file is subject to the GPL-3.0 license that is bundled
* with this source code in the file LICENSE.
*/

declare(strict_types=1);

namespace thebigcrafter\omp\constants;

class Poggit {
public const REPO_URL = "https://poggit.pmmp.io/releases.min.json?fields=name,version,artifact_url,html_url,license,downloads,score,api,deps,description_url,changelog_url";
}
12 changes: 6 additions & 6 deletions src/thebigcrafter/omp/tasks/FetchDataTask.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php

/*
* This file is part of oh-my-pmmp.
Expand All @@ -16,6 +16,7 @@
use pocketmine\scheduler\AsyncTask;
use pocketmine\utils\Internet;
use pocketmine\utils\InternetRequestResult;
use thebigcrafter\omp\constants\Poggit;
use thebigcrafter\omp\Language;
use thebigcrafter\omp\OhMyPMMP;
use thebigcrafter\omp\pool\PoggitPluginsPool;
Expand All @@ -24,17 +25,16 @@
use thebigcrafter\omp\types\Plugin;
use thebigcrafter\omp\types\PluginVersion;
use thebigcrafter\omp\Utils;
use thebigcrafter\omp\Vars;
use function array_map;
use function count;
use function json_decode;
use function array_map;
use function count;
use function json_decode;
use function strval;

class FetchDataTask extends AsyncTask
{
public function onRun() : void
{
$res = Internet::getURL(Vars::POGGIT_REPO_URL);
$res = Internet::getURL(Poggit::REPO_URL);

if (!$res instanceof InternetRequestResult) {
return;
Expand Down

0 comments on commit ded95c5

Please sign in to comment.