Plugin.yml Code (Text): name: ElytraCrafting version: 1.0 main: me.noobskills.recipe.Recipe description: Craft the elytra Code Code (Text): package me.noobskills.recipe; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ShapedRecipe; import org.bukkit.plugin.java.JavaPlugin; public class Recipe extends JavaPlugin { public void onEnable() { ItemStack elytra = new ItemStack(Material.ELYTRA, 1); ShapedRecipe Elytrawings = new ShapedRecipe(elytra); Elytrawings.shape("*%*","PLP","F F"); Elytrawings.setIngredient('*', Material.STRING); Elytrawings.setIngredient('%', Material.CHORUS_FRUIT); Elytrawings.setIngredient('P', Material.PAPER); Elytrawings.setIngredient('L', Material.LEATHER); Elytrawings.setIngredient('F', Material.FEATHER); getServer().addRecipe(Elytrawings); } public void OnDisable() { } } So I want to know how I can make a config so people can disable the plugin and change the crafting recipe. I'm new to coding so yea.
To allow users to disable your plugin: Add an option in the config "enabled: true" then in your onEnable() method you would check if that value is true or false. If false disable the plugin. For changing the recipe I would use a string list, 3 strings, 3 characters per string. there is a method available via the file configuration class to get a string list so this is very easy. You config would look like something like this: Code (Text): enabled: true recipe: - 'ABC' - 'DEF' - 'GHI'
It get a little more complicated due to a number of factors, but basically there are a few ways. Instead of chars to represent the ingredients use material names separated by some delimiter i.e. a comma Code (Text): recipe: - 'STONE,GRASS,STONE' - 'DIRT,OBSIDIAN,DIRT' - 'GRAVEL,STONE,DIRT' Read in the string list and split each string at the comma, then you can use the Material#getMaterial() method(might want to call #toUpperCase() on the string representing the material). I guess another way could be to keep the recipe list as it is and add a map of sorts i.e. Code (Text): ingredients: A: 'STONE' B: 'GRASS' C: 'DIRT' D: '...' E: '...' F: '...' etc... The second method IMO would make it easier to specify a durability value i.e. A: 'WOOL:5' EDIT: You really have a lot of choice on how to implement something like this, the possibilities are limitless.