Loading multiple crafting recipes from config

Discussion in 'Plugin Development' started by CaptainBern, Apr 1, 2013.

Thread Status:
Not open for further replies.
  1. Hello, for my new plugin i need to implement a feature that server owners can add crafting recipes, this is not a plugin like RecipeManager, what i need to know is how i can load the recipes, i tried some code but it didnt worked and was really bad so i deleted it :/, cans someone please explain me whats a good way how u can do it like server owners can add as much recipes they want ? thank you for reading my post (don't ask me for any code, like i said its deleted and noob/bad...)
     
  2. Offline

    msalihov

    I would suggest storing all those recipes in a SQLite database, and then looping through the SQL to initialize all of those recipes. The columns you would need are NAME, RESULT, and a column for each of the nine crafting squares. I understand that this might be hard for someone rather new to plugin coding or Java (such as me!) I also hope this would actually work in practice.

    Another method would be following a specific format in your config.yml, or you could even define another yml file for the recipes. This is the format I would suggest:

    Code:
    craftingrecipename:
        result:
        bright:
        cright:
        tright:
        tcenter:
        tleft:
        cleft:
        bleft:
        bcenter:
        ccenter:
    I love noobishly posting on these forums ;)
     
  3. at the moment i use this:
    item: item
    recipe line 1: iid|id|id
    recipe line 2: id|id|id
    recipe line 3: id|id|id

    but i want it to be so the serevr owner can open up the config and there will be a list like:
    list:
    and then they can add strings to this list
    -item
    then they can define what item does like
    item:
    item: Chest
    recipe line 1: 54|54|54
    recipe line 2: 54|54|54
    recipe line 3: 54|54|54

    like this, or just a seperate file for each recipe and item...

    i already can make it so u can have 1 recipe, but i want it that they can add as much recipes as they want
     
  4. Offline

    msalihov

    It harder if you put in the default config.yml. Easier if you store it in a database, so trust me, it is worth it. There should be some SQL tutorials in the Resources section. Why I say this: Loops is the key here, and I just can't get my mind around how to use loops with a simple YAML file.
     
  5. yes, I know how to make an sql database, but I want players to have the ability to change the recipes without doing commands in-game... thanks you for your help
     
Thread Status:
Not open for further replies.

Share This Page