Enchantments from string?

Discussion in 'Plugin Development' started by ThijsD, Jul 6, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    ThijsD

    I have this simple question but I can't figure out how to do this. I'm trying to save the enchants of a weapon in a MySQL database. For this i currently use:

    items.getEnchantments().toString()
    (where items is an ItemsStack)

    This gives me the following string in the database: {Enchantment[34, DURABILITY]=3, Enchantment[32, DIG_SPEED]=4} Now i need to take this string and turn it back into a enchantment for a sword, How do I do this?


    Please help me,
    ThijsD
     
  2. Offline

    Firefly

    Are you looking to just save all the properties of an ItemStack? If so, saving it to config will save enchantments and all for it. I don't see why you need a database.
     
  3. Offline

    ThijsD

    Well I also want to save it to a Config, but I want to provide SQL support aswell :) But yes, what I want to accomplish is to save all the properties of an ItemStack.
     
  4. Offline

    Firefly

    I haven't touched SQL, but I can tell you that saving the ItemStack to a path in a config file will do what you want.
     
  5. Offline

    ThijsD

    I think I'll drop the SQL support then if a config file is so much easier
     
  6. you can save the raw config data inside the sql, ifthe users eeep whining, :D
     
  7. Offline

    agd555

    Sorry for responding for old thread, but why he should use config? SQL is not hard, and you CAN make from it enchantments. You need to use String.split methods and Enchantment.getByName. Using MySQL for it is very good for e.g. inventory view on website, or something like this.
     
Thread Status:
Not open for further replies.

Share This Page