# ExecutableCrafting API

Canonical: https://splugins.net/docs/developer-api/executablecrafting

# 🛠️ ExecutableCrafting API

ExecutableCrafting has **two** API levels:

1. **The SCore facade** — id lookups and lifecycle, consistent with the other plugins. Only needs `com.ssomar:SCore`.
2. **The rich recipe API** shipped in the plugin (`vayk.executablecrafting.api.ExecutableCraftingAPI`) — crafting grids, furnace inputs, anvil pairs, recipe groups, conditions. Needs the `com.ssomar.executablecrafting:ExecutableCrafting` artifact.

## SCore facade

Entry point: `com.ssomar.score.api.executablecrafting.ExecutableCraftingAPI`

```java
ExecutableCraftingManagerInterface manager = ExecutableCraftingAPI.getExecutableCraftingManager();

Optional<? extends RecipeInterface> recipeOpt = manager.getRecipe("my_recipe");
List ids = manager.getRecipeIdsList();
List<? extends RecipeInterface> all = manager.getAllRecipes();
```

## Rich recipe API (advanced)

Add the plugin artifact next to SCore:

```xml

    com.ssomar.executablecrafting
    ExecutableCrafting
    VERSION
    provided

```

```java
import vayk.executablecrafting.api.ExecutableCraftingAPIProvider;
import vayk.executablecrafting.api.ExecutableCraftingAPI;

ExecutableCraftingAPI api = ExecutableCraftingAPIProvider.get();
Optional byGrid = api.getCraftingRecipe(craftingGrid);
Optional furnace = api.getFurnaceRecipe(inputItem);
List groups = api.getRecipeGroupsForRecipe("my_recipe");
boolean allowed = api.checkRecipeConditions("my_recipe", player, null);
```

## Events

| Event | Cancellable | Fired when |
|---|---|---|
| `ExecutableCraftingCraftEvent` | ✅ | a player crafts with a custom recipe, **before** ingredients are consumed |
| `ExecutableCraftingPostLoadEvent` | — | all recipes are loaded and registered |

```java
@EventHandler
public void onCustomCraft(ExecutableCraftingCraftEvent e) {
    // e.getPlayer(), e.getRecipe().getId(), e.getResult()
    e.getResult().setAmount(e.getResult().getAmount() * 2);   // the result stack is mutable
    // e.setCancelled(true) aborts the craft: no ingredients consumed, nothing given
}
```