Converting String to ItemStack

Discussion in 'Plugin Development' started by Chr0mosom3, Dec 19, 2020.

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

    Chr0mosom3

    I serialized a ItemStack and got this string
    Code:
    {v=2584, type=PUMPKIN_SEEDS, meta=UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name=§c§lRIFLE AMMO, lore=[§7---, §a$122]}}
    How would I convert this string to a ItemStack. The ItemStack#deserialize() method takes a Map<String, Object> as an argument, and if I try to split by string, the lore also gets split.
     
  2. Offline

    CraftCreeper6

  3. Online

    timtower Administrator Administrator Moderator

    @MrDaniel How did you serialize it? And where does this come from?
     
  4. Offline

    Newdel

    First, the serialize() method is returning a Map<String, Object> so your question doesn't make sense at all
    Second, use BukkitObjectInputStream and BukkitObjectOutputStream to serialize. It's made for this
     
    Last edited: Dec 19, 2020
  5. Offline

    Chr0mosom3

    ---Sorry, I meant ","---
    Sorry, I misunderstood your post, I will try that

    I used #serialize() and converted it to a string since I saved it in a database

    1) To save the object to a database I converted it to a string.
    2) What's the BukkitInputStream and BukkitOutputStream?
     
    Last edited: Dec 23, 2020
  6. Offline

    Chr0mosom3

  7. Offline

    CraftCreeper6

    Last edited: Dec 24, 2020
Thread Status:
Not open for further replies.

Share This Page