Don't use Config for builtin JSON resources

it doesn't make sense to use a config in these cases, and also it just hides problems when the files are missing.
This commit is contained in:
Dylan K. Taylor 2018-06-16 16:35:47 +01:00
parent cc97f76ec9
commit 9f7f62e9e5
2 changed files with 4 additions and 6 deletions

View File

@ -29,7 +29,6 @@ use pocketmine\network\mcpe\protocol\BatchPacket;
use pocketmine\network\mcpe\protocol\CraftingDataPacket;
use pocketmine\Server;
use pocketmine\timings\Timings;
use pocketmine\utils\Config;
class CraftingManager{
/** @var ShapedRecipe[][] */
@ -47,9 +46,9 @@ class CraftingManager{
}
public function init() : void{
$recipes = new Config(\pocketmine\RESOURCE_PATH . "vanilla" . DIRECTORY_SEPARATOR . "recipes.json", Config::JSON, []);
$recipes = json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "vanilla" . DIRECTORY_SEPARATOR . "recipes.json"), true);
foreach($recipes->getAll() as $recipe){
foreach($recipes as $recipe){
switch($recipe["type"]){
case 0:
$this->registerRecipe(new ShapelessRecipe(

View File

@ -43,7 +43,6 @@ use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\Player;
use pocketmine\utils\Binary;
use pocketmine\utils\Config;
class Item implements ItemIds, \JsonSerializable{
public const TAG_ENCH = "ench";
@ -119,9 +118,9 @@ class Item implements ItemIds, \JsonSerializable{
public static function initCreativeItems(){
self::clearCreativeItems();
$creativeItems = new Config(\pocketmine\RESOURCE_PATH . "vanilla" . DIRECTORY_SEPARATOR . "creativeitems.json", Config::JSON, []);
$creativeItems = json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "vanilla" . DIRECTORY_SEPARATOR . "creativeitems.json"), true);
foreach($creativeItems->getAll() as $data){
foreach($creativeItems as $data){
$item = Item::jsonDeserialize($data);
if($item->getName() === "Unknown"){
continue;