Skip to content

Commit

Permalink
standardize values for native_minecraft_version and supported_minecra…
Browse files Browse the repository at this point in the history
…ft_versions; fixes #53
  • Loading branch information
jacobsandersen committed Nov 4, 2022
1 parent 4c3a34e commit 8479ff8
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/object/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,29 @@ public function __construct($resource) {

for ($idx = 0; $idx < count($resource['fields']); $idx++) {
$field = $resource['fields'][$idx];
$value = $field['actual_field_value'];

switch ($field['field_id']) {
case 'native_mc_version':
$this->native_minecraft_version = self::cleanupVersion($field['actual_field_value']);
if (is_null($value) || empty($value)) {
$this->native_minecraft_version = NULL;
} else {
$this->native_minecraft_version = self::cleanupVersion($value);
}
break;
case 'mc_versions':
$versions = array_map(
function($version) {
return self::cleanupVersion($version);
},
unserialize($field['actual_field_value'])
);
$this->supported_minecraft_versions = array_values($versions);
if (is_null($value) || empty($value)) {
$this->supported_minecraft_versions = array();
} else {
$versions = array_map(
function($version) {
return self::cleanupVersion($version);
},
unserialize($value)
);

$this->supported_minecraft_versions = array_values($versions);
}
break;
}
}
Expand Down

0 comments on commit 8479ff8

Please sign in to comment.