Compare commits
16 commits
2024041021
...
main
Author | SHA1 | Date | |
---|---|---|---|
31a51fd76f | |||
e4e071b551 | |||
![]() |
a21f5e04a4 | ||
![]() |
49f80a53be | ||
![]() |
bd754f04e6 | ||
![]() |
eaf293fc09 | ||
![]() |
bf1195bb49 | ||
![]() |
8ff5e2947e | ||
![]() |
0557862a0a | ||
![]() |
184cde85d5 | ||
![]() |
80dcc5fbf8 | ||
![]() |
c723c1b9ff | ||
![]() |
4e0f55fa02 | ||
![]() |
a80723c695 | ||
![]() |
4ccdb53aa0 | ||
![]() |
5a7d53f600 |
23 changed files with 448 additions and 196 deletions
2
.github/workflows/maven.yml
vendored
2
.github/workflows/maven.yml
vendored
|
@ -9,7 +9,7 @@ on:
|
|||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: docker
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding//src/test/resources=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
encoding/src=UTF-8
|
||||
|
|
33
pom.xml
33
pom.xml
|
@ -17,21 +17,11 @@
|
|||
<artifactId>json</artifactId>
|
||||
<version>20231013</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.formdev</groupId>
|
||||
<artifactId>flatlaf</artifactId>
|
||||
<version>3.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alex1304.jdash</groupId>
|
||||
<artifactId>jdash-client</artifactId>
|
||||
|
@ -55,12 +45,27 @@
|
|||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.15</version> <!-- oder die neueste Version -->
|
||||
<version>1.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>31.0.1-jre</version> <!-- oder die neueste Version -->
|
||||
<groupId>org.kohsuke</groupId>
|
||||
<artifactId>github-api</artifactId>
|
||||
<version>1.127</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<version>1.6.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.33</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.qtjambi</groupId>
|
||||
<artifactId>qtjambi</artifactId>
|
||||
<version>6.7.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import java.net.URL;
|
|||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
|
@ -84,18 +83,18 @@ public class DownloadLevels {
|
|||
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
||||
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
area.append(" >> ERFOLGREICH \n");
|
||||
}
|
||||
|
||||
JOptionPane.showMessageDialog(null, "Alle " + ManageFiles.getMissinglevels().size() + " Level wurden erfolgreich heruntergeladen.", "Download abgeschlossen", JOptionPane.INFORMATION_MESSAGE);
|
||||
main.dispose();
|
||||
|
||||
MainGUI gui = new MainGUI();
|
||||
MigrateData migrate = new MigrateData();
|
||||
migrate.migrateData();
|
||||
|
||||
try {
|
||||
gui.build();
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -6,10 +6,9 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import database.DatabaseManager;
|
||||
|
||||
public class GuiData {
|
||||
|
||||
private ArrayList<String> localLevels = new ArrayList<String>();
|
||||
|
@ -66,9 +65,6 @@ public class GuiData {
|
|||
}
|
||||
|
||||
public void IndexData(ArrayList<String> migrate) throws IOException {
|
||||
DatabaseManager mgr = new DatabaseManager();
|
||||
|
||||
|
||||
File filelength = new File("C:\\ExtremeDemonList\\levels");
|
||||
File[] filelengthindex = filelength.listFiles();
|
||||
|
||||
|
@ -85,8 +81,15 @@ public class GuiData {
|
|||
|
||||
localLevels.add(obj.getString("name"));
|
||||
id.add(obj.getInt("id") + "");
|
||||
verifier.add(obj.getString("verifier"));
|
||||
creator.add(obj.getString("author"));
|
||||
|
||||
try {
|
||||
verifier.add(obj.getString("verifier"));
|
||||
creator.add(obj.getString("author"));
|
||||
} catch (JSONException e) {
|
||||
verifier.add(Long.toString(obj.getLong("verifier")));
|
||||
creator.add(Long.toString(obj.getLong("author")));
|
||||
}
|
||||
|
||||
qualification.add(obj.getInt("percentToQualify") + "");
|
||||
ytlink.add(obj.getString("verification") + "");
|
||||
creators.add(obj.getJSONArray("creators") + "");
|
||||
|
|
|
@ -38,6 +38,5 @@ public class ManageFiles {
|
|||
MainGUI gui = new MainGUI();
|
||||
gui.build();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String> levels = new ArrayList<String>();
|
||||
ArrayList<String> rawLevels = new ArrayList<String>();
|
||||
|
||||
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();
|
||||
|
||||
status.initialize();
|
||||
|
||||
LoadSettings settings = new LoadSettings();
|
||||
try {
|
||||
settings.load();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ArrayList<String> levels = new ArrayList<String>();
|
||||
ArrayList<String> rawLevels = new ArrayList<String>();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<String> levelname = new ArrayList<String>();
|
||||
private ArrayList<String> levelID = new ArrayList<String>();
|
||||
|
@ -30,6 +33,7 @@ public class Sqlite {
|
|||
private ArrayList<Integer> attempts = new ArrayList<Integer>();
|
||||
private ArrayList<Boolean> locked = new ArrayList<Boolean>(); // New column
|
||||
private ArrayList<String> pbarr = new ArrayList<String>();
|
||||
private ArrayList<String> levelLength = new ArrayList<String>();
|
||||
|
||||
public ArrayList<String> getLevelname() {
|
||||
return levelname;
|
||||
|
@ -82,6 +86,10 @@ public class Sqlite {
|
|||
public ArrayList<String> getPbarr() {
|
||||
return pbarr;
|
||||
}
|
||||
|
||||
public ArrayList<String> 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 NOT NULL,\n"
|
||||
+ " levelLength String NOT NULL\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) {
|
||||
|
@ -166,39 +176,49 @@ public class Sqlite {
|
|||
}
|
||||
|
||||
public void queryData(String tablename) {
|
||||
FetchData fetch = new FetchData();
|
||||
|
||||
String sql = "SELECT * FROM " + tablename;
|
||||
String sql = "SELECT levelname, levelID, author, creators, verifier, verificationLink, " +
|
||||
"percentToQualify, completed, records, levelNameRaw, attempts, locked, " +
|
||||
"personalBest, levelLength FROM " + tablename + " WHERE levelNameRaw = ?";
|
||||
|
||||
try (Connection conn = DriverManager.getConnection(url);
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(sql)) {
|
||||
|
||||
// loop through the result set
|
||||
while (rs.next()) {
|
||||
levelname.add(rs.getString("levelname"));
|
||||
levelID.add(rs.getInt("levelID") + "");
|
||||
author.add(rs.getString("author"));
|
||||
creators.add(rs.getString("creators"));
|
||||
verifier.add(rs.getString("verifier"));
|
||||
verificationLink.add(rs.getString("verificationLink"));
|
||||
percenttoqualify.add(rs.getInt("percentToQualify") + "");
|
||||
completed.add(rs.getBoolean("completed") + "");
|
||||
records.add(rs.getString("records"));
|
||||
rawLevelNames.add(rs.getString("levelNameRaw"));
|
||||
attempts.add(rs.getInt("attempts"));
|
||||
locked.add(rs.getBoolean("locked")); // Get the value of the new column
|
||||
pbarr.add(rs.getString("personalBest"));
|
||||
PreparedStatement pstmt = conn.prepareStatement(sql)) {
|
||||
|
||||
for (int i = 0; i < fetch.allLevels().size(); i++) {
|
||||
pstmt.setString(1, fetch.allLevels().get(i));
|
||||
try (ResultSet rs = pstmt.executeQuery()) {
|
||||
while (rs.next()) { // Sicherstellen, dass alle Zeilen verarbeitet werden
|
||||
levelname.add(rs.getString("levelname"));
|
||||
levelID.add(rs.getInt("levelID") + "");
|
||||
author.add(rs.getString("author"));
|
||||
creators.add(rs.getString("creators"));
|
||||
verifier.add(rs.getString("verifier"));
|
||||
verificationLink.add(rs.getString("verificationLink"));
|
||||
percenttoqualify.add(rs.getInt("percentToQualify") + "");
|
||||
completed.add(rs.getBoolean("completed") + "");
|
||||
records.add(rs.getString("records"));
|
||||
rawLevelNames.add(rs.getString("levelNameRaw"));
|
||||
attempts.add(rs.getInt("attempts"));
|
||||
locked.add(rs.getBoolean("locked"));
|
||||
pbarr.add(rs.getString("personalBest"));
|
||||
levelLength.add(rs.getString("levelLength"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void sortData(String tablename) throws SQLException {
|
||||
FetchData data = new FetchData();
|
||||
|
||||
status = LoadingStatus.getInstance(); // Holen der Singleton-Instanz
|
||||
|
||||
status.initialize();
|
||||
|
||||
|
||||
ArrayList<String> levelnamelocal = new ArrayList<String>();
|
||||
ArrayList<String> levelIDlocal = new ArrayList<String>();
|
||||
|
@ -213,6 +233,7 @@ public class Sqlite {
|
|||
ArrayList<Integer> attemptsLocal = new ArrayList<Integer>();
|
||||
ArrayList<Boolean> lockedLocal = new ArrayList<Boolean>();
|
||||
ArrayList<String> pblocal = new ArrayList<String>();
|
||||
ArrayList<String> levelLengthlocal = new ArrayList<String>();
|
||||
|
||||
try (Connection conn = DriverManager.getConnection(url);
|
||||
Statement stmt = conn.createStatement()) {
|
||||
|
@ -229,11 +250,17 @@ public class Sqlite {
|
|||
maxPlacement = maxPlacementResult.getInt("maxPlacement");
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
|
||||
status.changeState("Datenbank wird sortiert...", maxPlacement);
|
||||
|
||||
// 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 +274,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 +284,13 @@ public class Sqlite {
|
|||
// Erstelle eine neue Tabelle mit dem ursprünglichen Namen
|
||||
createNewTable(tablename);
|
||||
|
||||
status.changeState("Daten werden in neue Tabelle migriert...", levelnamelocal.size());
|
||||
|
||||
// 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 +312,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 +327,7 @@ public class Sqlite {
|
|||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
status.dispose();
|
||||
}
|
||||
|
||||
public void removeEntry(String tablename, String rawLevelName) throws SQLException {
|
||||
|
@ -311,16 +344,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,23 +370,19 @@ 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)) {
|
||||
DatabaseMetaData metaData = connection.getMetaData();
|
||||
ResultSet resultSet;
|
||||
|
||||
int missing = 0;
|
||||
|
||||
// Schleife über die Spalten
|
||||
for (String spalte : spalten) {
|
||||
// Abfrage der Spalteninformationen
|
||||
resultSet = metaData.getColumns(null, null, tablename, spalte);
|
||||
|
||||
if (!resultSet.next()) {
|
||||
System.out.println("Spalte " + spalte + " existiert nicht. Eine neue Spalte wird erstellt.");
|
||||
// Eine neue Spalte erstellen
|
||||
createNewColumn(tablename, spalte);
|
||||
missing++;
|
||||
}
|
||||
|
@ -368,7 +398,7 @@ public class Sqlite {
|
|||
}
|
||||
|
||||
private void createNewColumn(String tablename, String columnName) {
|
||||
String sql = "ALTER TABLE " + tablename + " ADD COLUMN " + columnName + " TEXT";
|
||||
String sql = "ALTER TABLE " + tablename + " ADD COLUMN " + columnName + " TEXT NOT NULL";
|
||||
try (Connection conn = DriverManager.getConnection(url);
|
||||
Statement stmt = conn.createStatement()) {
|
||||
stmt.executeUpdate(sql);
|
||||
|
@ -377,6 +407,7 @@ public class Sqlite {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void moveDataToNewDatabase(String tablename) {
|
||||
// Neuen Tabellennamen für die Kopie
|
||||
String newTableName = tablename + "_new";
|
||||
|
|
21
src/errorhandler/ErrorHandler.java
Normal file
21
src/errorhandler/ErrorHandler.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package errorhandler;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class ErrorHandler {
|
||||
|
||||
public void newError(Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
e.printStackTrace(pw);
|
||||
|
||||
JOptionPane.showMessageDialog(null, sw.toString() + "", e.getMessage(), JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
}
|
18
src/errorhandler/ErrorSubmission.java
Normal file
18
src/errorhandler/ErrorSubmission.java
Normal file
|
@ -0,0 +1,18 @@
|
|||
package errorhandler;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.mail.Authenticator;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.PasswordAuthentication;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.Transport;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
public class ErrorSubmission {
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package firstlaunch;
|
||||
|
||||
public class FirstlaunchMain {
|
||||
|
||||
public void main() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
79
src/gui/LoadingStatus.java
Normal file
79
src/gui/LoadingStatus.java
Normal file
|
@ -0,0 +1,79 @@
|
|||
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();
|
||||
|
||||
public LoadingStatus() {
|
||||
initialize();
|
||||
}
|
||||
|
||||
public static synchronized LoadingStatus getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new LoadingStatus();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
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 void update(String level, int barValue) {
|
||||
area.append(level + "\n");
|
||||
bar.setValue(barValue + 1);
|
||||
area.setCaretPosition(area.getDocument().getLength());
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
main.dispose();
|
||||
}
|
||||
|
||||
public void changeState(String state, int arrsize) {
|
||||
bar.setMaximum(arrsize);
|
||||
bar.setValue(0);
|
||||
info.setText(state);
|
||||
area.setText("");
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@ package gui;
|
|||
import java.awt.Button;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Toolkit;
|
||||
|
@ -18,10 +17,6 @@ import java.awt.event.KeyListener;
|
|||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.ProtocolException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.ImageIcon;
|
||||
|
@ -36,6 +31,7 @@ import javax.swing.JScrollPane;
|
|||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import api.GetApiData;
|
||||
import data.SortData;
|
||||
import database.Sqlite;
|
||||
|
||||
|
@ -59,6 +55,7 @@ public class MainGUI {
|
|||
public JLabel idshow = new JLabel("ID");
|
||||
public JLabel qualify = new JLabel("Qualifikation");
|
||||
public JLabel attemptslabel = new JLabel("Attempts");
|
||||
public JLabel lengthLabel = new JLabel("Länge");
|
||||
public JCheckBox filtercompleted = new JCheckBox("Nach geschafft filtern");
|
||||
public Button copyid = new Button("Level ID kopieren");
|
||||
public Button showinfos = new Button("Mehr Infos anzeigen");
|
||||
|
@ -83,6 +80,8 @@ public class MainGUI {
|
|||
Sqlite data = new Sqlite("levels");
|
||||
data.queryData("levels");
|
||||
|
||||
GetApiData api = new GetApiData();
|
||||
|
||||
//sort.sort();
|
||||
|
||||
gridLayout.setRows(data.getLevelname().size());
|
||||
|
@ -117,19 +116,21 @@ public class MainGUI {
|
|||
|
||||
idshow.setBounds(10, 110, 164, 30);
|
||||
|
||||
copyid.setBounds(10, 190, 164, 30);
|
||||
copyid.setBounds(10, 210, 164, 30);
|
||||
|
||||
qualify.setBounds(10, 130, 164, 30);
|
||||
|
||||
attemptslabel.setBounds(10, 150, 164, 30);
|
||||
|
||||
lengthLabel.setBounds(10, 170, 164, 30);
|
||||
|
||||
settings.setBounds(1, 1, 60, 60);
|
||||
settings.setFont(settings.getFont().deriveFont(30f));
|
||||
settings.setBackground(Color.LIGHT_GRAY);
|
||||
|
||||
showinfos.setBounds(12, 237, 160, 30);
|
||||
showinfos.setBounds(12, 257, 160, 30);
|
||||
|
||||
showcalc.setBounds(12, 283, 160, 30);
|
||||
showcalc.setBounds(12, 303, 160, 30);
|
||||
|
||||
startgame.setBounds(12, 560, 160, 30);
|
||||
|
||||
|
@ -143,7 +144,7 @@ public class MainGUI {
|
|||
elements.infopanel().setVisible(false);
|
||||
|
||||
separator.setBounds(0, 30, 300, 30);
|
||||
separator2.setBounds(0 ,160, 400, 30);
|
||||
separator2.setBounds(0 ,180, 400, 30);
|
||||
|
||||
creator.setBounds(10, 50, 164, 30);
|
||||
|
||||
|
@ -280,7 +281,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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -310,7 +311,7 @@ public class MainGUI {
|
|||
|
||||
contents.addMouseListener(new MouseListener() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
showinfos.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -328,14 +329,32 @@ public class MainGUI {
|
|||
attemptslabel.setText("Attempts: " + data.getAttempts().get(index));
|
||||
level.setVerticalAlignment(SwingConstants.CENTER);
|
||||
|
||||
lengthLabel.setText("Länge: lädt...");
|
||||
|
||||
String levellength = data.getLevelLength().get(index);
|
||||
|
||||
System.out.println("test:" + data.getLevelLength().get(index) + ".");
|
||||
|
||||
|
||||
if(data.getLevelLength().get(index).equals("N/A") || data.getLevelLength().get(index) == null) {
|
||||
levellength = api.getLevelLength(Integer.parseInt(data.getLevelID().get(index)));
|
||||
data.modifyData(data.getLevelname().get(index), comp[index], Integer.parseInt(attempts.getText()), lockbool[index], data.getPbarr().get(index), levellength);
|
||||
System.out.println("request");
|
||||
}
|
||||
|
||||
lengthLabel.setText("Länge: " + levellength);
|
||||
|
||||
copyid.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
StringSelection stringSelection = new StringSelection(data.getLevelID().get(index));
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
clipboard.setContents(stringSelection, null);
|
||||
clipboard.setContents(stringSelection, null);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
|
@ -377,7 +396,6 @@ public class MainGUI {
|
|||
if(show.getSelectedIndex() == 1) {
|
||||
if(!(Integer.parseInt(rank.getName()) >= 0 && Integer.parseInt(rank.getName()) <= 2)) {
|
||||
levelpanel.remove(contents);
|
||||
|
||||
levelpanel.repaint();
|
||||
levelpanel.revalidate();
|
||||
}
|
||||
|
@ -556,6 +574,7 @@ public class MainGUI {
|
|||
elements.infopanel().add(showinfos);
|
||||
elements.infopanel().add(attemptslabel);
|
||||
elements.infopanel().add(showcalc);
|
||||
elements.infopanel().add(lengthLabel);
|
||||
// elements.infopanel().add(startgame);
|
||||
|
||||
main.add(search);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -3,10 +3,14 @@ package main;
|
|||
import java.io.IOException;
|
||||
import java.util.zip.DataFormatException;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import api.GetApiData;
|
||||
import data.FetchData;
|
||||
import data.ManageFiles;
|
||||
import database.DatabaseManager;
|
||||
import database.Sqlite;
|
||||
import errorhandler.ErrorHandler;
|
||||
import filestructure.CreateFileStructure;
|
||||
import gui.LoadMenu;
|
||||
import preload.PreChecks;
|
||||
|
@ -15,6 +19,16 @@ import settingsfunctions.LoadSettings;
|
|||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws IOException, DataFormatException {
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
ErrorHandler error = new ErrorHandler();
|
||||
error.newError(e);
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
|
||||
LoadMenu load = new LoadMenu();
|
||||
load.onLoad();
|
||||
|
@ -53,6 +67,10 @@ public class Main {
|
|||
|
||||
load.updateBar("Ladevorgang abgeschlossen");
|
||||
load.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("fehler");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
requires org.json;
|
||||
requires org.apache.commons.io;
|
||||
requires java.datatransfer;
|
||||
requires com.formdev.flatlaf;
|
||||
requires jdash.client;
|
||||
requires jdash.common;
|
||||
requires jlayer;
|
||||
requires java.sql;
|
||||
requires java.xml;
|
||||
requires org.apache.commons.codec;
|
||||
requires github.api;
|
||||
requires java.mail;
|
||||
}
|
|
@ -1,5 +1,11 @@
|
|||
package preload;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class AssetManager {
|
||||
|
||||
public void checkAssets() {
|
||||
File file = new File("");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,5 +24,4 @@ public class PreChecks {
|
|||
migration.migrateData();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.apache.commons.codec.binary.Base64;
|
|||
|
||||
public class DecryptXOR {
|
||||
|
||||
private static final String[] SAVES = {"CCGameManager.dat"};
|
||||
private static final String[] SAVES = {"CCGameManager.dat"};
|
||||
private static final int XOR_KEY = 11;
|
||||
|
||||
private static byte[] xor(byte[] data, int key) {
|
||||
|
|
|
@ -15,6 +15,12 @@ public class ReadAttemptsFromXML {
|
|||
|
||||
public Map<String, String> attempts = new HashMap<String, String>();
|
||||
public Map<String, String> newbestMap = new HashMap<>();
|
||||
public Map<String, String> lengthMap = new HashMap<>();
|
||||
|
||||
public Map<String, String> getLengthMap() {
|
||||
System.out.println("size getLengthMap in function: " + lengthMap.size());
|
||||
return lengthMap;
|
||||
}
|
||||
|
||||
public void readAttempts() {
|
||||
try {
|
||||
|
@ -46,6 +52,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 +61,25 @@ 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 (attemptsValue != null && percentValue != null) {
|
||||
|
||||
if (attemptsValue != null && percentValue != null && lengthValue != null) {
|
||||
tempAttempts.put(currentLevelID, attemptsValue ); // + "," + percentValue
|
||||
newbestMap.put(currentLevelID, percentValue);
|
||||
lengthMap.put(currentLevelID, lengthValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Füge die Daten aus der temporären Map in die attempts-Map ein
|
||||
System.out.println("lengthmap size: " + lengthMap.size());
|
||||
attempts.putAll(tempAttempts);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
5
src/readsafefile/Request.java
Normal file
5
src/readsafefile/Request.java
Normal file
|
@ -0,0 +1,5 @@
|
|||
package readsafefile;
|
||||
|
||||
public class Request {
|
||||
|
||||
}
|
|
@ -1,27 +1,37 @@
|
|||
package readsafefile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import data.FetchData;
|
||||
import data.ManageFiles;
|
||||
import database.Sqlite;
|
||||
import gui.AttemptsProgress;
|
||||
|
||||
public class SafeFileManager {
|
||||
|
||||
private String[] lengthArr = {"TINY", "SHORT", "MEDIUM", "LONG", "XL", "PLATFORMER", "N/A"};
|
||||
public Map<String, String> lengthComp = new HashMap<>();
|
||||
private Sqlite database = new Sqlite("levels");
|
||||
private ReadAttemptsFromXML read = new ReadAttemptsFromXML();
|
||||
|
||||
public void DecryptSafeFile() throws IOException {
|
||||
DecryptXOR.decryptAndWriteFiles();
|
||||
}
|
||||
|
||||
public void ReadIndexAttempts() throws IOException {
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
read.readAttempts();
|
||||
|
||||
AttemptsProgress prog = new AttemptsProgress();
|
||||
prog.build();
|
||||
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Sqlite database = new Sqlite("levels");
|
||||
database.queryData("levels");
|
||||
FetchData fetch = new FetchData();
|
||||
try {
|
||||
|
@ -30,29 +40,42 @@ public class SafeFileManager {
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ReadAttemptsFromXML read = new ReadAttemptsFromXML();
|
||||
System.out.println("size lengthMap: " + read.getLengthMap().size());
|
||||
|
||||
read.readAttempts();
|
||||
lengthComp.putAll(read.lengthMap);
|
||||
|
||||
String attempts;
|
||||
String percent;
|
||||
String length;
|
||||
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));
|
||||
length = read.lengthMap.get(database.getLevelID().get(i));
|
||||
|
||||
if(attempts == null) {
|
||||
attempts = 0 + "";
|
||||
}
|
||||
if(percent == null) {
|
||||
percent = 0 + "";
|
||||
}
|
||||
if(length == null) {
|
||||
length = 6 + "";
|
||||
}
|
||||
|
||||
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, lengthArr[Integer.parseInt(length)]);
|
||||
} else {
|
||||
database.modifyData(database.getLevelname().get(i), Boolean.parseBoolean(database.getCompleted().get(i)), database.getAttempts().get(i), database.getLocked().get(i), database.getRecords().get(i), lengthArr[Integer.parseInt(length)]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
prog.close();
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue