Remove the last few File usages

Barring one, given I've heard in hot code `Files.exists()` is slower than toFile().exists() if in the default `FileSystem`
This commit is contained in:
altrisi authored and gnembon committed 2022-08-28 18:34:39 +02:00
1 parent df240159ff
commit 2a4d678aa7
2 files changed
+6 -8

No files matched your search

@@ -80,7 +80,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.CommandStorage;
import net.minecraft.world.level.storage.LevelResource;
import net.minecraft.world.phys.Vec3;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.file.PathUtils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -1076,7 +1076,7 @@ public class Auxiliary {
{
successful[0] = false;
try {
FileUtils.forceDelete(packFloder.toFile());
PathUtils.delete(packFloder);
} catch (IOException ignored) {
throw new InternalExpressionException("Failed to install a datapack and failed to clean up after it");
}
@@ -32,7 +32,6 @@ import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.levelgen.WorldGenSettings;
import net.minecraft.world.level.storage.DerivedLevelData;
import net.minecraft.world.level.storage.ServerLevelData;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
@@ -54,10 +53,9 @@ public class WorldTools
if (region == null) return false;
return region.hasChunk(chpos);
}
Path regionPath = new File(((MinecraftServerInterface )world.getServer()).getCMSession().getDimensionPath(world.dimension()).toFile(), "region").toPath();
Path regionFilePath = regionPath.resolve(currentRegionName);
File regionFile = regionFilePath.toFile();
if (!regionFile.exists())
Path regionsFolder = ((MinecraftServerInterface)world.getServer()).getCMSession().getDimensionPath(world.dimension()).resolve("region");
Path regionPath = regionsFolder.resolve(currentRegionName);
if (!regionPath.toFile().exists())
{
if (regionCache != null) regionCache.put(currentRegionName, null);
return false;
@@ -65,7 +63,7 @@ public class WorldTools
if (!deepcheck) return true; // not using cache in this case.
try
{
RegionFile region = new RegionFile(regionFile.toPath(), regionPath, true);
RegionFile region = new RegionFile(regionPath, regionsFolder, true);
if (regionCache != null) regionCache.put(currentRegionName, region);
return region.hasChunk(chpos);
}