diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index b365ee4..7a53139 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,5 +1,3 @@ eclipse.preferences.version=1 -encoding//src/test/java=UTF-8 -encoding//src/test/resources=UTF-8 encoding/=UTF-8 encoding/src=UTF-8 diff --git a/pom.xml b/pom.xml index 5a04546..f4346ee 100644 --- a/pom.xml +++ b/pom.xml @@ -55,12 +55,17 @@ commons-codec commons-codec - 1.15 + 1.15 com.google.guava guava - 31.0.1-jre + 31.0.1-jre + + + org.kohsuke + github-api + 1.127 diff --git a/src/api/GetApiData.java b/src/api/GetApiData.java index 0711af6..4b1b1f1 100644 --- a/src/api/GetApiData.java +++ b/src/api/GetApiData.java @@ -25,5 +25,23 @@ public class GetApiData { return songID; } + + private static int lock = 0; + GDClient client = null; + GDLevel level = null; + + public String getLevelLength(int id) { + if(lock == 0) { + client = GDClient.create(); + } + lock = 1; + + level = client.findLevelById(id).block(); + + String length = level.length() + ""; + + return length; + + } } diff --git a/src/data/DownloadLevels.java b/src/data/DownloadLevels.java index ac36c5a..307cab7 100644 --- a/src/data/DownloadLevels.java +++ b/src/data/DownloadLevels.java @@ -12,6 +12,7 @@ import javax.swing.JProgressBar; import javax.swing.JScrollPane; import javax.swing.JTextArea; +import api.GetApiData; import gui.MainGUI; import settingsfunctions.LoadSettings; import settingsfunctions.MigrateData; @@ -96,6 +97,10 @@ public class DownloadLevels { MainGUI gui = new MainGUI(); MigrateData migrate = new MigrateData(); migrate.migrateData(); + + RequestLevelLength req = new RequestLevelLength(); + req.request(); + try { gui.build(); } catch (IOException e) { diff --git a/src/data/ManageFiles.java b/src/data/ManageFiles.java index 9a3fb20..9880414 100644 --- a/src/data/ManageFiles.java +++ b/src/data/ManageFiles.java @@ -38,6 +38,5 @@ public class ManageFiles { MainGUI gui = new MainGUI(); gui.build(); } - } -} + } diff --git a/src/data/RequestLevelLength.java b/src/data/RequestLevelLength.java new file mode 100644 index 0000000..0210621 --- /dev/null +++ b/src/data/RequestLevelLength.java @@ -0,0 +1,37 @@ +package data; + +import api.GetApiData; +import database.Sqlite; + +public class RequestLevelLength { + + GetApiData data = new GetApiData(); + FetchData fetch = new FetchData(); + Sqlite sql = new Sqlite("levels"); + + public void request() { + + sql.queryData("levels"); + + Thread thread = new Thread(new Runnable( ) { + + @Override + public void run() { + + for(int i = 0; i < ManageFiles.getMissinglevels().size(); i++) { + sql.modifyData(sql.getLevelname().get(sql.getRawLevelNames().indexOf(sql.getRawLevelNames().get(i))), Boolean.parseBoolean(sql.getCompleted().get(i).toString()), sql.getAttempts().get(i).intValue(), sql.getLocked().get(i).booleanValue(), sql.getPbarr().get(i), "" + data.getLevelLength(Integer.parseInt(sql.getLevelID().get(sql.getRawLevelNames().indexOf(ManageFiles.getMissinglevels().get(i)))))); + try { + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + }); + + thread.start(); + + + } + +} diff --git a/src/database/DatabaseManager.java b/src/database/DatabaseManager.java index 2336434..067a203 100644 --- a/src/database/DatabaseManager.java +++ b/src/database/DatabaseManager.java @@ -7,95 +7,102 @@ import java.util.ArrayList; import data.FetchData; import data.GuiData; +import gui.LoadingStatus; import settingsfunctions.LoadSettings; public class DatabaseManager { - - public void manage() { - Sqlite createLevelDB = new Sqlite("levels"); - if(createLevelDB.exists()) { - } else { - createLevelDB.createNewDatabase("levels"); - } - createLevelDB.createNewTable("levels"); - - createLevelDB.checkColumns("levels"); - - } - - public void migrateData() { - Sqlite database = new Sqlite("levels"); - FetchData fetch = new FetchData(); - - LoadSettings settings = new LoadSettings(); - try { - settings.load(); - } catch (IOException e) { - e.printStackTrace(); - } - - ArrayList levels = new ArrayList(); - ArrayList rawLevels = new ArrayList(); - - File file = new File("C:\\ExtremeDemonList\\levels"); - File[] listLevels = file.listFiles(); - - for(int i = 0; i < listLevels.length; i++) { - rawLevels.add(listLevels[i].getName()); - } - - for(int i = 0; i < fetch.allLevels().size(); i++) { - if(rawLevels.indexOf(fetch.allLevels().get(i) + ".json") != -1) { - levels.add(rawLevels.get(rawLevels.indexOf(fetch.allLevels().get(i) + ".json"))); - } - - } - - GuiData data = new GuiData(); - - try { - data.IndexData(levels); - fetch.getGithubString(); - } catch (IOException e) { - e.printStackTrace(); - } - - System.out.println(data.getLocalLevels().size() + " ====== lovallevelsize"); - - for (int i = 0; i < data.getLocalLevels().size(); i++) { - - System.out.println(data.getLocalLevels().get(i)); + + private LoadingStatus status; // Singleton-Instanz von LoadingStatus + + public void manage() { + Sqlite createLevelDB = new Sqlite("levels"); + if(createLevelDB.exists()) { + } else { + createLevelDB.createNewDatabase("levels"); + } + createLevelDB.createNewTable("levels"); + + createLevelDB.checkColumns("levels"); + + } + + public void migrateData() { + Sqlite database = new Sqlite("levels"); + FetchData fetch = new FetchData(); + status = LoadingStatus.getInstance(); // Holen der Singleton-Instanz + + status.initialize(); + + LoadSettings settings = new LoadSettings(); + try { + settings.load(); + } catch (IOException e) { + e.printStackTrace(); + } + + ArrayList levels = new ArrayList(); + ArrayList rawLevels = new ArrayList(); + + File file = new File("C:\\ExtremeDemonList\\levels"); + File[] listLevels = file.listFiles(); + + for(int i = 0; i < listLevels.length; i++) { + rawLevels.add(listLevels[i].getName()); + } + + for(int i = 0; i < fetch.allLevels().size(); i++) { + if(rawLevels.indexOf(fetch.allLevels().get(i) + ".json") != -1) { + levels.add(rawLevels.get(rawLevels.indexOf(fetch.allLevels().get(i) + ".json"))); + } + + } + + GuiData data = new GuiData(); + + try { + data.IndexData(levels); + fetch.getGithubString(); + } catch (IOException e) { + e.printStackTrace(); + } + + System.out.println(data.getLocalLevels().size() + " ====== lovallevelsize"); + + for (int i = 0; i < data.getLocalLevels().size(); i++) { + + status.update(data.getLocalLevels().get(i), i); - database.insertData( - "levels", // Tabellenname - data.getAttempts().get(i), - fetch.allLevels().indexOf(levels.get(i).replace(".json", "")) + 1, - data.getLocalLevels().get(i), // Level-Name - levels.get(i).replace(".json", ""), // Level-Name-Raw (oder entsprechender Wert aus fetch.allLevels()) - Integer.parseInt(data.getId().get(i)), // ID - data.getCreator().get(i), // Ersteller - data.getCreators().get(i), // Ersteller - data.getVerifier().get(i), // Überprüfer - data.getYoutubeLink().get(i), // YouTube-Link - Integer.parseInt(data.getQualification().get(i)), // Qualifikation - data.getVictors().get(i), // Sieger - false, - false, - "" - ); - } - - try { - database.sortData("levels"); - } catch (SQLException e) { - e.printStackTrace(); - } - - } - - public void queryData(String tablename) { - Sqlite database = new Sqlite("levels"); - database.queryData(tablename); - } - + database.insertData( + "levels", // Tabellenname + data.getAttempts().get(i), + fetch.allLevels().indexOf(levels.get(i).replace(".json", "")) + 1, + data.getLocalLevels().get(i), // Level-Name + levels.get(i).replace(".json", ""), // Level-Name-Raw (oder entsprechender Wert aus fetch.allLevels()) + Integer.parseInt(data.getId().get(i)), // ID + data.getCreator().get(i), // Ersteller + data.getCreators().get(i), // Ersteller + data.getVerifier().get(i), // Überprüfer + data.getYoutubeLink().get(i), // YouTube-Link + Integer.parseInt(data.getQualification().get(i)), // Qualifikation + data.getVictors().get(i), // Sieger + false, + false, + "", + "" + ); + } + + try { + database.sortData("levels"); + } catch (SQLException e) { + e.printStackTrace(); + } + status.dispose(); + } + + public void queryData(String tablename) { + Sqlite database = new Sqlite("levels"); + database.queryData(tablename); + } + } diff --git a/src/database/Sqlite.java b/src/database/Sqlite.java index b3e1979..2ee3beb 100644 --- a/src/database/Sqlite.java +++ b/src/database/Sqlite.java @@ -11,11 +11,14 @@ import java.sql.Statement; import java.util.ArrayList; import data.FetchData; +import gui.LoadingStatus; public class Sqlite { private static String url = "jdbc:sqlite:C:\\ExtremeDemonList\\database\\sqlite\\"; private static String filename; + + private LoadingStatus status; private ArrayList levelname = new ArrayList(); private ArrayList levelID = new ArrayList(); @@ -30,6 +33,7 @@ public class Sqlite { private ArrayList attempts = new ArrayList(); private ArrayList locked = new ArrayList(); // New column private ArrayList pbarr = new ArrayList(); + private ArrayList levelLength = new ArrayList(); public ArrayList getLevelname() { return levelname; @@ -82,6 +86,10 @@ public class Sqlite { public ArrayList getPbarr() { return pbarr; } + + public ArrayList getLevelLength() { + return levelLength; + } public Sqlite(String dbname) { // setzt variablen url = "jdbc:sqlite:C:\\ExtremeDemonList\\database\\sqlite\\"; @@ -121,7 +129,8 @@ public class Sqlite { + " attempts INTEGER NOT NULL,\n" + " completed BOOLEAN NOT NULL,\n" + " locked BOOLEAN NOT NULL,\n" // Neue Spalte - + " personalBest STRING\n" + + " personalBest STRING,\n" + + " levelLength String\n" + ");"; try (Connection conn = DriverManager.getConnection(url); @@ -133,8 +142,8 @@ public class Sqlite { } } - public void insertData(String tablename, Integer attempts, int placement, String levelname, String levelnameRaw, int levelid, String author, String creators, String verifier, String verificationLink, int percenttoqualify, String records, boolean completed, boolean locked, String pb) { - String sql = "INSERT INTO " + tablename + " (placement, levelname, levelnameRaw, levelID, author, creators, verifier, verificationLink, percentToQualify, records, attempts, completed, locked, personalBest) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + public void insertData(String tablename, Integer attempts, int placement, String levelname, String levelnameRaw, int levelid, String author, String creators, String verifier, String verificationLink, int percenttoqualify, String records, boolean completed, boolean locked, String pb, String levelLength) { + String sql = "INSERT INTO " + tablename + " (placement, levelname, levelnameRaw, levelID, author, creators, verifier, verificationLink, percentToQualify, records, attempts, completed, locked, personalBest, levelLength) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; System.out.println("tablename: " + levelname); @@ -158,6 +167,7 @@ public class Sqlite { pstmt.setBoolean(12, completed); pstmt.setBoolean(13, locked); pstmt.setString(14, pb); + pstmt.setString(15, levelLength); pstmt.executeUpdate(); } catch (SQLException e) { @@ -188,6 +198,7 @@ public class Sqlite { attempts.add(rs.getInt("attempts")); locked.add(rs.getBoolean("locked")); // Get the value of the new column pbarr.add(rs.getString("personalBest")); + levelLength.add(rs.getString("levelLength")); } @@ -199,6 +210,11 @@ public class Sqlite { public void sortData(String tablename) throws SQLException { FetchData data = new FetchData(); + +status = LoadingStatus.getInstance(); // Holen der Singleton-Instanz + + status.initialize(); + status.changeState("Datenbank wird sortiert..."); ArrayList levelnamelocal = new ArrayList(); ArrayList levelIDlocal = new ArrayList(); @@ -213,6 +229,7 @@ public class Sqlite { ArrayList attemptsLocal = new ArrayList(); ArrayList lockedLocal = new ArrayList(); ArrayList pblocal = new ArrayList(); + ArrayList levelLengthlocal = new ArrayList(); try (Connection conn = DriverManager.getConnection(url); Statement stmt = conn.createStatement()) { @@ -229,11 +246,15 @@ public class Sqlite { maxPlacement = maxPlacementResult.getInt("maxPlacement"); } + int index = 0; + // Durchlaufen Sie die Platzierungen und holen Sie die Daten entsprechend for (int i = 1; i <= maxPlacement; i++) { String sql = "SELECT * FROM " + tablename + " WHERE placement = " + i; ResultSet rs = stmt.executeQuery(sql); while (rs.next()) { + index++; + status.update(rs.getString("levelname"), index); levelnamelocal.add(rs.getString("levelname")); levelIDlocal.add(rs.getInt("levelID") + ""); authorlocal.add(rs.getString("author")); @@ -247,6 +268,7 @@ public class Sqlite { attemptsLocal.add(rs.getInt("attempts")); lockedLocal.add(rs.getBoolean("locked")); pblocal.add(rs.getString("personalBest")); + levelLengthlocal.add(rs.getString("levelLength")); } } @@ -256,10 +278,13 @@ public class Sqlite { // Erstelle eine neue Tabelle mit dem ursprünglichen Namen createNewTable(tablename); + status.changeState("Daten werden in neue Tabelle migriert..."); + // Füge Daten in die neue Tabelle ein - String insert = "INSERT INTO " + tablename + " (placement, levelname, levelnameRaw, levelID, author, creators, verifier, verificationLink, percentToQualify, records, attempts, completed, locked, personalBest) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + String insert = "INSERT INTO " + tablename + " (placement, levelname, levelnameRaw, levelID, author, creators, verifier, verificationLink, percentToQualify, records, attempts, completed, locked, personalBest, levelLength) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; try (PreparedStatement pstmt = conn.prepareStatement(insert)) { for (int i = 0; i < levelnamelocal.size(); i++) { + status.update(levelnamelocal.get(i), i); if (i < rawLevelNameslocal.size()) { // Überprüfen, ob der Index im Array rawLevelNameslocal gültig ist String currentRawLevelName = rawLevelNameslocal.get(i); if (data.allLevels().indexOf(currentRawLevelName) == -1) { @@ -281,6 +306,7 @@ public class Sqlite { pstmt.setBoolean(12, Boolean.parseBoolean(completedlocal.get(i))); pstmt.setBoolean(13, lockedLocal.get(i)); // Insert value of locked column pstmt.setString(14, pblocal.get(i)); + pstmt.setString(15, levelLengthlocal.get(i)); pstmt.executeUpdate(); } } else { @@ -295,6 +321,7 @@ public class Sqlite { } catch (SQLException e) { e.printStackTrace(); } + status.dispose(); } public void removeEntry(String tablename, String rawLevelName) throws SQLException { @@ -311,16 +338,17 @@ public class Sqlite { } } - public void modifyData(String levelname, boolean completedStatus, int attempts, boolean lock, String percent) { - String sql = "UPDATE levels SET completed = ?, attempts = ?, locked = ?, personalBest = ? WHERE levelname = ?"; + public void modifyData(String levelname, boolean completedStatus, int attempts, boolean lock, String percent, String levelLength) { + String sql = "UPDATE levels SET completed = ?, attempts = ?, locked = ?, personalBest = ?, levelLength = ? WHERE levelname = ?"; try (Connection conn = DriverManager.getConnection(url); PreparedStatement pstmt = conn.prepareStatement(sql)) { - pstmt.setBoolean(1, completedStatus); - pstmt.setInt(2, attempts); - pstmt.setBoolean(3, lock); // Korrigierte Reihenfolge - pstmt.setString(4, percent); - pstmt.setString(5, levelname); // Korrigierte Reihenfolge + pstmt.setBoolean(1, completedStatus); + pstmt.setInt(2, attempts); + pstmt.setBoolean(3, lock); // Korrigierte Reihenfolge + pstmt.setString(4, percent); + pstmt.setString(5, levelLength); + pstmt.setString(6, levelname); // Korrigierte Reihenfolge @@ -336,7 +364,7 @@ public class Sqlite { } public void checkColumns(String tablename) { - String[] spalten = {"placement", "levelname", "levelnameRaw", "levelID", "author", "creators", "verifier", "verificationLink", "percentToQualify", "records", "attempts", "completed", "locked", "personalBest"}; + String[] spalten = {"placement", "levelname", "levelnameRaw", "levelID", "author", "creators", "verifier", "verificationLink", "percentToQualify", "records", "attempts", "completed", "locked", "personalBest", "levelLength"}; // Datenbankverbindung try (Connection connection = DriverManager.getConnection(url)) { diff --git a/src/firstlaunch/FirstlaunchMain.java b/src/firstlaunch/FirstlaunchMain.java deleted file mode 100644 index 0026e85..0000000 --- a/src/firstlaunch/FirstlaunchMain.java +++ /dev/null @@ -1,10 +0,0 @@ -package firstlaunch; - -public class FirstlaunchMain { - - public void main() { - - - } - -} diff --git a/src/gui/LoadingStatus.java b/src/gui/LoadingStatus.java new file mode 100644 index 0000000..d6dc3db --- /dev/null +++ b/src/gui/LoadingStatus.java @@ -0,0 +1,78 @@ +package gui; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JProgressBar; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; + +import data.FetchData; +import data.ManageFiles; + +public class LoadingStatus { + + private static LoadingStatus instance = null; + + private JTextArea area = new JTextArea(); + private JProgressBar bar = new JProgressBar(); + private JFrame main = new JFrame("Updater"); + private JLabel info = new JLabel("Updateroutine wird durchgeführt..."); + private FetchData data = new FetchData(); + + private LoadingStatus() { + initialize(); + } + + public void initialize() { + main.setSize(400, 300); + main.setLayout(null); + main.setResizable(false); + main.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + + info.setBounds(80, 1, 500, 30); + + area.setEditable(false); + area.setLineWrap(true); + area.setWrapStyleWord(true); + area.setCaretPosition(area.getDocument().getLength()); + + JScrollPane scroll = new JScrollPane(area); + scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scroll.setBounds(1, 60, 383, 201); + + + bar.setBounds(1, 29, 382, 30); + bar.setMinimum(0); + + bar.setStringPainted(true); + + main.add(info); + main.add(scroll); + main.add(bar); + main.setVisible(true); + } + + public static synchronized LoadingStatus getInstance() { + if (instance == null) { + instance = new LoadingStatus(); + } + return instance; + } + + public void update(String level, int barValue) { + area.append(level + "\n"); + bar.setValue(barValue + 1); + } + + public void dispose() { + main.dispose(); + } + + public void changeState(String state) { + bar.setMaximum(data.allLevels().size()); + bar.setValue(0); + info.setText(state); + area.setText(""); + } +} diff --git a/src/gui/MainGUI.java b/src/gui/MainGUI.java index 7440e0c..b6d2199 100644 --- a/src/gui/MainGUI.java +++ b/src/gui/MainGUI.java @@ -280,7 +280,7 @@ public class MainGUI { public void actionPerformed(ActionEvent e) { if(!(comp[index] == Boolean.parseBoolean(data.getCompleted().get(index))) || !(attempts.getText().equals(data.getAttempts().get(index) + "")) || !(data.getLocked().get(index) == lockbool[index])) { - data.modifyData(data.getLevelname().get(index), comp[index], Integer.parseInt(attempts.getText()), lockbool[index], data.getPbarr().get(index)); + data.modifyData(data.getLevelname().get(index), comp[index], Integer.parseInt(attempts.getText()), lockbool[index], data.getPbarr().get(index), data.getLevelLength().get(index)); } diff --git a/src/gui/SettingsGui.java b/src/gui/SettingsGui.java index ff5786b..b08fa9f 100644 --- a/src/gui/SettingsGui.java +++ b/src/gui/SettingsGui.java @@ -87,6 +87,8 @@ public class SettingsGui { }); + Button lengthReq = new Button("Länge der Level abfragen"); + Button delete = new Button("Datenbank löschen"); delete.setBounds(150, 206, 150, 30); diff --git a/src/main/Main.java b/src/main/Main.java index 94b8ee6..273c262 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -3,6 +3,7 @@ package main; import java.io.IOException; import java.util.zip.DataFormatException; +import api.GetApiData; import data.FetchData; import data.ManageFiles; import database.DatabaseManager; diff --git a/src/module-info.java b/src/module-info.java index a21e7ba..698127d 100644 --- a/src/module-info.java +++ b/src/module-info.java @@ -10,4 +10,5 @@ requires java.sql; requires java.xml; requires org.apache.commons.codec; + requires github.api; } \ No newline at end of file diff --git a/src/preload/AssetManager.java b/src/preload/AssetManager.java index cee986a..5b9706e 100644 --- a/src/preload/AssetManager.java +++ b/src/preload/AssetManager.java @@ -1,5 +1,11 @@ package preload; +import java.io.File; + public class AssetManager { + + public void checkAssets() { + File file = new File(""); + } } diff --git a/src/readsafefile/ReadAttemptsFromXML.java b/src/readsafefile/ReadAttemptsFromXML.java index 708cac1..8e0592d 100644 --- a/src/readsafefile/ReadAttemptsFromXML.java +++ b/src/readsafefile/ReadAttemptsFromXML.java @@ -15,6 +15,7 @@ public class ReadAttemptsFromXML { public Map attempts = new HashMap(); public Map newbestMap = new HashMap<>(); + public Map lengthMap = new HashMap<>(); public void readAttempts() { try { @@ -46,6 +47,7 @@ public class ReadAttemptsFromXML { NodeList dChildren = dElement.getChildNodes(); String attemptsValue = null; String percentValue = null; + String lengthValue = null; for (int j = 0; j < dChildren.getLength(); j++) { if (dChildren.item(j).getNodeName().equals("k")) { @@ -54,21 +56,30 @@ public class ReadAttemptsFromXML { if (kChild.getTextContent().equals("k18")) { attemptsValue = dChildren.item(j + 1).getTextContent(); } - + if (kChild.getTextContent().equals("k19")) { percentValue = dChildren.item(j + 1).getTextContent(); } + + if(kChild.getTextContent().equals("k23")) { + lengthValue = dChildren.item(j + 1).getTextContent(); + } } } + + if(lengthValue != null) { + lengthMap.put(currentLevelID, lengthValue); + } + if (attemptsValue != null && percentValue != null) { tempAttempts.put(currentLevelID, attemptsValue ); // + "," + percentValue newbestMap.put(currentLevelID, percentValue); + } } } - // Füge die Daten aus der temporären Map in die attempts-Map ein attempts.putAll(tempAttempts); } catch (Exception e) { e.printStackTrace(); diff --git a/src/readsafefile/Request.java b/src/readsafefile/Request.java new file mode 100644 index 0000000..b36a538 --- /dev/null +++ b/src/readsafefile/Request.java @@ -0,0 +1,5 @@ +package readsafefile; + +public class Request { + +} diff --git a/src/readsafefile/SafeFileManager.java b/src/readsafefile/SafeFileManager.java index 233182b..7ab9b82 100644 --- a/src/readsafefile/SafeFileManager.java +++ b/src/readsafefile/SafeFileManager.java @@ -8,6 +8,8 @@ import gui.AttemptsProgress; public class SafeFileManager { + private String[] lengthArr = {"Tiny", "Short", "Medium", "Long", "XL", "Platformer", "N/A"}; + public void DecryptSafeFile() throws IOException { DecryptXOR.decryptAndWriteFiles(); } @@ -39,6 +41,12 @@ public class SafeFileManager { for(int i = 0; i < database.getLevelID().size(); i++) { attempts = read.attempts.get(database.getLevelID().get(i)); percent = read.newbestMap.get(database.getLevelID().get(i)); + + if(read.lengthMap.get(database.getLevelID().get(i)) != null) { + System.out.println(lengthArr[Integer.parseInt(read.lengthMap.get(database.getLevelID().get(i)))]); + } + + if(attempts == null) { attempts = 0 + ""; } @@ -47,7 +55,7 @@ public class SafeFileManager { } prog.update(database.getLevelname().get(i), Integer.parseInt(attempts), Integer.parseInt(percent), i); if(!database.getLocked().get(i)) { - database.modifyData(database.getLevelname().get(i), Boolean.parseBoolean(database.getCompleted().get(i)), Integer.parseInt(attempts), database.getLocked().get(i), percent); + database.modifyData(database.getLevelname().get(i), Boolean.parseBoolean(database.getCompleted().get(i)), Integer.parseInt(attempts), database.getLocked().get(i), percent, database.getLevelLength().get(i)); } } prog.close();