Move delayed executor and file tree system
This commit is contained in:
parent
b92a261c2c
commit
453d5642b7
5 changed files with 57 additions and 2 deletions
|
@ -7,6 +7,7 @@ import com.mojang.logging.LogUtils;
|
|||
import dev.zontreck.libzontreck.events.PlayerChangedPositionEvent;
|
||||
import dev.zontreck.libzontreck.memory.PlayerContainer;
|
||||
import dev.zontreck.libzontreck.memory.VolatilePlayerStorage;
|
||||
import dev.zontreck.libzontreck.util.DelayedExecutorService;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -34,6 +35,7 @@ public class LibZontreck {
|
|||
// Register the setup method for modloading
|
||||
bus.addListener(this::setup);
|
||||
|
||||
bus.register(DelayedExecutorService.getInstance());
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,15 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
|||
@EventBusSubscriber(modid=LibZontreck.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE)
|
||||
public class DelayedExecutorService {
|
||||
private static int COUNT = 0;
|
||||
private static final DelayedExecutorService inst;
|
||||
static{
|
||||
inst=new DelayedExecutorService();
|
||||
}
|
||||
|
||||
public static DelayedExecutorService getInstance()
|
||||
{
|
||||
return inst;
|
||||
}
|
||||
public class DelayedExecution
|
||||
{
|
||||
public DelayedExecution(Runnable run, long unix) {
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package dev.zontreck.libzontreck.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
|
||||
public class FileTreeDatastore {
|
||||
private static final Path BASE;
|
||||
|
||||
static{
|
||||
Path X = FMLPaths.CONFIGDIR.get().resolve("arias_mods");
|
||||
BASE=X;
|
||||
if(!BASE.toFile().exists())
|
||||
{
|
||||
try {
|
||||
Files.createDirectory(BASE);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Path of(String nick)
|
||||
{
|
||||
return BASE.resolve(nick);
|
||||
}
|
||||
|
||||
public static List<File> getListOfFiles(Path files)
|
||||
{
|
||||
List<File> fileList = new ArrayList<>();
|
||||
|
||||
File[] entries = files.toFile().listFiles();
|
||||
|
||||
for (File file : entries) {
|
||||
fileList.add(file);
|
||||
}
|
||||
return fileList;
|
||||
}
|
||||
}
|
Reference in a new issue