mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 16:49:53 +00:00
ItemTranslator: throw the proper exceptions when failing to map network IDs
This commit is contained in:
parent
a3f8546ac4
commit
80b402e529
@ -175,11 +175,12 @@ final class ItemTranslator{
|
|||||||
/**
|
/**
|
||||||
* @return int[]
|
* @return int[]
|
||||||
* @phpstan-return array{int, int}
|
* @phpstan-return array{int, int}
|
||||||
|
* @throws TypeConversionException
|
||||||
*/
|
*/
|
||||||
public function fromNetworkId(int $networkId, int $networkMeta, ?bool &$isComplexMapping = null) : array{
|
public function fromNetworkId(int $networkId, int $networkMeta, ?bool &$isComplexMapping = null) : array{
|
||||||
if(isset($this->complexNetToCoreMapping[$networkId])){
|
if(isset($this->complexNetToCoreMapping[$networkId])){
|
||||||
if($networkMeta !== 0){
|
if($networkMeta !== 0){
|
||||||
throw new \UnexpectedValueException("Unexpected non-zero network meta on complex item mapping");
|
throw new TypeConversionException("Unexpected non-zero network meta on complex item mapping");
|
||||||
}
|
}
|
||||||
$isComplexMapping = true;
|
$isComplexMapping = true;
|
||||||
return $this->complexNetToCoreMapping[$networkId];
|
return $this->complexNetToCoreMapping[$networkId];
|
||||||
@ -188,12 +189,13 @@ final class ItemTranslator{
|
|||||||
if(isset($this->simpleNetToCoreMapping[$networkId])){
|
if(isset($this->simpleNetToCoreMapping[$networkId])){
|
||||||
return [$this->simpleNetToCoreMapping[$networkId], $networkMeta];
|
return [$this->simpleNetToCoreMapping[$networkId], $networkMeta];
|
||||||
}
|
}
|
||||||
throw new \UnexpectedValueException("Unmapped network ID/metadata combination $networkId:$networkMeta");
|
throw new TypeConversionException("Unmapped network ID/metadata combination $networkId:$networkMeta");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int[]
|
* @return int[]
|
||||||
* @phpstan-return array{int, int}
|
* @phpstan-return array{int, int}
|
||||||
|
* @throws TypeConversionException
|
||||||
*/
|
*/
|
||||||
public function fromNetworkIdWithWildcardHandling(int $networkId, int $networkMeta) : array{
|
public function fromNetworkIdWithWildcardHandling(int $networkId, int $networkMeta) : array{
|
||||||
$isComplexMapping = false;
|
$isComplexMapping = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user