All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.parzivail.pswg.container.SwgStructures Maven / Gradle / Ivy

package com.parzivail.pswg.container;

import com.google.common.base.Suppliers;
import com.parzivail.pswg.Resources;
import com.parzivail.scarif.ScarifStructure;
import net.fabricmc.loader.api.FabricLoader;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.function.Supplier;
import java.util.stream.Stream;

public class SwgStructures
{
	public static void cleanUpTemporaryFiles()
	{
		var modDir = FabricLoader.getInstance().getGameDir().resolve("mods");
		try (var fileStream = Files.list(modDir))
		{
			fileStream.forEach(file -> {
				var name = file.getFileName().toString();
				if (name.startsWith("zipfstmp") && name.endsWith(".tmp"))
				{
					try
					{
						Files.delete(file);
					}
					catch (IOException ignored)
					{
						// Ignore this. If we get an exception here, we're on Windows,
						// and the file is being used.
					}
				}
			});
		}
		catch (IOException ignored)
		{
		}
	}

	public static class General
	{
		public static final Supplier Region = Suppliers.memoize(() -> ScarifStructure.read(Resources.id("structures/entire_region.scrf2")));

		public static void register()
		{
			// no-op to make sure the class is loaded
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy