FireworkEffect not serializable?

Discussion in 'Plugin Development' started by Sil3nt_One, Feb 3, 2013.

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

    Sil3nt_One

    I'm trying to serialize ItemMeta of a firework but it fails..

    Code:
    ItemMeta itemMeta = is.getItemMeta();
    Map<String, Object> smap = itemMeta.serialize()
    Textual representation of the data stored inside Map<String, Object> smap using
    System.out.println(smap);
    Code:
    {meta-type=FIREWORK, firework-effects=[FireworkEffect:{flicker=false, trail=false, colors=[Color:[rgb0xDECF2A]], fade-colors=[], type=BALL}], power=1}
    Code:
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream oos;
            try {
                oos = new ObjectOutputStream(baos);
                [COLOR=#ff0000]oos.writeObject(_itemMeta);[/COLOR]
                oos.close();
            }
    
    Code:
    1:37:31 AM [SEVERE] java.io.NotSerializableException: org.bukkit.FireworkEffect
    1:37:31 AM [SEVERE]    at java.io.ObjectOutputStream.writeObject0(Unknown Source)
    1:37:31 AM [SEVERE]    at java.io.ObjectOutputStream.writeArray(Unknown Source)
    1:37:31 AM [SEVERE]    at java.io.ObjectOutputStream.writeObject0(Unknown Source)
    1:37:31 AM [SEVERE]    at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
    1:37:31 AM [SEVERE]    at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
    1:37:31 AM [SEVERE]    at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
    1:37:31 AM [SEVERE]    at java.io.ObjectOutputStream.writeObject0(Unknown Source)
    1:37:31 AM [SEVERE]    at java.io.ObjectOutputStream.writeArray(Unknown Source)
    1:37:31 AM [SEVERE]    at java.io.ObjectOutputStream.writeObject0(Unknown Source)
    1:37:31 AM [SEVERE]    at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
    1:37:31 AM [SEVERE]    at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
    1:37:31 AM [SEVERE]    at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
    1:37:31 AM [SEVERE]    at java.io.ObjectOutputStream.writeObject0(Unknown Source)
    1:37:31 AM [SEVERE]    at java.io.ObjectOutputStream.writeObject(Unknown Source)
    1:37:31 AM [SEVERE]    at meepcraft.inv.InventorySerializer.EncodeItemMeta(InventorySerializer.java:89)
    1:37:31 AM [SEVERE]    at meepcraft.inv.InventorySerializer.serialize(InventorySerializer.java:77)
    1:37:31 AM [SEVERE]    at meepcraft.inv.InventorySerializer.inventoryToString(InventorySerializer.java:40)
    1:37:31 AM [SEVERE]    at meepcraft.inv.InvSQL$SaveInventoryTask.run(InvSQL.java:185)
    1:37:31 AM [SEVERE]    at org.bukkit.craftbukkit.v1_4_R1.scheduler.CraftTask.run(CraftTask.java:53)
    1:37:31 AM [SEVERE]    at org.bukkit.craftbukkit.v1_4_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
    1:37:31 AM [SEVERE]    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    1:37:31 AM [SEVERE]    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    1:37:31 AM [SEVERE]    at java.lang.Thread.run(Unknown Source)
    
     
  2. Offline

    Sagacious_Zed Bukkit Docs

  3. Offline

    Sil3nt_One

    I did.. I recently started with java..
    The above works with Enchanted Items, Enchanted Books, Skulls, etc.. But not with Fireworks.. Can you give me a short reason or hint as to why i'm getting a NotSerializableException for the FireworkEffect?
    Is it because...... umm... np.. thanks.. I just noticed what I did :p ..
     
  4. Offline

    Sagacious_Zed Bukkit Docs

    Sil3nt_One
    You can serialize something that is not Serializable, thus the NotSerializableException
     
  5. Offline

    Sil3nt_One

    :eek: LOL

    I know, I forgot i was actually serializing the Map at first and not the ItemMeta itself... So i have to call the serialize method on FireworkEffect too
     
Thread Status:
Not open for further replies.

Share This Page