Crafting stations enable players to easily craft specific items using crafting recipes, which require ingredients and conditions. When opening a crafting station, players can see information about the station recipes, including the recipe conditions (permissions, levels), ingredients and output, and navigate through them using the pagination system.
You can make a player open a crafting station GUI by using the following command: /mi stations open {player} {station-id}. You can check the list of available crafting stations by using /mi stations list.
Creating a new crafting station
Crafting stations are saved in the /MMOItems/crafting-stations folder. Every YML file in that folder corresponds to a crafting station, therefore you can create a crafting station by creating a new YML file. Be careful when choosing the file name, because it corresponds to the ID you will be using as reference when opening a GUI to a player via the command as explained previously.
Configurating a crafting station
# Name which will be displayed
# when opening the station
name: 'Arcane Forge (#page#/#max#)'
# Configure GUI items here
items:
fill:
material: PINK_STAINED_GLASS_PANE
name: '&a'
no-recipe:
material: GRAY_DYE
name: '&a'
Every crafting station needs some basic information provided in the station config file, including the name
option which corresponds to the GUI name. The items
config section is used to change some of the GUI items. The fill
item is the item used to fill remaining GUI slots around the recipe items. The no-recipe
item is used to fill GUI recipe slots when there are no recipes. The previous config therefore displays that:
Creating a crafting recipe
The first step is to create the recipes
config section inside the station config. You then need to create a config section for your station recipe. The config section name corresponds to the recipe ID, which is only used internally in the plugin. What you put here does not really matter, just make sure the different recipes have different recipe IDs.
For this guide, we will be creating a recipe for the steel sword, which requires the player to be at least level 5. The recipe requires two specific player permissions, some steel ingots and vanilla wooden sticks as ingredients.
# Station recipes
recipes:
steel-sword: {}
The second step is setting up the recipe output. This is the MMOItem any player will obtain when using your recipe. Since we want the player to obtain 1 steel sword (which MMOItems type is SWORD
and ID is STEEL_SWORD
), this is how the output
section should look like:
recipes:
steel-sword:
output:
material: SWORD
sword: STEEL_SWORD
amount: 1
Recipes may also have a crafting time which is the time in seconds players spend crafting the item. When clicking on the recipe item in the GUI, players will temporarily quit the GUI and a progress bar will be prompted using the vanilla title feature till the crafting is complete. In order to setup a recipe crafting time, use the following config template:
recipes:
steel-sword:
crafting-time: 10 # time in seconds
If you want your recipe not to display in the GUI if any of its conditions are not met, use the hide-when-locked
recipe option, which you can enable using this template:
recipes:
steel-sword:
options:
hide-when-locked: true
Setting up recipe ingredients
The most important part about crafting recipes is the recipe ingredients (physical items any player must have to use the recipe). Recipe ingredients are stored in a list inside the recipe config section. There are multiple types of recipe ingredients, the default ones being:
- items generated using MMOItems
- vanilla items (not generated using MI) with a custom display name
For instance, the ingredients needed to craft a silver sword are the following: 4 steel ingots (item generated using MMOItems) and 2 vanilla wooden sticks.
recipes:
steel-sword:
ingredients:
- 'mmoitem MATERIAL STEEL_INGOT 4 Steel_Ingot'
- 'vanilla STICK . 2 Wooden_Stick'
In order to setup an MMOItem ingredient, use mmoitem <ITEM_TYPE> <ITEM_ID> (amount) (GUI_name)
. The GUI_name
option corresponds to the name which will be displayed in the ingredient list, in the recipe item lore. Arguments marked with () brackets are optional.
In order to setup a vanilla ingredient, use vanilla <ITEM_TYPE> (display_name) (amount) (GUI_name)
. Set the vanilla item display_name
to . to have no display name.
The ingredient list presented previously should look like this in game:
Setting up recipe conditions
Just like ingredients, conditions must be met in order to use a recipe. Unlike ingredients, conditions do not take anything from the player inventory when using a crafting recipe. There are several types of recipes conditions, the main being level conditions and permission conditions. Just like ingredients, conditions are stored in a list inside the recipe config section.
recipes:
steel-sword:
conditions:
- 'level 5'
- 'perms mmoitems.recipe.steel-sword mmoitems.recipe.station.steel'
If you want your recipe to be available only for players who are at least level X, use this: level <required_level>
. If you want your recipe to be available only for players with specific permissions, use: perms <perm1> <perm2> <perm3> ...
. Perm nodes must be separated using spaces.
The hide-when-locked
recipe option only triggers when at least one of the conditions is/are not met. The recipe will still display in the GUI if the player does not have all the required ingredients. Recipe conditions display at the beginning of the GUI recipe item lore.
Recipe example
recipes:
two-handed-steel-sword:
output:
type: GREATSWORD
id: TWO_HANDED_STEEL_SWORD
amount: 1
crafting-time: 10
conditions:
- 'level 8'
ingredients:
- 'mmoitem MATERIAL STEEL_INGOT 8 Steel_Ingot'
- 'vanilla STICK . 4 Wooden_Stick'