Skip to content

Commit 8479ff8

Browse files
standardize values for native_minecraft_version and supported_minecraft_versions; fixes #53
1 parent 4c3a34e commit 8479ff8

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

src/object/Resource.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,29 @@ public function __construct($resource) {
2424

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

2829
switch ($field['field_id']) {
2930
case 'native_mc_version':
30-
$this->native_minecraft_version = self::cleanupVersion($field['actual_field_value']);
31+
if (is_null($value) || empty($value)) {
32+
$this->native_minecraft_version = NULL;
33+
} else {
34+
$this->native_minecraft_version = self::cleanupVersion($value);
35+
}
3136
break;
3237
case 'mc_versions':
33-
$versions = array_map(
34-
function($version) {
35-
return self::cleanupVersion($version);
36-
},
37-
unserialize($field['actual_field_value'])
38-
);
39-
$this->supported_minecraft_versions = array_values($versions);
38+
if (is_null($value) || empty($value)) {
39+
$this->supported_minecraft_versions = array();
40+
} else {
41+
$versions = array_map(
42+
function($version) {
43+
return self::cleanupVersion($version);
44+
},
45+
unserialize($value)
46+
);
47+
48+
$this->supported_minecraft_versions = array_values($versions);
49+
}
4050
break;
4151
}
4252
}

0 commit comments

Comments
 (0)