Block MetaData not save when server restarts

Discussion in 'Plugin Development' started by lucasdidur, Feb 7, 2013.

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

    lucasdidur

    Hello,

    I want create a simple way to store a inventory, so I saved on Block MetaData.

    All works, but when I restart the server, all metadata saved is lost, may I do someting wrong?

    Here my code.

    Code:
    if(args[1].equals("save"))
    {
        Block b = player.getWorld().getBlockAt(Integer.valueOf(args[2]), Integer.valueOf(args[3]), Integer.valueOf(args[4]));
        b.setMetadata("inventory", new FixedMetadataValue(EhShop.getShopPlugin(), ItemSerialization.toBase64(player.getInventory())));
    }
     
    if(args[1].equals("open"))
    {
        Block b = player.getWorld().getBlockAt(Integer.valueOf(args[2]), Integer.valueOf(args[3]), Integer.valueOf(args[4]));
        Inventory i = ItemSerialization.fromBase64(b.getMetadata("inventory").get(0).asString());
        player.openInventory(i);
    }
    
    I used ItemSerialization from https://gist.github.com/aadnk/4342379 to convert inventory to String.
     
  2. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Metadata isn't persistent.
     
  3. Offline

    lucasdidur

    Hmm, now that explains everything. But is there any way I can do this without using files or mysql?
     
  4. Offline

    Yukari

    To be properly philosophical, I'm certain you could come up with some way to avoid files or databases.

    But no, files or a database are by far the simplest ways to do it.
     
Thread Status:
Not open for further replies.

Share This Page