mirror of
https://github.com/slawkens/myaac.git
synced 2026-03-16 16:03:31 +01:00
Copilot fixes
This commit is contained in:
@@ -16,7 +16,13 @@ use MyAAC\Models\Spell;
|
||||
|
||||
class Items
|
||||
{
|
||||
public static $items;
|
||||
public static array $items;
|
||||
|
||||
private static string $error = '';
|
||||
|
||||
public static function getError(): string {
|
||||
return self::$error;
|
||||
}
|
||||
|
||||
public static function load(): bool {
|
||||
$file_path = config('data_path') . 'items/items.toml';
|
||||
@@ -27,10 +33,14 @@ class Items
|
||||
$items = new Server\XML\Items();
|
||||
}
|
||||
else {
|
||||
self::$error = 'Cannot load items.xml or items.toml file. Files not found.';
|
||||
return false;
|
||||
}
|
||||
|
||||
$items->load();
|
||||
if (!$items->load()) {
|
||||
self::$error = $items->getError();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use MyAAC\Cache\Cache;
|
||||
|
||||
class Groups
|
||||
{
|
||||
private static array $groups;
|
||||
private static array $groups = [];
|
||||
|
||||
public function __construct() {
|
||||
self::$groups = Cache::remember('groups', 10 * 60, function () {
|
||||
|
||||
@@ -6,7 +6,7 @@ use Devium\Toml\Toml;
|
||||
|
||||
class Groups
|
||||
{
|
||||
private array $groups;
|
||||
private array $groups = [];
|
||||
|
||||
public function load(): void
|
||||
{
|
||||
@@ -14,7 +14,7 @@ class Groups
|
||||
|
||||
if(!@file_exists($file)) {
|
||||
error('Error: Cannot load groups.toml. More info in system/logs/error.log file.');
|
||||
log_append('error.log', '[OTS_Groups_List.php] Fatal error: Cannot load groups.toml (' . $file . '). It doesnt exist.');
|
||||
log_append('error.log', "[OTS_Groups_List.php] Fatal error: Cannot load groups.toml ($file). It doesn't exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,20 @@ class Items
|
||||
return !in_array($key, ['id', 'article', 'name', 'plural']);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
$items[$item['id']] = ['article' => $item['article'], 'name' => $item['name'], 'plural' => $item['plural'] ?? '', 'attributes' => $attributes];
|
||||
$id = $item['id'] ?? null;
|
||||
if ($id === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$article = $item['article'] ?? '';
|
||||
$name = $item['name'] ?? '';
|
||||
$plural = $item['plural'] ?? '';
|
||||
$items[$id] = [
|
||||
'article' => $article,
|
||||
'name' => $name,
|
||||
'plural' => $plural,
|
||||
'attributes' => $attributes,
|
||||
];
|
||||
}
|
||||
|
||||
$cache_php = new CachePHP(config('cache_prefix'), CACHE . 'persistent/');
|
||||
|
||||
@@ -6,14 +6,14 @@ use Devium\Toml\Toml;
|
||||
|
||||
class Vocations
|
||||
{
|
||||
private array $vocations;
|
||||
private array $vocationsFrom;
|
||||
private array $vocations = [];
|
||||
private array $vocationsFrom = [];
|
||||
|
||||
public function load(): void
|
||||
{
|
||||
$tomlVocations = glob(config('data_path') . 'vocations/*.toml');
|
||||
if (count($tomlVocations) <= 0) {
|
||||
throw new \RuntimeException('ERROR: Cannot load any <i>.toml</i> vocation in the data/vocations folder.');
|
||||
throw new \RuntimeException('ERROR: Cannot load any .toml vocation from the data/vocations folder.');
|
||||
}
|
||||
|
||||
foreach ($tomlVocations as $file) {
|
||||
|
||||
@@ -6,8 +6,8 @@ use MyAAC\Cache\Cache;
|
||||
|
||||
class Vocations
|
||||
{
|
||||
private static array $vocations;
|
||||
private static array $vocationsFrom;
|
||||
private static array $vocations = [];
|
||||
private static array $vocationsFrom = [];
|
||||
|
||||
public function __construct() {
|
||||
$cached = Cache::remember('vocations', 10 * 60, function () {
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace MyAAC\Server\XML;
|
||||
|
||||
class Groups
|
||||
{
|
||||
private array $groups;
|
||||
private array $groups = [];
|
||||
|
||||
public function load(): void
|
||||
{
|
||||
@@ -12,7 +12,7 @@ class Groups
|
||||
|
||||
if(!@file_exists($file)) {
|
||||
error('Error: Cannot load groups.xml. More info in system/logs/error.log file.');
|
||||
log_append('error.log', '[OTS_Groups_List.php] Fatal error: Cannot load groups.xml (' . $file . '). It doesnt exist.');
|
||||
log_append('error.log', "[OTS_Groups_List.php] Fatal error: Cannot load groups.xml ($file). It doesn't exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace MyAAC\Server\XML;
|
||||
|
||||
class Vocations
|
||||
{
|
||||
private array $vocations;
|
||||
private array $vocationsFrom;
|
||||
private array $vocations = [];
|
||||
private array $vocationsFrom = [];
|
||||
|
||||
public function load(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user