AuroraCrafting
  • AuroraCrafting
  • Configuration
    • Main config
    • Workbench config
    • Blueprint config
    • Smithing blueprint config
    • Cooking blueprint config
    • Brewing recipes
    • Stonecutter blueprint config
    • Cauldron blueprint config
    • Recipe book config
    • Merchant config
    • Disabled vanilla recipes config
  • Commands
  • Permissions
  • Compatible plugins
  • API
Powered by GitBook
On this page
  • Integrating with quest/job plugins
  • Registering your own blueprint
  • Add the API to your project
  • Maven
  • Gradle

API

Guide to use the API.

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

Maven

<repository>
    <id>auroramc</id>
    <url>https://repo.auroramc.gg/releases/</url>
</repository>
<dependency>
    <groupId>gg.auroramc</groupId>
    <artifactId>AuroraCraftingAPI</artifactId>
    <version>{VERSION}</version>
    <scope>provided</scope>
</dependency>

Gradle

Groovy DSL:

repositories {
    maven {
        url "https://repo.auroramc.gg/releases/"
    }
}

dependencies {
    compileOnly 'gg.auroramc:AuroraCraftingAPI:{VERSION}'
}

Kotlin DSL:

repositories { 
    maven("https://repo.auroramc.gg/releases/")
}

dependencies { 
    compileOnly("gg.auroramc:AuroraCraftingAPI:{VERSION}")
}
PreviousCompatible plugins

Last updated 2 months ago