From c86ec97e375edfef10856c156c08050115f17765 Mon Sep 17 00:00:00 2001 From: Florian Rinke Date: Mon, 11 Oct 2021 17:52:57 +0200 Subject: renamed --- .../minecraft_integration/TemporarySession.java | 137 --------------------- 1 file changed, 137 deletions(-) delete mode 100644 src/main/java/de/torui/coflsky/minecraft_integration/TemporarySession.java (limited to 'src/main') diff --git a/src/main/java/de/torui/coflsky/minecraft_integration/TemporarySession.java b/src/main/java/de/torui/coflsky/minecraft_integration/TemporarySession.java deleted file mode 100644 index 542bd53..0000000 --- a/src/main/java/de/torui/coflsky/minecraft_integration/TemporarySession.java +++ /dev/null @@ -1,137 +0,0 @@ -package de.torui.coflsky.minecraft_integration; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.time.Duration; -import java.time.LocalDateTime; -import java.time.ZonedDateTime; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import net.minecraftforge.fml.common.Loader; - -public class TemporarySession { - private static Gson gson = new GsonBuilder() .registerTypeAdapter(ZonedDateTime.class, new TypeAdapter() { - @Override - public void write(JsonWriter out, ZonedDateTime value) throws IOException { - out.value(value.toString()); - } - - @Override - public ZonedDateTime read(JsonReader in) throws IOException { - return ZonedDateTime.parse(in.nextString()); - } - }) - .enableComplexMapKeySerialization().create(); - public static class TempSession { - - public String SessionUUID; - public ZonedDateTime timestampCreated; - public TempSession() {} - public TempSession(String sessionUUID, ZonedDateTime timestampCreated) { - super(); - SessionUUID = sessionUUID; - this.timestampCreated = timestampCreated; - } - - } - - public static void UpdateSessions() throws IOException { - Map sessions = GetSessions(); - - for (String username : sessions.keySet()) { - if(!isValidSession(sessions.get(username))) { - DeleteTempSession(username); - } - } - } - - public static Path GetTempFileFolder() { - - Path dataPath = Paths.get(Loader.instance().getConfigDir().getPath(), "CoflSky", "sessions"); - dataPath.toFile().mkdirs(); - - return dataPath; - } - - public static Map GetSessions() throws IOException{ - - File[] sessions = GetTempFileFolder().toFile().listFiles(); - - Map map = new HashMap<>(); - - for (int i= 0; i