WolfyScript / CustomCrafting

Spigot based plugin to create your own custom Recipes & Items. Designed to be easy to use with in-game GUI and tons of configuration possibilities.
https://modrinth.com/plugin/customcrafting
GNU General Public License v3.0
115 stars 35 forks source link

Improved & Multithreaded Recipe Parser and Loader #325

Closed WolfyScript closed 1 year ago

WolfyScript commented 1 year ago

This improves the recipe parser and loader by separating parsing & validation of Objects. The current system both parses and validates the recipes in one pass, if one value is invalid it prints a stack trace. The stack trace, however, is not very intuitive.

Parsing & Validation separation

This new system separates parsing errors from validation errors, which will result in the following improvements:

Loading mechanism

The current system parses the recipes after it detected that all dependencies were done loading.
This has multiple issues:

  1. If just one dependency fails to load, no recipe will be parsed
  2. parsing may happen at runtime, causing the server to detect it as lag.

The new system instead,

After that, it starts to listen for any dependency to load. Once a dependency is loaded, it runs another validation pass on the still pending recipes:

To make sure it does not indefinitely wait for possibly failed dependencies, it marks all 'pending' recipes as 'invalid' and prints them to the logs after a specified timeout.