Compare commits

..

No commits in common. "main" and "20240410210453" have entirely different histories.

23 changed files with 196 additions and 448 deletions

View file

@ -9,7 +9,7 @@ on:
jobs:
publish:
runs-on: docker
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

View file

@ -1,3 +1,5 @@
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
View file

@ -17,11 +17,21 @@
<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>
@ -45,27 +55,12 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
<version>1.15</version> <!-- oder die neueste Version -->
</dependency>
<dependency>
<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>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version> <!-- oder die neueste Version -->
</dependency>
</dependencies>
<build>

View file

@ -25,23 +25,5 @@ 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;
}
}

View file

@ -7,6 +7,7 @@ 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;
@ -83,18 +84,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) {

View file

@ -6,9 +6,10 @@ 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>();
@ -65,6 +66,9 @@ 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();
@ -81,15 +85,8 @@ public class GuiData {
localLevels.add(obj.getString("name"));
id.add(obj.getInt("id") + "");
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")));
}
verifier.add(obj.getString("verifier"));
creator.add(obj.getString("author"));
qualification.add(obj.getInt("percentToQualify") + "");
ytlink.add(obj.getString("verification") + "");
creators.add(obj.getJSONArray("creators") + "");

View file

@ -38,5 +38,6 @@ public class ManageFiles {
MainGUI gui = new MainGUI();
gui.build();
}
}
}
}

View file

@ -7,102 +7,95 @@ import java.util.ArrayList;
import data.FetchData;
import data.GuiData;
import gui.LoadingStatus;
import settingsfunctions.LoadSettings;
public class DatabaseManager {
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);
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));
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);
}
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);
}
}

View file

@ -11,14 +11,11 @@ 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>();
@ -33,7 +30,6 @@ 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;
@ -86,10 +82,6 @@ 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\\";
@ -129,8 +121,7 @@ public class Sqlite {
+ " attempts INTEGER NOT NULL,\n"
+ " completed BOOLEAN NOT NULL,\n"
+ " locked BOOLEAN NOT NULL,\n" // Neue Spalte
+ " personalBest STRING NOT NULL,\n"
+ " levelLength String NOT NULL\n"
+ " personalBest STRING\n"
+ ");";
try (Connection conn = DriverManager.getConnection(url);
@ -142,8 +133,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 levelLength) {
String sql = "INSERT INTO " + tablename + " (placement, levelname, levelnameRaw, levelID, author, creators, verifier, verificationLink, percentToQualify, records, attempts, completed, locked, personalBest, levelLength) 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 sql = "INSERT INTO " + tablename + " (placement, levelname, levelnameRaw, levelID, author, creators, verifier, verificationLink, percentToQualify, records, attempts, completed, locked, personalBest) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
System.out.println("tablename: " + levelname);
@ -167,7 +158,6 @@ public class Sqlite {
pstmt.setBoolean(12, completed);
pstmt.setBoolean(13, locked);
pstmt.setString(14, pb);
pstmt.setString(15, levelLength);
pstmt.executeUpdate();
} catch (SQLException e) {
@ -176,49 +166,39 @@ public class Sqlite {
}
public void queryData(String tablename) {
FetchData fetch = new FetchData();
String sql = "SELECT levelname, levelID, author, creators, verifier, verificationLink, " +
"percentToQualify, completed, records, levelNameRaw, attempts, locked, " +
"personalBest, levelLength FROM " + tablename + " WHERE levelNameRaw = ?";
String sql = "SELECT * FROM " + tablename;
try (Connection conn = DriverManager.getConnection(url);
PreparedStatement pstmt = conn.prepareStatement(sql)) {
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"));
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>();
@ -233,7 +213,6 @@ status = LoadingStatus.getInstance(); // Holen der Singleton-Instanz
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()) {
@ -250,17 +229,11 @@ status = LoadingStatus.getInstance(); // Holen der Singleton-Instanz
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"));
@ -274,7 +247,6 @@ status = LoadingStatus.getInstance(); // Holen der Singleton-Instanz
attemptsLocal.add(rs.getInt("attempts"));
lockedLocal.add(rs.getBoolean("locked"));
pblocal.add(rs.getString("personalBest"));
levelLengthlocal.add(rs.getString("levelLength"));
}
}
@ -284,13 +256,10 @@ status = LoadingStatus.getInstance(); // Holen der Singleton-Instanz
// 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, levelLength) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
String insert = "INSERT INTO " + tablename + " (placement, levelname, levelnameRaw, levelID, author, creators, verifier, verificationLink, percentToQualify, records, attempts, completed, locked, personalBest) 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) {
@ -312,7 +281,6 @@ status = LoadingStatus.getInstance(); // Holen der Singleton-Instanz
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 {
@ -327,7 +295,6 @@ status = LoadingStatus.getInstance(); // Holen der Singleton-Instanz
} catch (SQLException e) {
e.printStackTrace();
}
status.dispose();
}
public void removeEntry(String tablename, String rawLevelName) throws SQLException {
@ -344,17 +311,16 @@ status = LoadingStatus.getInstance(); // Holen der Singleton-Instanz
}
}
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 = ?";
public void modifyData(String levelname, boolean completedStatus, int attempts, boolean lock, String percent) {
String sql = "UPDATE levels SET completed = ?, attempts = ?, locked = ?, personalBest = ? 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, levelLength);
pstmt.setString(6, levelname); // Korrigierte Reihenfolge
pstmt.setBoolean(1, completedStatus);
pstmt.setInt(2, attempts);
pstmt.setBoolean(3, lock); // Korrigierte Reihenfolge
pstmt.setString(4, percent);
pstmt.setString(5, levelname); // Korrigierte Reihenfolge
@ -370,19 +336,23 @@ status = LoadingStatus.getInstance(); // Holen der Singleton-Instanz
}
public void checkColumns(String tablename) {
String[] spalten = {"placement", "levelname", "levelnameRaw", "levelID", "author", "creators", "verifier", "verificationLink", "percentToQualify", "records", "attempts", "completed", "locked", "personalBest", "levelLength"};
String[] spalten = {"placement", "levelname", "levelnameRaw", "levelID", "author", "creators", "verifier", "verificationLink", "percentToQualify", "records", "attempts", "completed", "locked", "personalBest"};
// 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++;
}
@ -398,7 +368,7 @@ status = LoadingStatus.getInstance(); // Holen der Singleton-Instanz
}
private void createNewColumn(String tablename, String columnName) {
String sql = "ALTER TABLE " + tablename + " ADD COLUMN " + columnName + " TEXT NOT NULL";
String sql = "ALTER TABLE " + tablename + " ADD COLUMN " + columnName + " TEXT";
try (Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement()) {
stmt.executeUpdate(sql);
@ -407,7 +377,6 @@ status = LoadingStatus.getInstance(); // Holen der Singleton-Instanz
}
}
public void moveDataToNewDatabase(String tablename) {
// Neuen Tabellennamen für die Kopie
String newTableName = tablename + "_new";

View file

@ -1,21 +0,0 @@
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);
}
}

View file

@ -1,18 +0,0 @@
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 {
}

View file

@ -0,0 +1,10 @@
package firstlaunch;
public class FirstlaunchMain {
public void main() {
}
}

View file

@ -1,79 +0,0 @@
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("");
}
}

View file

@ -3,6 +3,7 @@ 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;
@ -17,6 +18,10 @@ 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;
@ -31,7 +36,6 @@ import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import api.GetApiData;
import data.SortData;
import database.Sqlite;
@ -55,7 +59,6 @@ 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");
@ -80,8 +83,6 @@ public class MainGUI {
Sqlite data = new Sqlite("levels");
data.queryData("levels");
GetApiData api = new GetApiData();
//sort.sort();
gridLayout.setRows(data.getLevelname().size());
@ -116,21 +117,19 @@ public class MainGUI {
idshow.setBounds(10, 110, 164, 30);
copyid.setBounds(10, 210, 164, 30);
copyid.setBounds(10, 190, 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, 257, 160, 30);
showinfos.setBounds(12, 237, 160, 30);
showcalc.setBounds(12, 303, 160, 30);
showcalc.setBounds(12, 283, 160, 30);
startgame.setBounds(12, 560, 160, 30);
@ -144,7 +143,7 @@ public class MainGUI {
elements.infopanel().setVisible(false);
separator.setBounds(0, 30, 300, 30);
separator2.setBounds(0 ,180, 400, 30);
separator2.setBounds(0 ,160, 400, 30);
creator.setBounds(10, 50, 164, 30);
@ -281,7 +280,7 @@ public class MainGUI {
public void actionPerformed(ActionEvent e) {
if(!(comp[index] == Boolean.parseBoolean(data.getCompleted().get(index))) || !(attempts.getText().equals(data.getAttempts().get(index) + "")) || !(data.getLocked().get(index) == lockbool[index])) {
data.modifyData(data.getLevelname().get(index), comp[index], Integer.parseInt(attempts.getText()), lockbool[index], data.getPbarr().get(index), data.getLevelLength().get(index));
data.modifyData(data.getLevelname().get(index), comp[index], Integer.parseInt(attempts.getText()), lockbool[index], data.getPbarr().get(index));
}
@ -311,7 +310,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) {
@ -329,32 +328,14 @@ 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) {
@ -396,6 +377,7 @@ 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();
}
@ -574,7 +556,6 @@ 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);

View file

@ -87,8 +87,6 @@ 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);

View file

@ -3,14 +3,10 @@ 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;
@ -19,16 +15,6 @@ 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();
@ -67,10 +53,6 @@ public class Main {
load.updateBar("Ladevorgang abgeschlossen");
load.close();
} catch (Exception e) {
System.out.println("fehler");
}
}
}

View file

@ -3,12 +3,11 @@
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;
}

View file

@ -1,11 +1,5 @@
package preload;
import java.io.File;
public class AssetManager {
public void checkAssets() {
File file = new File("");
}
}

View file

@ -24,4 +24,5 @@ public class PreChecks {
migration.migrateData();
}
}
}

View file

@ -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) {

View file

@ -15,12 +15,6 @@ 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 {
@ -52,7 +46,6 @@ 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")) {
@ -61,25 +54,21 @@ 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 && lengthValue != null) {
if (attemptsValue != null && percentValue != null) {
tempAttempts.put(currentLevelID, attemptsValue ); // + "," + 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);
} catch (Exception e) {
e.printStackTrace();

View file

@ -1,5 +0,0 @@
package readsafefile;
public class Request {
}

View file

@ -1,37 +1,27 @@
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 {
@ -40,42 +30,29 @@ public class SafeFileManager {
e.printStackTrace();
}
System.out.println("size lengthMap: " + read.getLengthMap().size());
ReadAttemptsFromXML read = new ReadAttemptsFromXML();
lengthComp.putAll(read.lengthMap);
read.readAttempts();
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, 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)]);
database.modifyData(database.getLevelname().get(i), Boolean.parseBoolean(database.getCompleted().get(i)), Integer.parseInt(attempts), database.getLocked().get(i), percent);
}
}
prog.close();
}
});
thread.start();
}
});
thread.start();
}
}