22declare(strict_types=1);
24namespace pocketmine\data\bedrock;
30use
function is_string;
31use
function json_decode;
39 private array $legacyToString = [];
41 public function __construct(
string $file){
43 if(!is_array($stringToLegacyId)){
46 foreach($stringToLegacyId as $stringId => $legacyId){
47 if(!is_string($stringId) || !is_int($legacyId)){
50 $this->legacyToString[$legacyId] = $stringId;
54 public function legacyToString(
int $legacy) : ?
string{
55 return $this->legacyToString[$legacy] ??
null;
63 return $this->legacyToString;
66 public function add(
string $string,
int $legacy) : void{
67 if(isset($this->legacyToString[$legacy])){
68 if($this->legacyToString[$legacy] === $string){
71 throw new \InvalidArgumentException(
"Legacy ID $legacy is already mapped to string " . $this->legacyToString[$legacy]);
73 $this->legacyToString[$legacy] = $string;
static fileGetContents(string $fileName, bool $useIncludePath=false, $context=null, int $offset=0, ?int $length=null)