    001    package net.minecraftforge.common;
    002
    003    import java.io.File;
    004
    005    import net.minecraft.world.chunk.storage.IChunkLoader;
    006    import net.minecraft.world.storage.IPlayerFileData;
    007    import net.minecraft.world.storage.ISaveHandler;
    008    import net.minecraft.world.MinecraftException;
    009    import net.minecraft.nbt.NBTTagCompound;
    010    import net.minecraft.world.storage.WorldInfo;
    011    import net.minecraft.world.WorldProvider;
    012    import net.minecraft.world.WorldServer;
    013
    014    //Class used internally to provide the world specific data directories.
    015
    016    public 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    }