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:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: docker
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
encoding//src/test/java=UTF-8
|
|
||||||
encoding//src/test/resources=UTF-8
|
|
||||||
encoding/<project>=UTF-8
|
encoding/<project>=UTF-8
|
||||||
encoding/src=UTF-8
|
encoding/src=UTF-8
|
||||||
|
|
33
pom.xml
33
pom.xml
|
@ -17,21 +17,11 @@
|
||||||
<artifactId>json</artifactId>
|
<artifactId>json</artifactId>
|
||||||
<version>20231013</version>
|
<version>20231013</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.code.gson</groupId>
|
|
||||||
<artifactId>gson</artifactId>
|
|
||||||
<version>2.8.9</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>2.7</version>
|
<version>2.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.formdev</groupId>
|
|
||||||
<artifactId>flatlaf</artifactId>
|
|
||||||
<version>3.4</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alex1304.jdash</groupId>
|
<groupId>com.alex1304.jdash</groupId>
|
||||||
<artifactId>jdash-client</artifactId>
|
<artifactId>jdash-client</artifactId>
|
||||||
|
@ -55,12 +45,27 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-codec</groupId>
|
<groupId>commons-codec</groupId>
|
||||||
<artifactId>commons-codec</artifactId>
|
<artifactId>commons-codec</artifactId>
|
||||||
<version>1.15</version> <!-- oder die neueste Version -->
|
<version>1.15</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>org.kohsuke</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>github-api</artifactId>
|
||||||
<version>31.0.1-jre</version> <!-- oder die neueste Version -->
|
<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>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -26,4 +26,22 @@ public class GetApiData {
|
||||||
return songID;
|
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.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JProgressBar;
|
import javax.swing.JProgressBar;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
|
@ -84,18 +83,18 @@ public class DownloadLevels {
|
||||||
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
area.append(" >> ERFOLGREICH \n");
|
area.append(" >> ERFOLGREICH \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(null, "Alle " + ManageFiles.getMissinglevels().size() + " Level wurden erfolgreich heruntergeladen.", "Download abgeschlossen", JOptionPane.INFORMATION_MESSAGE);
|
|
||||||
main.dispose();
|
main.dispose();
|
||||||
|
|
||||||
MainGUI gui = new MainGUI();
|
MainGUI gui = new MainGUI();
|
||||||
MigrateData migrate = new MigrateData();
|
MigrateData migrate = new MigrateData();
|
||||||
migrate.migrateData();
|
migrate.migrateData();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
gui.build();
|
gui.build();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -6,10 +6,9 @@ import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import database.DatabaseManager;
|
|
||||||
|
|
||||||
public class GuiData {
|
public class GuiData {
|
||||||
|
|
||||||
private ArrayList<String> localLevels = new ArrayList<String>();
|
private ArrayList<String> localLevels = new ArrayList<String>();
|
||||||
|
@ -66,9 +65,6 @@ public class GuiData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IndexData(ArrayList<String> migrate) throws IOException {
|
public void IndexData(ArrayList<String> migrate) throws IOException {
|
||||||
DatabaseManager mgr = new DatabaseManager();
|
|
||||||
|
|
||||||
|
|
||||||
File filelength = new File("C:\\ExtremeDemonList\\levels");
|
File filelength = new File("C:\\ExtremeDemonList\\levels");
|
||||||
File[] filelengthindex = filelength.listFiles();
|
File[] filelengthindex = filelength.listFiles();
|
||||||
|
|
||||||
|
@ -85,8 +81,15 @@ public class GuiData {
|
||||||
|
|
||||||
localLevels.add(obj.getString("name"));
|
localLevels.add(obj.getString("name"));
|
||||||
id.add(obj.getInt("id") + "");
|
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") + "");
|
qualification.add(obj.getInt("percentToQualify") + "");
|
||||||
ytlink.add(obj.getString("verification") + "");
|
ytlink.add(obj.getString("verification") + "");
|
||||||
creators.add(obj.getJSONArray("creators") + "");
|
creators.add(obj.getJSONArray("creators") + "");
|
||||||
|
|
|
@ -38,6 +38,5 @@ public class ManageFiles {
|
||||||
MainGUI gui = new MainGUI();
|
MainGUI gui = new MainGUI();
|
||||||
gui.build();
|
gui.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,95 +7,102 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import data.FetchData;
|
import data.FetchData;
|
||||||
import data.GuiData;
|
import data.GuiData;
|
||||||
|
import gui.LoadingStatus;
|
||||||
import settingsfunctions.LoadSettings;
|
import settingsfunctions.LoadSettings;
|
||||||
|
|
||||||
public class DatabaseManager {
|
public class DatabaseManager {
|
||||||
|
|
||||||
public void manage() {
|
private LoadingStatus status; // Singleton-Instanz von LoadingStatus
|
||||||
Sqlite createLevelDB = new Sqlite("levels");
|
|
||||||
if(createLevelDB.exists()) {
|
|
||||||
} else {
|
|
||||||
createLevelDB.createNewDatabase("levels");
|
|
||||||
}
|
|
||||||
createLevelDB.createNewTable("levels");
|
|
||||||
|
|
||||||
createLevelDB.checkColumns("levels");
|
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();
|
public void migrateData() {
|
||||||
try {
|
Sqlite database = new Sqlite("levels");
|
||||||
settings.load();
|
FetchData fetch = new FetchData();
|
||||||
} catch (IOException e) {
|
status = LoadingStatus.getInstance();
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<String> levels = new ArrayList<String>();
|
status.initialize();
|
||||||
ArrayList<String> rawLevels = new ArrayList<String>();
|
|
||||||
|
|
||||||
File file = new File("C:\\ExtremeDemonList\\levels");
|
LoadSettings settings = new LoadSettings();
|
||||||
File[] listLevels = file.listFiles();
|
try {
|
||||||
|
settings.load();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < listLevels.length; i++) {
|
ArrayList<String> levels = new ArrayList<String>();
|
||||||
rawLevels.add(listLevels[i].getName());
|
ArrayList<String> rawLevels = new ArrayList<String>();
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i < fetch.allLevels().size(); i++) {
|
File file = new File("C:\\ExtremeDemonList\\levels");
|
||||||
if(rawLevels.indexOf(fetch.allLevels().get(i) + ".json") != -1) {
|
File[] listLevels = file.listFiles();
|
||||||
levels.add(rawLevels.get(rawLevels.indexOf(fetch.allLevels().get(i) + ".json")));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
for(int i = 0; i < listLevels.length; i++) {
|
||||||
|
rawLevels.add(listLevels[i].getName());
|
||||||
|
}
|
||||||
|
|
||||||
GuiData data = new GuiData();
|
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")));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
}
|
||||||
data.IndexData(levels);
|
|
||||||
fetch.getGithubString();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println(data.getLocalLevels().size() + " ====== lovallevelsize");
|
GuiData data = new GuiData();
|
||||||
|
|
||||||
for (int i = 0; i < data.getLocalLevels().size(); i++) {
|
try {
|
||||||
|
data.IndexData(levels);
|
||||||
|
fetch.getGithubString();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
System.out.println(data.getLocalLevels().get(i));
|
System.out.println(data.getLocalLevels().size() + " ====== lovallevelsize");
|
||||||
|
|
||||||
database.insertData(
|
for (int i = 0; i < data.getLocalLevels().size(); i++) {
|
||||||
"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 {
|
status.update(data.getLocalLevels().get(i), i);
|
||||||
database.sortData("levels");
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
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,
|
||||||
|
"",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public void queryData(String tablename) {
|
try {
|
||||||
Sqlite database = new Sqlite("levels");
|
database.sortData("levels");
|
||||||
database.queryData(tablename);
|
} catch (SQLException e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
status.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void queryData(String tablename) {
|
||||||
|
Sqlite database = new Sqlite("levels");
|
||||||
|
database.queryData(tablename);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,15 @@ import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import data.FetchData;
|
import data.FetchData;
|
||||||
|
import gui.LoadingStatus;
|
||||||
|
|
||||||
public class Sqlite {
|
public class Sqlite {
|
||||||
|
|
||||||
private static String url = "jdbc:sqlite:C:\\ExtremeDemonList\\database\\sqlite\\";
|
private static String url = "jdbc:sqlite:C:\\ExtremeDemonList\\database\\sqlite\\";
|
||||||
private static String filename;
|
private static String filename;
|
||||||
|
|
||||||
|
private LoadingStatus status;
|
||||||
|
|
||||||
private ArrayList<String> levelname = new ArrayList<String>();
|
private ArrayList<String> levelname = new ArrayList<String>();
|
||||||
private ArrayList<String> levelID = new ArrayList<String>();
|
private ArrayList<String> levelID = new ArrayList<String>();
|
||||||
private ArrayList<String> author = new ArrayList<String>();
|
private ArrayList<String> author = new ArrayList<String>();
|
||||||
|
@ -30,6 +33,7 @@ public class Sqlite {
|
||||||
private ArrayList<Integer> attempts = new ArrayList<Integer>();
|
private ArrayList<Integer> attempts = new ArrayList<Integer>();
|
||||||
private ArrayList<Boolean> locked = new ArrayList<Boolean>(); // New column
|
private ArrayList<Boolean> locked = new ArrayList<Boolean>(); // New column
|
||||||
private ArrayList<String> pbarr = new ArrayList<String>();
|
private ArrayList<String> pbarr = new ArrayList<String>();
|
||||||
|
private ArrayList<String> levelLength = new ArrayList<String>();
|
||||||
|
|
||||||
public ArrayList<String> getLevelname() {
|
public ArrayList<String> getLevelname() {
|
||||||
return levelname;
|
return levelname;
|
||||||
|
@ -83,6 +87,10 @@ public class Sqlite {
|
||||||
return pbarr;
|
return pbarr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> getLevelLength() {
|
||||||
|
return levelLength;
|
||||||
|
}
|
||||||
|
|
||||||
public Sqlite(String dbname) { // setzt variablen
|
public Sqlite(String dbname) { // setzt variablen
|
||||||
url = "jdbc:sqlite:C:\\ExtremeDemonList\\database\\sqlite\\";
|
url = "jdbc:sqlite:C:\\ExtremeDemonList\\database\\sqlite\\";
|
||||||
url += dbname + ".db";
|
url += dbname + ".db";
|
||||||
|
@ -121,7 +129,8 @@ public class Sqlite {
|
||||||
+ " attempts INTEGER NOT NULL,\n"
|
+ " attempts INTEGER NOT NULL,\n"
|
||||||
+ " completed BOOLEAN NOT NULL,\n"
|
+ " completed BOOLEAN NOT NULL,\n"
|
||||||
+ " locked BOOLEAN NOT NULL,\n" // Neue Spalte
|
+ " 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);
|
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) {
|
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) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
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);
|
System.out.println("tablename: " + levelname);
|
||||||
|
|
||||||
|
@ -158,6 +167,7 @@ public class Sqlite {
|
||||||
pstmt.setBoolean(12, completed);
|
pstmt.setBoolean(12, completed);
|
||||||
pstmt.setBoolean(13, locked);
|
pstmt.setBoolean(13, locked);
|
||||||
pstmt.setString(14, pb);
|
pstmt.setString(14, pb);
|
||||||
|
pstmt.setString(15, levelLength);
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -166,40 +176,50 @@ public class Sqlite {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void queryData(String tablename) {
|
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);
|
try (Connection conn = DriverManager.getConnection(url);
|
||||||
Statement stmt = conn.createStatement();
|
PreparedStatement pstmt = conn.prepareStatement(sql)) {
|
||||||
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"));
|
|
||||||
|
|
||||||
|
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) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sortData(String tablename) throws SQLException {
|
public void sortData(String tablename) throws SQLException {
|
||||||
FetchData data = new FetchData();
|
FetchData data = new FetchData();
|
||||||
|
|
||||||
|
status = LoadingStatus.getInstance(); // Holen der Singleton-Instanz
|
||||||
|
|
||||||
|
status.initialize();
|
||||||
|
|
||||||
|
|
||||||
ArrayList<String> levelnamelocal = new ArrayList<String>();
|
ArrayList<String> levelnamelocal = new ArrayList<String>();
|
||||||
ArrayList<String> levelIDlocal = new ArrayList<String>();
|
ArrayList<String> levelIDlocal = new ArrayList<String>();
|
||||||
ArrayList<String> authorlocal = new ArrayList<String>();
|
ArrayList<String> authorlocal = new ArrayList<String>();
|
||||||
|
@ -213,6 +233,7 @@ public class Sqlite {
|
||||||
ArrayList<Integer> attemptsLocal = new ArrayList<Integer>();
|
ArrayList<Integer> attemptsLocal = new ArrayList<Integer>();
|
||||||
ArrayList<Boolean> lockedLocal = new ArrayList<Boolean>();
|
ArrayList<Boolean> lockedLocal = new ArrayList<Boolean>();
|
||||||
ArrayList<String> pblocal = new ArrayList<String>();
|
ArrayList<String> pblocal = new ArrayList<String>();
|
||||||
|
ArrayList<String> levelLengthlocal = new ArrayList<String>();
|
||||||
|
|
||||||
try (Connection conn = DriverManager.getConnection(url);
|
try (Connection conn = DriverManager.getConnection(url);
|
||||||
Statement stmt = conn.createStatement()) {
|
Statement stmt = conn.createStatement()) {
|
||||||
|
@ -229,11 +250,17 @@ public class Sqlite {
|
||||||
maxPlacement = maxPlacementResult.getInt("maxPlacement");
|
maxPlacement = maxPlacementResult.getInt("maxPlacement");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
status.changeState("Datenbank wird sortiert...", maxPlacement);
|
||||||
|
|
||||||
// Durchlaufen Sie die Platzierungen und holen Sie die Daten entsprechend
|
// Durchlaufen Sie die Platzierungen und holen Sie die Daten entsprechend
|
||||||
for (int i = 1; i <= maxPlacement; i++) {
|
for (int i = 1; i <= maxPlacement; i++) {
|
||||||
String sql = "SELECT * FROM " + tablename + " WHERE placement = " + i;
|
String sql = "SELECT * FROM " + tablename + " WHERE placement = " + i;
|
||||||
ResultSet rs = stmt.executeQuery(sql);
|
ResultSet rs = stmt.executeQuery(sql);
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
index++;
|
||||||
|
status.update(rs.getString("levelname"), index);
|
||||||
levelnamelocal.add(rs.getString("levelname"));
|
levelnamelocal.add(rs.getString("levelname"));
|
||||||
levelIDlocal.add(rs.getInt("levelID") + "");
|
levelIDlocal.add(rs.getInt("levelID") + "");
|
||||||
authorlocal.add(rs.getString("author"));
|
authorlocal.add(rs.getString("author"));
|
||||||
|
@ -247,6 +274,7 @@ public class Sqlite {
|
||||||
attemptsLocal.add(rs.getInt("attempts"));
|
attemptsLocal.add(rs.getInt("attempts"));
|
||||||
lockedLocal.add(rs.getBoolean("locked"));
|
lockedLocal.add(rs.getBoolean("locked"));
|
||||||
pblocal.add(rs.getString("personalBest"));
|
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
|
// Erstelle eine neue Tabelle mit dem ursprünglichen Namen
|
||||||
createNewTable(tablename);
|
createNewTable(tablename);
|
||||||
|
|
||||||
|
status.changeState("Daten werden in neue Tabelle migriert...", levelnamelocal.size());
|
||||||
|
|
||||||
// Füge Daten in die neue Tabelle ein
|
// 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)) {
|
try (PreparedStatement pstmt = conn.prepareStatement(insert)) {
|
||||||
for (int i = 0; i < levelnamelocal.size(); i++) {
|
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
|
if (i < rawLevelNameslocal.size()) { // Überprüfen, ob der Index im Array rawLevelNameslocal gültig ist
|
||||||
String currentRawLevelName = rawLevelNameslocal.get(i);
|
String currentRawLevelName = rawLevelNameslocal.get(i);
|
||||||
if (data.allLevels().indexOf(currentRawLevelName) == -1) {
|
if (data.allLevels().indexOf(currentRawLevelName) == -1) {
|
||||||
|
@ -281,6 +312,7 @@ public class Sqlite {
|
||||||
pstmt.setBoolean(12, Boolean.parseBoolean(completedlocal.get(i)));
|
pstmt.setBoolean(12, Boolean.parseBoolean(completedlocal.get(i)));
|
||||||
pstmt.setBoolean(13, lockedLocal.get(i)); // Insert value of locked column
|
pstmt.setBoolean(13, lockedLocal.get(i)); // Insert value of locked column
|
||||||
pstmt.setString(14, pblocal.get(i));
|
pstmt.setString(14, pblocal.get(i));
|
||||||
|
pstmt.setString(15, levelLengthlocal.get(i));
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -295,6 +327,7 @@ public class Sqlite {
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
status.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeEntry(String tablename, String rawLevelName) throws SQLException {
|
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) {
|
public void modifyData(String levelname, boolean completedStatus, int attempts, boolean lock, String percent, String levelLength) {
|
||||||
String sql = "UPDATE levels SET completed = ?, attempts = ?, locked = ?, personalBest = ? WHERE levelname = ?";
|
String sql = "UPDATE levels SET completed = ?, attempts = ?, locked = ?, personalBest = ?, levelLength = ? WHERE levelname = ?";
|
||||||
|
|
||||||
try (Connection conn = DriverManager.getConnection(url);
|
try (Connection conn = DriverManager.getConnection(url);
|
||||||
PreparedStatement pstmt = conn.prepareStatement(sql)) {
|
PreparedStatement pstmt = conn.prepareStatement(sql)) {
|
||||||
pstmt.setBoolean(1, completedStatus);
|
pstmt.setBoolean(1, completedStatus);
|
||||||
pstmt.setInt(2, attempts);
|
pstmt.setInt(2, attempts);
|
||||||
pstmt.setBoolean(3, lock); // Korrigierte Reihenfolge
|
pstmt.setBoolean(3, lock); // Korrigierte Reihenfolge
|
||||||
pstmt.setString(4, percent);
|
pstmt.setString(4, percent);
|
||||||
pstmt.setString(5, levelname); // Korrigierte Reihenfolge
|
pstmt.setString(5, levelLength);
|
||||||
|
pstmt.setString(6, levelname); // Korrigierte Reihenfolge
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -336,23 +370,19 @@ public class Sqlite {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkColumns(String tablename) {
|
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)) {
|
try (Connection connection = DriverManager.getConnection(url)) {
|
||||||
DatabaseMetaData metaData = connection.getMetaData();
|
DatabaseMetaData metaData = connection.getMetaData();
|
||||||
ResultSet resultSet;
|
ResultSet resultSet;
|
||||||
|
|
||||||
int missing = 0;
|
int missing = 0;
|
||||||
|
|
||||||
// Schleife über die Spalten
|
|
||||||
for (String spalte : spalten) {
|
for (String spalte : spalten) {
|
||||||
// Abfrage der Spalteninformationen
|
|
||||||
resultSet = metaData.getColumns(null, null, tablename, spalte);
|
resultSet = metaData.getColumns(null, null, tablename, spalte);
|
||||||
|
|
||||||
if (!resultSet.next()) {
|
if (!resultSet.next()) {
|
||||||
System.out.println("Spalte " + spalte + " existiert nicht. Eine neue Spalte wird erstellt.");
|
System.out.println("Spalte " + spalte + " existiert nicht. Eine neue Spalte wird erstellt.");
|
||||||
// Eine neue Spalte erstellen
|
|
||||||
createNewColumn(tablename, spalte);
|
createNewColumn(tablename, spalte);
|
||||||
missing++;
|
missing++;
|
||||||
}
|
}
|
||||||
|
@ -368,7 +398,7 @@ public class Sqlite {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNewColumn(String tablename, String columnName) {
|
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);
|
try (Connection conn = DriverManager.getConnection(url);
|
||||||
Statement stmt = conn.createStatement()) {
|
Statement stmt = conn.createStatement()) {
|
||||||
stmt.executeUpdate(sql);
|
stmt.executeUpdate(sql);
|
||||||
|
@ -377,6 +407,7 @@ public class Sqlite {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void moveDataToNewDatabase(String tablename) {
|
public void moveDataToNewDatabase(String tablename) {
|
||||||
// Neuen Tabellennamen für die Kopie
|
// Neuen Tabellennamen für die Kopie
|
||||||
String newTableName = tablename + "_new";
|
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.Button;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
|
@ -18,10 +17,6 @@ import java.awt.event.KeyListener;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.io.IOException;
|
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.BorderFactory;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
@ -36,6 +31,7 @@ import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
|
|
||||||
|
import api.GetApiData;
|
||||||
import data.SortData;
|
import data.SortData;
|
||||||
import database.Sqlite;
|
import database.Sqlite;
|
||||||
|
|
||||||
|
@ -59,6 +55,7 @@ public class MainGUI {
|
||||||
public JLabel idshow = new JLabel("ID");
|
public JLabel idshow = new JLabel("ID");
|
||||||
public JLabel qualify = new JLabel("Qualifikation");
|
public JLabel qualify = new JLabel("Qualifikation");
|
||||||
public JLabel attemptslabel = new JLabel("Attempts");
|
public JLabel attemptslabel = new JLabel("Attempts");
|
||||||
|
public JLabel lengthLabel = new JLabel("Länge");
|
||||||
public JCheckBox filtercompleted = new JCheckBox("Nach geschafft filtern");
|
public JCheckBox filtercompleted = new JCheckBox("Nach geschafft filtern");
|
||||||
public Button copyid = new Button("Level ID kopieren");
|
public Button copyid = new Button("Level ID kopieren");
|
||||||
public Button showinfos = new Button("Mehr Infos anzeigen");
|
public Button showinfos = new Button("Mehr Infos anzeigen");
|
||||||
|
@ -83,6 +80,8 @@ public class MainGUI {
|
||||||
Sqlite data = new Sqlite("levels");
|
Sqlite data = new Sqlite("levels");
|
||||||
data.queryData("levels");
|
data.queryData("levels");
|
||||||
|
|
||||||
|
GetApiData api = new GetApiData();
|
||||||
|
|
||||||
//sort.sort();
|
//sort.sort();
|
||||||
|
|
||||||
gridLayout.setRows(data.getLevelname().size());
|
gridLayout.setRows(data.getLevelname().size());
|
||||||
|
@ -117,19 +116,21 @@ public class MainGUI {
|
||||||
|
|
||||||
idshow.setBounds(10, 110, 164, 30);
|
idshow.setBounds(10, 110, 164, 30);
|
||||||
|
|
||||||
copyid.setBounds(10, 190, 164, 30);
|
copyid.setBounds(10, 210, 164, 30);
|
||||||
|
|
||||||
qualify.setBounds(10, 130, 164, 30);
|
qualify.setBounds(10, 130, 164, 30);
|
||||||
|
|
||||||
attemptslabel.setBounds(10, 150, 164, 30);
|
attemptslabel.setBounds(10, 150, 164, 30);
|
||||||
|
|
||||||
|
lengthLabel.setBounds(10, 170, 164, 30);
|
||||||
|
|
||||||
settings.setBounds(1, 1, 60, 60);
|
settings.setBounds(1, 1, 60, 60);
|
||||||
settings.setFont(settings.getFont().deriveFont(30f));
|
settings.setFont(settings.getFont().deriveFont(30f));
|
||||||
settings.setBackground(Color.LIGHT_GRAY);
|
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);
|
startgame.setBounds(12, 560, 160, 30);
|
||||||
|
|
||||||
|
@ -143,7 +144,7 @@ public class MainGUI {
|
||||||
elements.infopanel().setVisible(false);
|
elements.infopanel().setVisible(false);
|
||||||
|
|
||||||
separator.setBounds(0, 30, 300, 30);
|
separator.setBounds(0, 30, 300, 30);
|
||||||
separator2.setBounds(0 ,160, 400, 30);
|
separator2.setBounds(0 ,180, 400, 30);
|
||||||
|
|
||||||
creator.setBounds(10, 50, 164, 30);
|
creator.setBounds(10, 50, 164, 30);
|
||||||
|
|
||||||
|
@ -280,7 +281,7 @@ public class MainGUI {
|
||||||
public void actionPerformed(ActionEvent e) {
|
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])) {
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -328,14 +329,32 @@ public class MainGUI {
|
||||||
attemptslabel.setText("Attempts: " + data.getAttempts().get(index));
|
attemptslabel.setText("Attempts: " + data.getAttempts().get(index));
|
||||||
level.setVerticalAlignment(SwingConstants.CENTER);
|
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() {
|
copyid.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
StringSelection stringSelection = new StringSelection(data.getLevelID().get(index));
|
StringSelection stringSelection = new StringSelection(data.getLevelID().get(index));
|
||||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
clipboard.setContents(stringSelection, null);
|
clipboard.setContents(stringSelection, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
|
@ -377,7 +396,6 @@ public class MainGUI {
|
||||||
if(show.getSelectedIndex() == 1) {
|
if(show.getSelectedIndex() == 1) {
|
||||||
if(!(Integer.parseInt(rank.getName()) >= 0 && Integer.parseInt(rank.getName()) <= 2)) {
|
if(!(Integer.parseInt(rank.getName()) >= 0 && Integer.parseInt(rank.getName()) <= 2)) {
|
||||||
levelpanel.remove(contents);
|
levelpanel.remove(contents);
|
||||||
|
|
||||||
levelpanel.repaint();
|
levelpanel.repaint();
|
||||||
levelpanel.revalidate();
|
levelpanel.revalidate();
|
||||||
}
|
}
|
||||||
|
@ -556,6 +574,7 @@ public class MainGUI {
|
||||||
elements.infopanel().add(showinfos);
|
elements.infopanel().add(showinfos);
|
||||||
elements.infopanel().add(attemptslabel);
|
elements.infopanel().add(attemptslabel);
|
||||||
elements.infopanel().add(showcalc);
|
elements.infopanel().add(showcalc);
|
||||||
|
elements.infopanel().add(lengthLabel);
|
||||||
// elements.infopanel().add(startgame);
|
// elements.infopanel().add(startgame);
|
||||||
|
|
||||||
main.add(search);
|
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");
|
Button delete = new Button("Datenbank löschen");
|
||||||
delete.setBounds(150, 206, 150, 30);
|
delete.setBounds(150, 206, 150, 30);
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,14 @@ package main;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.zip.DataFormatException;
|
import java.util.zip.DataFormatException;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
|
import api.GetApiData;
|
||||||
import data.FetchData;
|
import data.FetchData;
|
||||||
import data.ManageFiles;
|
import data.ManageFiles;
|
||||||
import database.DatabaseManager;
|
import database.DatabaseManager;
|
||||||
import database.Sqlite;
|
import database.Sqlite;
|
||||||
|
import errorhandler.ErrorHandler;
|
||||||
import filestructure.CreateFileStructure;
|
import filestructure.CreateFileStructure;
|
||||||
import gui.LoadMenu;
|
import gui.LoadMenu;
|
||||||
import preload.PreChecks;
|
import preload.PreChecks;
|
||||||
|
@ -16,6 +20,16 @@ public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException, DataFormatException {
|
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();
|
LoadMenu load = new LoadMenu();
|
||||||
load.onLoad();
|
load.onLoad();
|
||||||
|
|
||||||
|
@ -53,6 +67,10 @@ public class Main {
|
||||||
|
|
||||||
load.updateBar("Ladevorgang abgeschlossen");
|
load.updateBar("Ladevorgang abgeschlossen");
|
||||||
load.close();
|
load.close();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("fehler");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
requires org.json;
|
requires org.json;
|
||||||
requires org.apache.commons.io;
|
requires org.apache.commons.io;
|
||||||
requires java.datatransfer;
|
requires java.datatransfer;
|
||||||
requires com.formdev.flatlaf;
|
|
||||||
requires jdash.client;
|
requires jdash.client;
|
||||||
requires jdash.common;
|
requires jdash.common;
|
||||||
requires jlayer;
|
requires jlayer;
|
||||||
requires java.sql;
|
requires java.sql;
|
||||||
requires java.xml;
|
requires java.xml;
|
||||||
requires org.apache.commons.codec;
|
requires org.apache.commons.codec;
|
||||||
|
requires github.api;
|
||||||
|
requires java.mail;
|
||||||
}
|
}
|
|
@ -1,5 +1,11 @@
|
||||||
package preload;
|
package preload;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
public class AssetManager {
|
public class AssetManager {
|
||||||
|
|
||||||
|
public void checkAssets() {
|
||||||
|
File file = new File("");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,5 +24,4 @@ public class PreChecks {
|
||||||
migration.migrateData();
|
migration.migrateData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.apache.commons.codec.binary.Base64;
|
||||||
|
|
||||||
public class DecryptXOR {
|
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 final int XOR_KEY = 11;
|
||||||
|
|
||||||
private static byte[] xor(byte[] data, int key) {
|
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> attempts = new HashMap<String, String>();
|
||||||
public Map<String, String> newbestMap = new HashMap<>();
|
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() {
|
public void readAttempts() {
|
||||||
try {
|
try {
|
||||||
|
@ -46,6 +52,7 @@ public class ReadAttemptsFromXML {
|
||||||
NodeList dChildren = dElement.getChildNodes();
|
NodeList dChildren = dElement.getChildNodes();
|
||||||
String attemptsValue = null;
|
String attemptsValue = null;
|
||||||
String percentValue = null;
|
String percentValue = null;
|
||||||
|
String lengthValue = null;
|
||||||
|
|
||||||
for (int j = 0; j < dChildren.getLength(); j++) {
|
for (int j = 0; j < dChildren.getLength(); j++) {
|
||||||
if (dChildren.item(j).getNodeName().equals("k")) {
|
if (dChildren.item(j).getNodeName().equals("k")) {
|
||||||
|
@ -58,17 +65,21 @@ public class ReadAttemptsFromXML {
|
||||||
if (kChild.getTextContent().equals("k19")) {
|
if (kChild.getTextContent().equals("k19")) {
|
||||||
percentValue = dChildren.item(j + 1).getTextContent();
|
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
|
tempAttempts.put(currentLevelID, attemptsValue ); // + "," + percentValue
|
||||||
newbestMap.put(currentLevelID, percentValue);
|
newbestMap.put(currentLevelID, percentValue);
|
||||||
|
lengthMap.put(currentLevelID, lengthValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("lengthmap size: " + lengthMap.size());
|
||||||
// Füge die Daten aus der temporären Map in die attempts-Map ein
|
|
||||||
attempts.putAll(tempAttempts);
|
attempts.putAll(tempAttempts);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
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;
|
package readsafefile;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import data.FetchData;
|
import data.FetchData;
|
||||||
|
import data.ManageFiles;
|
||||||
import database.Sqlite;
|
import database.Sqlite;
|
||||||
import gui.AttemptsProgress;
|
import gui.AttemptsProgress;
|
||||||
|
|
||||||
public class SafeFileManager {
|
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 {
|
public void DecryptSafeFile() throws IOException {
|
||||||
DecryptXOR.decryptAndWriteFiles();
|
DecryptXOR.decryptAndWriteFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReadIndexAttempts() throws IOException {
|
public void ReadIndexAttempts() throws IOException {
|
||||||
|
|
||||||
AttemptsProgress prog = new AttemptsProgress();
|
|
||||||
prog.build();
|
|
||||||
|
|
||||||
Thread thread = new Thread(new Runnable() {
|
Thread thread = new Thread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Sqlite database = new Sqlite("levels");
|
|
||||||
|
read.readAttempts();
|
||||||
|
|
||||||
|
AttemptsProgress prog = new AttemptsProgress();
|
||||||
|
prog.build();
|
||||||
|
|
||||||
database.queryData("levels");
|
database.queryData("levels");
|
||||||
FetchData fetch = new FetchData();
|
FetchData fetch = new FetchData();
|
||||||
try {
|
try {
|
||||||
|
@ -30,29 +40,42 @@ public class SafeFileManager {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadAttemptsFromXML read = new ReadAttemptsFromXML();
|
System.out.println("size lengthMap: " + read.getLengthMap().size());
|
||||||
|
|
||||||
read.readAttempts();
|
lengthComp.putAll(read.lengthMap);
|
||||||
|
|
||||||
String attempts;
|
String attempts;
|
||||||
String percent;
|
String percent;
|
||||||
|
String length;
|
||||||
for(int i = 0; i < database.getLevelID().size(); i++) {
|
for(int i = 0; i < database.getLevelID().size(); i++) {
|
||||||
attempts = read.attempts.get(database.getLevelID().get(i));
|
attempts = read.attempts.get(database.getLevelID().get(i));
|
||||||
percent = read.newbestMap.get(database.getLevelID().get(i));
|
percent = read.newbestMap.get(database.getLevelID().get(i));
|
||||||
|
length = read.lengthMap.get(database.getLevelID().get(i));
|
||||||
|
|
||||||
if(attempts == null) {
|
if(attempts == null) {
|
||||||
attempts = 0 + "";
|
attempts = 0 + "";
|
||||||
}
|
}
|
||||||
if(percent == null) {
|
if(percent == null) {
|
||||||
percent = 0 + "";
|
percent = 0 + "";
|
||||||
}
|
}
|
||||||
|
if(length == null) {
|
||||||
|
length = 6 + "";
|
||||||
|
}
|
||||||
|
|
||||||
prog.update(database.getLevelname().get(i), Integer.parseInt(attempts), Integer.parseInt(percent), i);
|
prog.update(database.getLevelname().get(i), Integer.parseInt(attempts), Integer.parseInt(percent), i);
|
||||||
if(!database.getLocked().get(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();
|
prog.close();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
thread.start();
|
});
|
||||||
|
thread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue