Recipes are called Blueprints. Every blueprint must belong to a workbench. You need Java 21.
Integrating with quest/job plugins
The main thing here, if you are a developer of a quest/jobs plugin who wants to add support, is probably the BlueprintCraftEvent. This has who crafted it and what (in the custom crafting GUI, but later it will be extended to the vanilla workstations as well, so make sure to check what workbench is associated with the crafted blueprint). You usually only want to check for workbenches that are instances of the CustomWorkbenchclass.
Here is an example using AuroraQuests to demonstrate how can you integrate your quest/job plugin for crafting objectives:
@EventHandler
public void onCraft(BlueprintCraftEvent event) {
// Assuming you handle vanilla crafting stations with bukkit events already.
if (!(event.getBlueprint().getWorkbench() instanceof CustomWorkbench)) return;
// Progress your quests/objectives
AuroraQuestsProvider.getQuestManager().progress(
event.getPlayer(),
TaskType.CRAFT,
event.getAmount(),
Map.of("type", AuroraAPI.getItemManager().resolveId(event.getItem()))
);
}
Registering your own blueprint
If you want to register blueprints, you have to use the RegistryLoadEvent. This event will be called every time the user reloads the plugin, and you have to register your blueprint every time as well. In here, you will have access to the WorkbenchRegistryalready, so you can either get the Workbenchyou need or create your own. You will also have access to the Book here, with all of the categories/subcategories already built. The book is not filled with blueprints at this time. You can create and add your own BookCategory.
Here is a snippet about how you would register a basic, shaped recipe to the vanilla crafting table:
@EventHandler
public void onRegistryLoad(RegistryLoadEvent event) {
// Recipe book
var book = AuroraCraftingPlugin.inst().getBook();
// Workbench registry
var registry = AuroraCraftingPlugin.inst().getWorkbenchRegistry();
// Vanilla crafting table
var table = registry.getCraftingTable();
table.addBlueprint(
BlueprintType.SHAPED,
ShapedBlueprint.shapedBlueprint(table, "test")
// Will automatically find the bounding box and create symmetrical recipes if possible, just like how vanilla does it.
.symmetrical(true)
// Vanilla options are optional. Be careful with the choice type option!
.vanillaOptions(CraftingBlueprint.VanillaOptions.builder()
.group("test")
.category(CraftingBookCategory.MISC)
.choiceType(ChoiceType.ITEM_TYPE)
.build())
// List of ingredients. It will be padded with air to have enough to fill every workbench slot.
// Alternatively, you can use Blueprint#addIngredient to add them one by one.
.ingredients(List.of(
new ItemPair(TypeId.fromString("mythicmobs:enchanted_diamond"), 32),
new ItemPair(TypeId.fromString("mythicmobs:enchanted_diamond"), 32),
new ItemPair(TypeId.fromString("mythicmobs:enchanted_diamond"), 32)
))
// Completely optional
.category(book.getCategory("category-id"))
// Permission required to craft the blueprint. Also completely optional
.permission("my.permission")
// Result of the blueprint
.result(new ItemPair(TypeId.fromString("eco:ecoitems:super_sword"), 1))
// Make sure to always call this when you are done editing your blueprint!
.complete()
);
}
Add the API to your project
At the time of writing, the latest API version is 2.0.0