ItemStackRequestExecutor: added a sanity check for recipe repetitions

This commit is contained in:
Dylan K. Taylor 2023-03-21 00:16:03 +00:00
parent f90315c4a2
commit e57fbff28c
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -211,6 +211,12 @@ final class ItemStackRequestExecutor{
if($repetitions < 1){ //TODO: upper bound?
throw new ItemStackRequestProcessException("Cannot craft a recipe less than 1 time");
}
if($repetitions > 256){
//TODO: we can probably lower this limit to 64, but I'm unsure if there are cases where the client may
//request more than 64 repetitions of a recipe.
//It's already hard-limited to 256 repetitions in the protocol, so this is just a sanity check.
throw new ItemStackRequestProcessException("Cannot craft a recipe more than 256 times");
}
$craftingManager = $this->player->getServer()->getCraftingManager();
$recipe = $craftingManager->getCraftingRecipeFromIndex($recipeId);
if($recipe === null){