optimized some code

This commit is contained in:
potzplitz 2024-03-27 03:15:00 +01:00
parent 02d7f6f750
commit c22481fcf0
14 changed files with 111 additions and 115 deletions

View file

@ -1,4 +1,14 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.builder.annotationPath.allLocations=disabled
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
@ -6,10 +16,102 @@ org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.APILeak=warning
org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated=info
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=warning
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17

View file

@ -12,7 +12,6 @@ import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import database.DatabaseManager;
import gui.MainGUI;
import settingsfunctions.LoadSettings;
import settingsfunctions.MigrateData;

View file

@ -16,14 +16,12 @@ public class FetchData {
if(lock == 0) {
lock = 1;
String link = "https://raw.githubusercontent.com/All-Rated-Extreme-Demon-List/AREDL/main/data/_list.json";
URL url = new URL(link);
try (BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()))) {
String line;
StringBuilder sb = new StringBuilder();
while ((line = in.readLine()) != null) {

View file

@ -6,11 +6,9 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import org.apache.commons.io.FileUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import database.DatabaseManager;
import database.Sqlite;
public class GuiData {
@ -24,8 +22,6 @@ public class GuiData {
private ArrayList<String> victors = new ArrayList<String>();
private ArrayList<Integer> attempts = new ArrayList<Integer>();
public ArrayList<String> completed = new ArrayList<String>();
private FetchData data = new FetchData();
private int localLength;
@ -73,10 +69,6 @@ public class GuiData {
DatabaseManager mgr = new DatabaseManager();
mgr.queryData("levels");
Sqlite sql = new Sqlite("levels");
FetchData data = new FetchData();
File filelength = new File("C:\\ExtremeDemonList\\levels");
File[] filelengthindex = filelength.listFiles();
@ -90,7 +82,6 @@ public class GuiData {
jsonstring = jsonstring.trim().replace("\n", "").replace("\t", "").replace("\\", "");
JSONObject obj = new JSONObject(jsonstring);
JSONArray recordsArray = obj.getJSONArray("records");
localLevels.add(obj.getString("name"));
id.add(obj.getInt("id") + "");

View file

@ -1,6 +1,5 @@
package data;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@ -20,10 +19,6 @@ public class ManageFiles {
public static ArrayList<String> getMissinglevels() {
return missinglevels;
}
private void feedMissingLevelsArray(String levelname) { // fehlende level werden missinglevels hinzugefügt
missinglevels.add(levelname);
}
public void compareArrays(boolean system) throws IOException { // downloadedlevels und onlinelevels werden verglichen und die fehlenden level in missinglevels gepackt

View file

@ -2,15 +2,11 @@ package database;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.SQLException;
import java.util.ArrayList;
import data.FetchData;
import data.GuiData;
import gui.MainGUI;
import settingsfunctions.LoadSettings;
public class DatabaseManager {
@ -56,13 +52,6 @@ public class DatabaseManager {
try {
data.IndexData(levels);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
fetch.getGithubString();
} catch (IOException e) {
e.printStackTrace();

View file

@ -2,7 +2,6 @@ package database;
import java.io.File;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
@ -97,7 +96,6 @@ public class Sqlite {
url += dbname + ".db";
filename = dbname;
try (Connection conn = DriverManager.getConnection(url)) {
DatabaseMetaData meta = conn.getMetaData();
} catch(SQLException e) {
e.printStackTrace();
}

View file

@ -16,9 +16,7 @@ import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
@ -32,10 +30,7 @@ import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import data.FetchData;
import data.GuiData;
import database.Sqlite;
import settingsfunctions.LoadSettings;
public class MainGUI {
@ -68,14 +63,12 @@ public class MainGUI {
private String[] showing = {"Alle anzeigen", "Top 3", "Top 50", "Top 150", "Top 200"};
@SuppressWarnings({ "unchecked", "rawtypes" })
public JComboBox show = new JComboBox(showing);
private FetchData fetch = new FetchData();
private Elements elements = new Elements();
private int completedcount = 0;
public void build() throws IOException {
LoadSettings load = new LoadSettings();
Sqlite data = new Sqlite("levels");
data.queryData("levels");
@ -177,11 +170,7 @@ public class MainGUI {
JTextField attempts = new JTextField("0");
attempts.setBounds(535, 17, 70, 18);
attempts.setVisible(false);
if(data.getAttempts().get(i) != null) {
attempts.setText(data.getAttempts().get(i) + "");
}
JButton confirm = new JButton("\uD83D\uDDAB");
confirm.setBounds(640, 17, 17, 17);
confirm.setMargin(new Insets(0, 0, 0, 0));
@ -192,6 +181,12 @@ public class MainGUI {
if(data.getAttempts().get(i) != null) {
attempts.setText(data.getAttempts().get(i) + "");
}
completed.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@ -205,8 +200,7 @@ public class MainGUI {
uncompleted.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(ActionEvent e) {
uncompleted.setVisible(false);
completed.setVisible(true);
comp[index] = false;
@ -214,7 +208,6 @@ public class MainGUI {
});
anpassen.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
anpassen.setVisible(false);
@ -233,7 +226,6 @@ public class MainGUI {
});
confirm.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@ -250,8 +242,7 @@ public class MainGUI {
uncompleted.setVisible(false);
completed.setVisible(false);
attempts.setVisible(false);
}
}
});
if(Boolean.parseBoolean(data.getCompleted().get(index))) {
@ -282,57 +273,13 @@ public class MainGUI {
attemptslabel.setText("Attempts: " + data.getAttempts().get(index));
level.setVerticalAlignment(SwingConstants.CENTER);
FetchData fetchData = new FetchData();
/*
try {
//TODO: recordspanel.setLayout(new GridLayout(GuiData.allVictors(fetchData.allLevels().get(index)).size(), 1));
} catch (IOException e1) {
e1.printStackTrace();
}
recordspanel.setBackground(Color.GRAY);
records.setBounds(0, 302, 185, 300);
recordspanel.removeAll();
try {
TODO: ArrayList<String> victors = GuiData.allVictors(fetchData.allLevels().get(index));
victorcount.setText("Anzahl Victors: " + victors.size());
recordspanel.setLayout(new GridLayout(victors.size(), 1));
for(String victor : victors) {
JPanel contents = new JPanel();
contents.setPreferredSize(new Dimension(165, 50));
contents.setLayout(null);
contents.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
JLabel name = new JLabel(victor);
name.setBounds(10, 10, 100, 30);
contents.add(name);
recordspanel.add(contents);
}
} catch (IOException e1) {
e1.printStackTrace();
}
recordspanel.revalidate();
*/
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);
}
});
}
@Override

View file

@ -1,16 +1,7 @@
package gui;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import javax.swing.JFrame;
import settingsfunctions.DeleteDatabase;
import settingsfunctions.MigrateData;
import settingsfunctions.WriteSettings;
public class SettingsGui {
public void showSettings() {

View file

@ -2,9 +2,6 @@ package main;
import java.io.IOException;
import javax.swing.UnsupportedLookAndFeelException;
import api.GetApiData;
import data.FetchData;
import data.ManageFiles;
import database.DatabaseManager;

View file

@ -2,7 +2,6 @@ package media;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@ -49,10 +48,8 @@ public class PlaySong {
playerThread.start();
Thread.sleep(10000);
player.close();
fis.close();
} catch (IOException | JavaLayerException | InterruptedException e) {

View file

@ -1,9 +1,3 @@
/**
*
*/
/**
*
*/
module ExtremeDemonList {
requires java.desktop;
requires org.json;

View file

@ -5,7 +5,6 @@ import java.io.File;
import javax.swing.JOptionPane;
import data.FetchData;
import data.ManageFiles;
import settingsfunctions.MigrateData;
public class PreChecks {

View file

@ -1,6 +1,5 @@
package settingsfunctions;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;