BlockStorage API icon

BlockStorage API -----

Allows you to store the data for each block in files



Code (Java):
package me.nome.BlockStorage ;

import java.io.IOException ;

import org.bukkit.plugin.java.JavaPlugin ;

public class Main   extends JavaPlugin {

 
    public static void 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 ) ) {
       
        }
   
    }
}
 
Resource Information
Author:
----------
Total Downloads: 118
First Release: Feb 25, 2023
Last Update: Feb 25, 2023
Category: ---------------
All-Time Rating:
0 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings