How to save Metadata on shutdown?

Discussion in 'Plugin Development' started by TheButlah, Aug 5, 2013.

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

    TheButlah

    Hi guys! I wanted to know how one would go about saving all metadata values for the blocks in a server. I know that metadata is not persistant over server restarts by default, but i was hoping that there was a way were i could extract all of the metadata, save it using my own methods, and then re-add the metadata when the server starts back up.

    For example, if i have a plugin where the player can rig up blocks to explode when a player steps on them by saving a value in the blocks' metadata, i cant just iterate through all blocks in all the worlds, check if they have the metadata, and save it somehow, because that would be too inefficient and kinda stupid. Instead, i would prefer if there was some method i could run that would give me a copy of all of the server's stored metadata records so i could copy them and save it.

    Hoping for some answers!
    --TheButlah
     
  2. Offline

    newboyhun

    If you want to save only some blocks metadata, then you should save it to a file.
    For this you should have a config file.
    When a player places the specific block then save the block's position to the config file.

    When the server shuts down the iterate over the saved positions and if the block presents then save it's metadata to the config file.

    When the server started iterate over blocks again and recover the metadata.
     
Thread Status:
Not open for further replies.

Share This Page