Class WorldFileManager

java.lang.Object
org.collebol.game.world.WorldFileManager

public class WorldFileManager extends Object
The WorldFileManager class is responsible for saving and loading Chunk in the game World. It provides methods to serialize ad deserialize chunk data to and from binary files.

Usage:

     WorldFileManager fileManager = new WorldFileManager(world);
     fileManager.saveChunk(chunk); //save a chunk to binary file in worldfolder
     Chunk loadedChunk = fileManager.loadChunk(chunkX, chunkY); //get chunk from binary file in worldfolder
 
Since:
1.0-dev
Author:
ColleBol - contact@collebol.org
  • Constructor Details

    • WorldFileManager

      public WorldFileManager(World world)
  • Method Details

    • saveChunk

      public void saveChunk(Chunk chunk)
      Saves the specified chunk to a binary file.
      Parameters:
      chunk - the chunk to be saved.
    • loadChunk

      public Chunk loadChunk(int chunkX, int chunkY)
      Loads a chunk from binary file.
      Parameters:
      chunkX - the x-coordinate of the chunk.
      chunkY - the y-coordinate of the chunk.
      Returns:
      the loaded chunk, or null if the file does not exist.