LegacyToStringMap: don't throw if the existing mapping is the same as the one we want to register

this was making it inconvenient for plugins to use BlockIdMetaUpgrader->addMapping(), because the block legacy ID map contains IDs up to 1.16, but the table of mapped 1.12 blockstates only goes up to ... well ... 1.12. This left a gap of several versions' blocks unable to be mapped.
This commit is contained in:
Dylan K. Taylor 2022-07-19 16:08:05 +01:00
parent b36b65927c
commit 9a8902d1fe
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -66,6 +66,9 @@ abstract class LegacyToStringIdMap{
public function add(string $string, int $legacy) : void{
if(isset($this->legacyToString[$legacy])){
if($this->legacyToString[$legacy] === $string){
return;
}
throw new \InvalidArgumentException("Legacy ID $legacy is already mapped to string " . $this->legacyToString[$legacy]);
}
$this->legacyToString[$legacy] = $string;