mirror of
https://github.com/slawkens/myaac.git
synced 2026-05-01 14:53:32 +02:00
[WIP] Initial Blacktek support - groups, vocations, items
items.toml loading through custom parser - no .toml reader that I tested can read it
This commit is contained in:
40
system/src/Server/TOML/ItemsParser.php
Normal file
40
system/src/Server/TOML/ItemsParser.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace MyAAC\Server\TOML;
|
||||
|
||||
class ItemsParser
|
||||
{
|
||||
public function parse(string $path): array
|
||||
{
|
||||
$ret = [];
|
||||
|
||||
$i = 0;
|
||||
$handle = fopen($path, "r");
|
||||
if ($handle) {
|
||||
$parse = '';
|
||||
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
if (str_contains($line, '[[items]]') && $i++ != 0) {
|
||||
//global $whoopsHandler;
|
||||
//$whoopsHandler->addDataTable('ini', [$parse]);
|
||||
$ret[] = parse_ini_string($parse);
|
||||
$parse = '';
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip lines like this
|
||||
// field = {type = "fire", initdamage = 20, ticks = 10000, count = 7, damage = 10}
|
||||
// as it cannot be parsed by parse_ini_string
|
||||
if (str_contains($line, 'field =')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$parse .= $line;
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user