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