mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 01:16:15 +00:00
Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/17310812886
This commit is contained in:
@ -162,7 +162,7 @@ final class CraftingManagerFromDataHelper{
|
||||
}
|
||||
|
||||
$mapper = new \JsonMapper();
|
||||
$mapper->bStrictObjectTypeChecking = true;
|
||||
$mapper->bStrictObjectTypeChecking = false; //to allow hydrating ItemStackData - since this is only used for offline data it's safe
|
||||
$mapper->bExceptionOnUndefinedProperty = true;
|
||||
$mapper->bExceptionOnMissingData = true;
|
||||
|
||||
|
@ -23,7 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\crafting\json;
|
||||
|
||||
final class ItemStackData{
|
||||
use function count;
|
||||
|
||||
final class ItemStackData implements \JsonSerializable{
|
||||
|
||||
/** @required */
|
||||
public string $name;
|
||||
@ -40,4 +42,15 @@ final class ItemStackData{
|
||||
public function __construct(string $name){
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]|string
|
||||
*/
|
||||
public function jsonSerialize() : array|string{
|
||||
$result = (array) $this;
|
||||
if(count($result) === 1 && isset($result["name"])){
|
||||
return $this->name;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user