mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Fixed resource packs with comments in manifest
MOJANG, THERE'S NO SUCH THING AS COMMENTS IN STANDARD JSON
This commit is contained in:
parent
a71af952ba
commit
6417cff618
@ -30,7 +30,8 @@
|
|||||||
"pocketmine/nbt": "^0.2.1",
|
"pocketmine/nbt": "^0.2.1",
|
||||||
"pocketmine/math": "^0.2.0",
|
"pocketmine/math": "^0.2.0",
|
||||||
"pocketmine/snooze": "^0.1.0",
|
"pocketmine/snooze": "^0.1.0",
|
||||||
"daverandom/callback-validator": "dev-master"
|
"daverandom/callback-validator": "dev-master",
|
||||||
|
"adhocore/json-comment": "^0.0.7"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
46
composer.lock
generated
46
composer.lock
generated
@ -4,8 +4,52 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "2d120a3dd7d68958809c3662d1cb7c99",
|
"content-hash": "d3fb809caf4d5a5c99054f47f28ff271",
|
||||||
"packages": [
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "adhocore/json-comment",
|
||||||
|
"version": "v0.0.7",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/adhocore/php-json-comment.git",
|
||||||
|
"reference": "135356c7e7336ef59924f1d921c770045f937a76"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/adhocore/php-json-comment/zipball/135356c7e7336ef59924f1d921c770045f937a76",
|
||||||
|
"reference": "135356c7e7336ef59924f1d921c770045f937a76",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.4"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.5"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Ahc\\Json\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Jitendra Adhikari",
|
||||||
|
"email": "jiten.adhikary@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Lightweight JSON comment stripper library for PHP",
|
||||||
|
"keywords": [
|
||||||
|
"comment",
|
||||||
|
"json",
|
||||||
|
"strip-comment"
|
||||||
|
],
|
||||||
|
"time": "2018-08-01T12:27:26+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "daverandom/callback-validator",
|
"name": "daverandom/callback-validator",
|
||||||
"version": "dev-master",
|
"version": "dev-master",
|
||||||
|
@ -25,6 +25,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\resourcepacks;
|
namespace pocketmine\resourcepacks;
|
||||||
|
|
||||||
|
|
||||||
|
use Ahc\Json\Comment as CommentedJsonDecoder;
|
||||||
|
|
||||||
class ZippedResourcePack implements ResourcePack{
|
class ZippedResourcePack implements ResourcePack{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,10 +88,13 @@ class ZippedResourcePack implements ResourcePack{
|
|||||||
|
|
||||||
$archive->close();
|
$archive->close();
|
||||||
|
|
||||||
$manifest = json_decode($manifestData);
|
//maybe comments in the json, use stripped decoder (thanks mojang)
|
||||||
if($manifest === null){
|
try{
|
||||||
throw new ResourcePackException("Failed to parse manifest.json: " . json_last_error_msg());
|
$manifest = (new CommentedJsonDecoder())->decode($manifestData);
|
||||||
|
}catch(\RuntimeException $e){
|
||||||
|
throw new ResourcePackException("Failed to parse manifest.json: " . $e->getMessage(), $e->getCode(), $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!self::verifyManifest($manifest)){
|
if(!self::verifyManifest($manifest)){
|
||||||
throw new ResourcePackException("manifest.json is missing required fields");
|
throw new ResourcePackException("manifest.json is missing required fields");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user