    001package net.minecraftforge.common;
    002
    003import java.io.File;
    004
    005import net.minecraft.world.chunk.storage.IChunkLoader;
    006import net.minecraft.world.storage.IPlayerFileData;
    007import net.minecraft.world.storage.ISaveHandler;
    008import net.minecraft.world.MinecraftException;
    009import net.minecraft.nbt.NBTTagCompound;
    010import net.minecraft.world.storage.WorldInfo;
    011import net.minecraft.world.WorldProvider;
    012import net.minecraft.world.WorldServer;
    013
    014//Class used internally to provide the world specific data directories.
    015
    016public class WorldSpecificSaveHandler implements ISaveHandler
    017{
    018    private WorldServer world;
    019    private ISaveHandler parent;
    020    private File dataDir;
    021
    022    public WorldSpecificSaveHandler(WorldServer world, ISaveHandler parent)
    023    {
    024        this.world = world;
    025        this.parent = parent;
    026        dataDir = new File(world.getChunkSaveLocation(), "data");
    027        dataDir.mkdirs();
    028    }
    029
    030    @Override public WorldInfo loadWorldInfo() { return parent.loadWorldInfo(); }
    031    @Override public void checkSessionLock() throws MinecraftException { parent.checkSessionLock(); }
    032    @Override public IChunkLoader getChunkLoader(WorldProvider var1) { return parent.getChunkLoader(var1); }
    033    @Override public void saveWorldInfoWithPlayer(WorldInfo var1, NBTTagCompound var2) { parent.saveWorldInfoWithPlayer(var1, var2); }
    034    @Override public void saveWorldInfo(WorldInfo var1){ parent.saveWorldInfo(var1); }
    035    @Override public IPlayerFileData getSaveHandler() { return parent.getSaveHandler(); }
    036    @Override public void flush() { parent.flush(); }
    037    @Override public String getSaveDirectoryName() { return parent.getSaveDirectoryName(); }
    038
    039    @Override
    040    public File getMapFileFromName(String name)
    041    {
    042        return new File(dataDir, name + ".dat");
    043    }
    044}