mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-18 15:05:56 +00:00
crafting: validate array inputs
this makes sure wrong parameters don't show up as core errors, as seen in crash report 12373907 closes #6642
This commit is contained in:
parent
aad2bce9e4
commit
7af5eb3da2
@ -97,6 +97,7 @@ class ShapedRecipe implements CraftingRecipe{
|
||||
|
||||
$this->shape = $shape;
|
||||
|
||||
Utils::validateArrayValueType($ingredients, function(RecipeIngredient $_) : void{});
|
||||
foreach(Utils::stringifyKeys($ingredients) as $char => $i){
|
||||
if(!str_contains(implode($this->shape), $char)){
|
||||
throw new \InvalidArgumentException("Symbol '$char' does not appear in the recipe shape");
|
||||
@ -105,6 +106,7 @@ class ShapedRecipe implements CraftingRecipe{
|
||||
$this->ingredientList[$char] = clone $i;
|
||||
}
|
||||
|
||||
Utils::validateArrayValueType($results, function(Item $_) : void{});
|
||||
$this->results = Utils::cloneObjectArray($results);
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,9 @@ class ShapelessRecipe implements CraftingRecipe{
|
||||
if(count($ingredients) > 9){
|
||||
throw new \InvalidArgumentException("Shapeless recipes cannot have more than 9 ingredients");
|
||||
}
|
||||
Utils::validateArrayValueType($ingredients, function(RecipeIngredient $_) : void{});
|
||||
$this->ingredients = $ingredients;
|
||||
Utils::validateArrayValueType($results, function(Item $_) : void{});
|
||||
$this->results = Utils::cloneObjectArray($results);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user