BlockStorage API This api plugin allows you to store the data for each block in any coordinates in any chunk in separate files so that even after a server restart you can get your unique data for each block
Code (Java):
packageme.nome.BlockStorage;
importjava.io.IOException;
importorg.bukkit.plugin.java.JavaPlugin;
publicclass Main
extends JavaPlugin
{
publicstaticvoid main
(String[] args
){ int chunkX
=0; int chunkZ
=15; //Create instance of ChunkContent(This instance save custom data for all blocks in this chunk) ChunkContent chunk
=new ChunkContent
(chunkX,chunkZ
);
int blockX
=0; int blockY
=0; int blockZ
=0; //Create instance of BlockContent(This instnace save custom data for block) BlockContent blockContent
=new BlockContent
();
//With method set from BlockContent you can save custom data; blockContent.
set("myData",
"myContent"); blockContent.
set("private",
true); blockContent.
set("counter",
0);
int block2X
=0; int block2Y
=0; int block2Z
=1;
BlockContent blockContent2
=new BlockContent
();
//With method set from BlockContent you can save custom data; blockContent.
set("myData",
"myContent"); blockContent.
set("private",
true); blockContent.
set("counter",
0);
// Method addBlock save block custom data in current ChunkContent instance chunk.
addBlock(block2X, block2Y, block2Z, blockContent2
);
/* * Creates a file structure that specifies the path where the chunk file itself * will be physically stored along with the written blocks and their data in them * This instance describes a file that will be called x-z.bin where x and z are real coordinates of the chunk */ ChunkFile chunkFile
=new ChunkFile
("./",chunkX, chunkZ
); try{ //This method will create a file and write the chunk data to it ChunkFileStorage.
writeChunk(chunkFile, chunk
); }catch(IOException e
){ // TODO Auto-generated catch block e.
printStackTrace(); }
try{ /* * This method will read a chunk from a file */ ChunkContent readedChunkFromFile
= ChunkFileStorage.
readChunk(chunkFile
); }catch(ClassNotFoundException|IOException e
){ // TODO Auto-generated catch block e.
printStackTrace(); }
//This method check if exists chunkFile if(ChunkFileStorage.
existsChunkFile(chunkFile
)){