|
@ -1,7 +1,9 @@ |
|
|
package de.yannicpunktdee.yoshibot.utils; |
|
|
package de.yannicpunktdee.yoshibot.utils; |
|
|
|
|
|
|
|
|
|
|
|
import de.yannicpunktdee.yoshibot.main.YoshiBot; |
|
|
import de.yannicpunktdee.yoshibot.utils.Logger.Type; |
|
|
import de.yannicpunktdee.yoshibot.utils.Logger.Type; |
|
|
import lombok.Getter; |
|
|
import lombok.Getter; |
|
|
|
|
|
import lombok.SneakyThrows; |
|
|
import org.json.JSONArray; |
|
|
import org.json.JSONArray; |
|
|
import org.json.JSONObject; |
|
|
import org.json.JSONObject; |
|
|
|
|
|
|
|
@ -11,35 +13,51 @@ import java.io.IOException; |
|
|
import java.nio.file.Files; |
|
|
import java.nio.file.Files; |
|
|
import java.nio.file.Paths; |
|
|
import java.nio.file.Paths; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.function.Function; |
|
|
import java.util.stream.StreamSupport; |
|
|
import java.util.stream.StreamSupport; |
|
|
|
|
|
|
|
|
public final class Resources { |
|
|
public final class Resources { |
|
|
|
|
|
|
|
|
@Getter private static String resourcePath; |
|
|
|
|
|
@Getter private static String configPath; |
|
|
|
|
|
@Getter private static String audioPath; |
|
|
|
|
|
@Getter private static String tempPath; |
|
|
|
|
|
@Getter private static String activitiesPath; |
|
|
|
|
|
@Getter private static String greetingsPath; |
|
|
|
|
|
@Getter private static String byebyesPath; |
|
|
|
|
|
@Getter private static String sauceConfigPath; |
|
|
|
|
|
@Getter private static String ttsPath; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Getter |
|
|
|
|
|
private static String resourcePath; |
|
|
|
|
|
@Getter |
|
|
|
|
|
private static String configPath; |
|
|
|
|
|
@Getter |
|
|
|
|
|
private static String audioPath; |
|
|
|
|
|
@Getter |
|
|
|
|
|
private static String tempPath; |
|
|
|
|
|
@Getter |
|
|
|
|
|
private static String activitiesPath; |
|
|
|
|
|
@Getter |
|
|
|
|
|
private static String greetingsPath; |
|
|
|
|
|
@Getter |
|
|
|
|
|
private static String byebyesPath; |
|
|
|
|
|
@Getter |
|
|
|
|
|
private static String sauceConfigPath; |
|
|
|
|
|
@Getter |
|
|
|
|
|
private static String ttsPath; |
|
|
|
|
|
|
|
|
private static Properties propertiesFile; |
|
|
private static Properties propertiesFile; |
|
|
|
|
|
|
|
|
@Getter private static String jda_builder_string; |
|
|
|
|
|
|
|
|
|
|
|
@Getter private static Long guild_id; |
|
|
|
|
|
|
|
|
|
|
|
@Getter private static boolean greetings_and_byebyes_on; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Getter |
|
|
|
|
|
private static String jda_builder_string; |
|
|
|
|
|
|
|
|
|
|
|
@Getter |
|
|
|
|
|
private static Long guild_id; |
|
|
|
|
|
|
|
|
|
|
|
@Getter |
|
|
|
|
|
private static boolean greetings_and_byebyes_on; |
|
|
private static List<String> greetings; |
|
|
private static List<String> greetings; |
|
|
private static List<String> byebyes; |
|
|
private static List<String> byebyes; |
|
|
|
|
|
|
|
|
@Getter private static String[] restrict_commands_to_channel; |
|
|
|
|
|
|
|
|
|
|
|
@Getter private static String[] filteredTags; |
|
|
|
|
|
@Getter private static final Map<String, List<String>> feedDetails = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Getter |
|
|
|
|
|
private static String[] restrict_commands_to_channel; |
|
|
|
|
|
|
|
|
|
|
|
@Getter |
|
|
|
|
|
private static String[] filteredTags; |
|
|
|
|
|
@Getter |
|
|
|
|
|
private static final Map<String, List<String>> feedDetails = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public synchronized static boolean init(String resourcePathArg) { |
|
|
public synchronized static boolean init(String resourcePathArg) { |
|
|
boolean isOk = initResources(resourcePathArg); |
|
|
boolean isOk = initResources(resourcePathArg); |
|
@ -60,139 +78,87 @@ public final class Resources { |
|
|
|
|
|
|
|
|
return isOk; |
|
|
return isOk; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static boolean initResources(String resourcePathArg){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean initResources(String resourcePathArg) { |
|
|
Logger.log("Versuche Resource-Verzeichnis zu finden.", Type.INFO); |
|
|
Logger.log("Versuche Resource-Verzeichnis zu finden.", Type.INFO); |
|
|
|
|
|
|
|
|
resourcePath = (new File((resourcePathArg == null)? "rsc" : resourcePathArg)).getAbsolutePath() |
|
|
|
|
|
.replace('\\', '/') + "/"; |
|
|
|
|
|
|
|
|
|
|
|
File resDir = new File(resourcePath); |
|
|
|
|
|
if(!resDir.exists() || !resDir.isDirectory()){ |
|
|
|
|
|
Logger.log("Das angegebene Resource-Verzeichnis \"" + resourcePath + |
|
|
|
|
|
"\" wurde nicht gefunden.", Type.WARNING); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.log("Resource-Verzeichnis \"" + resourcePath + "\" wurde gefunden.", Type.INFO); |
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resourcePath = (new File((resourcePathArg == null) ? "rsc" : resourcePathArg)).getAbsolutePath() |
|
|
|
|
|
.replace('\\', '/') + "/"; |
|
|
|
|
|
|
|
|
|
|
|
return verifyExists(resourcePath, File::isDirectory) != null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static boolean initConfig(){ |
|
|
|
|
|
Logger.log("Lade Config.properties.", Type.INFO); |
|
|
|
|
|
|
|
|
|
|
|
configPath = resourcePath + "Config.properties"; |
|
|
|
|
|
|
|
|
|
|
|
File configFile = new File(configPath); |
|
|
|
|
|
if(!configFile.exists() || !configFile.isFile()){ |
|
|
|
|
|
Logger.log("Die Datei Config.properties wurde nicht gefunden.", Type.ERROR); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SneakyThrows |
|
|
|
|
|
private static boolean initConfig() { |
|
|
|
|
|
configPath = verifyExists(resourcePath + "Config.properties", File::isFile); |
|
|
|
|
|
|
|
|
|
|
|
if (configPath == null) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
propertiesFile = new Properties(); |
|
|
propertiesFile = new Properties(); |
|
|
try { |
|
|
|
|
|
propertiesFile.load(new FileInputStream(configFile)); |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
Logger.log("Es ist ein Fehler beim Öffnen der Config.propeties aufgetreten.", Type.ERROR); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.log("Config.properties erfolgreich geladen.", Type.INFO); |
|
|
|
|
|
|
|
|
propertiesFile.load(new FileInputStream(configPath)); |
|
|
|
|
|
|
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static boolean initAudio(){ |
|
|
|
|
|
Logger.log("Versuche Audio-Verzeichnis zu finden.", Type.INFO); |
|
|
|
|
|
|
|
|
|
|
|
audioPath = resourcePath + "audio/"; |
|
|
|
|
|
|
|
|
|
|
|
File audioDir = new File(audioPath); |
|
|
|
|
|
if(!audioDir.exists() || !audioDir.isDirectory()){ |
|
|
|
|
|
Logger.log("Das Audio-Verzeichnis wurde nicht gefunden.", Type.ERROR); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.log("Audio-Verzeichnis wurde gefunden.", Type.INFO); |
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean initAudio() { |
|
|
|
|
|
audioPath = verifyExists(resourcePath + "audio/", File::isDirectory); |
|
|
|
|
|
return audioPath != null; |
|
|
} |
|
|
} |
|
|
public static String getPathToAudioFile(String name){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String getPathToAudioFile(String name) { |
|
|
return audioPath + name + ".opus"; |
|
|
return audioPath + name + ".opus"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static boolean initTemp(){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean initTemp() { |
|
|
Logger.log("Versuche Temp-Verzeichnis zu finden.", Type.INFO); |
|
|
Logger.log("Versuche Temp-Verzeichnis zu finden.", Type.INFO); |
|
|
|
|
|
|
|
|
tempPath = System.getProperty("java.io.tmpdir").replace('\\', '/') + "/yoshibot/"; |
|
|
|
|
|
|
|
|
|
|
|
File tempDir = new File(tempPath); |
|
|
|
|
|
if(!tempDir.exists() || !tempDir.isDirectory()){ |
|
|
|
|
|
Logger.log("Das Temp-Verzeichnis wurde nicht gefunden. Erstelle Verzeichnis.", Type.WARNING); |
|
|
|
|
|
if(!tempDir.mkdir()){ |
|
|
|
|
|
Logger.log("Temp-Verzeichnis konnte nicht erstellt werden.", Type.ERROR); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File tempDir = new File(System.getProperty("java.io.tmpdir").replace('\\', '/') + "/yoshibot/"); |
|
|
|
|
|
|
|
|
|
|
|
tempPath = verifyExists(tempDir.getAbsolutePath(), File::isDirectory); |
|
|
|
|
|
if (tempPath != null) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (tempDir.mkdir()) { |
|
|
|
|
|
return verifyExists(tempDir.getAbsolutePath(), File::isDirectory) != null; |
|
|
|
|
|
} else { |
|
|
|
|
|
Logger.log("Temp-Verzeichnis konnte nicht erstellt werden.", Type.ERROR); |
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Logger.log("Temp-Verzeichnis wurde gefunden.", Type.INFO); |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
} |
|
|
public static String getPathToTempAudioFile(String name){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String getPathToTempAudioFile(String name) { |
|
|
return tempPath + name + ".opus"; |
|
|
return tempPath + name + ".opus"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static boolean initActivities(){ |
|
|
|
|
|
Logger.log("Versuche Activities-Datei zu finden.", Type.INFO); |
|
|
|
|
|
|
|
|
|
|
|
activitiesPath = resourcePath + "activities.txt"; |
|
|
|
|
|
|
|
|
|
|
|
File activitiesFile = new File(activitiesPath); |
|
|
|
|
|
if(!activitiesFile.exists() || !activitiesFile.isFile()){ |
|
|
|
|
|
Logger.log("Die Activities-Datei wurde nicht gefunden.", Type.ERROR); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.log("Activities-Datei wurde gefunden.", Type.INFO); |
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean initActivities() { |
|
|
|
|
|
activitiesPath = verifyExists(resourcePath + "activities.txt", File::isFile); |
|
|
|
|
|
return activitiesPath != null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static boolean initSauceConfig(){ |
|
|
|
|
|
Logger.log("Versuche SauceConfig-Datei zu finden.", Type.INFO); |
|
|
|
|
|
|
|
|
|
|
|
sauceConfigPath = resourcePath + "sauceConfig.json"; |
|
|
|
|
|
|
|
|
|
|
|
File sauceConfigFile = new File(sauceConfigPath); |
|
|
|
|
|
if(!sauceConfigFile.exists() || !sauceConfigFile.isFile()){ |
|
|
|
|
|
Logger.log("Die SauceConfig-Datei wurde nicht gefunden.", Type.ERROR); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.log("SauceConfig-Datei wurde gefunden.", Type.INFO); |
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean initSauceConfig() { |
|
|
|
|
|
sauceConfigPath = verifyExists(resourcePath + "sauceConfig.json", File::isFile); |
|
|
|
|
|
return sauceConfigPath != null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static boolean initTTS(){ |
|
|
|
|
|
Logger.log("Versuche TTS-Datei zu finden.", Type.INFO); |
|
|
|
|
|
|
|
|
|
|
|
ttsPath = resourcePath + "tts.py"; |
|
|
|
|
|
|
|
|
|
|
|
File ttsFile = new File(ttsPath); |
|
|
|
|
|
if(!ttsFile.exists() || !ttsFile.isFile()){ |
|
|
|
|
|
Logger.log("Die TTS-Datei wurde nicht gefunden.", Type.ERROR); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.log("TTS-Datei wurde gefunden.", Type.INFO); |
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean initTTS() { |
|
|
|
|
|
ttsPath = verifyExists(resourcePath + "tts.py", File::isFile); |
|
|
|
|
|
return ttsPath != null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SneakyThrows |
|
|
private static boolean initJdaBuilderString() { |
|
|
private static boolean initJdaBuilderString() { |
|
|
List<String> strings = Files.readAllLines(new File(propertiesFilePath)) |
|
|
|
|
|
jda_builder_string = propertiesFile.getProperty("jda_builder_string"); |
|
|
|
|
|
|
|
|
if (verifyExists(resourcePath + "PrivateJdaBuilderString.txt", File::isFile) == null) { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
jda_builder_string = Files.readAllLines(new File(resourcePath + "PrivateJdaBuilderString.txt").toPath()).get(0); |
|
|
Logger.log("jda_builder_string erfolgreich geladen", Type.INFO); |
|
|
Logger.log("jda_builder_string erfolgreich geladen", Type.INFO); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static boolean initGuildId(){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean initGuildId() { |
|
|
if (!propertiesFile.containsKey("guild_id")) { |
|
|
if (!propertiesFile.containsKey("guild_id")) { |
|
|
Logger.log("Die Config.properties benötigt das Attribut guild_id.", Type.ERROR); |
|
|
Logger.log("Die Config.properties benötigt das Attribut guild_id.", Type.ERROR); |
|
|
return false; |
|
|
return false; |
|
@ -200,72 +166,52 @@ public final class Resources { |
|
|
String raw = propertiesFile.getProperty("guild_id"); |
|
|
String raw = propertiesFile.getProperty("guild_id"); |
|
|
try { |
|
|
try { |
|
|
guild_id = Long.parseLong(raw); |
|
|
guild_id = Long.parseLong(raw); |
|
|
} catch(NumberFormatException e){ |
|
|
|
|
|
|
|
|
} catch (NumberFormatException e) { |
|
|
Logger.log("Die angegebene guild_id ist keine Ganzzahl", Type.ERROR); |
|
|
Logger.log("Die angegebene guild_id ist keine Ganzzahl", Type.ERROR); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
Logger.log("guild_id erfolgreich geladen", Type.INFO); |
|
|
Logger.log("guild_id erfolgreich geladen", Type.INFO); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static boolean initGreetingsAndByebyes(){ |
|
|
|
|
|
Logger.log("Versuche Greetings-Datei zu finden.", Type.INFO); |
|
|
|
|
|
|
|
|
|
|
|
greetingsPath = resourcePath + "greetings.txt"; |
|
|
|
|
|
|
|
|
|
|
|
File greetingsFile = new File(greetingsPath); |
|
|
|
|
|
if(!greetingsFile.exists() || !greetingsFile.isFile()){ |
|
|
|
|
|
Logger.log("Die Greetings-Datei wurde nicht gefunden.", Type.ERROR); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.log("Greetings-Datei wurde gefunden.", Type.INFO); |
|
|
|
|
|
|
|
|
|
|
|
Logger.log("Versuche Byebyes-Datei zu finden.", Type.INFO); |
|
|
|
|
|
|
|
|
|
|
|
byebyesPath = resourcePath + "byebyes.txt"; |
|
|
|
|
|
|
|
|
|
|
|
File byebyesFile = new File(byebyesPath); |
|
|
|
|
|
if(!byebyesFile.exists() || !byebyesFile.isFile()){ |
|
|
|
|
|
Logger.log("Die Byebyes-Datei wurde nicht gefunden.", Type.ERROR); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SneakyThrows |
|
|
|
|
|
private static boolean initGreetingsAndByebyes() { |
|
|
|
|
|
greetingsPath = verifyExists(resourcePath + "greetings.txt", File::isFile); |
|
|
|
|
|
|
|
|
|
|
|
if (greetingsPath == null) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Logger.log("Byebyes-Datei wurde gefunden.", Type.INFO); |
|
|
|
|
|
|
|
|
|
|
|
if(propertiesFile.containsKey("greetings_and_byebyes_on")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
byebyesPath = verifyExists(resourcePath + "byebyes.txt", File::isFile); |
|
|
|
|
|
|
|
|
|
|
|
if (propertiesFile.containsKey("greetings_and_byebyes_on")) { |
|
|
greetings_and_byebyes_on = Boolean.parseBoolean(propertiesFile.getProperty("greetings_and_byebyes_on")); |
|
|
greetings_and_byebyes_on = Boolean.parseBoolean(propertiesFile.getProperty("greetings_and_byebyes_on")); |
|
|
} |
|
|
|
|
|
else greetings_and_byebyes_on = true; |
|
|
|
|
|
|
|
|
|
|
|
if(!greetings_and_byebyes_on) return true; |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
greetings = Files.readAllLines(Paths.get(greetingsPath)); |
|
|
|
|
|
byebyes = Files.readAllLines(Paths.get(byebyesPath)); |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
Logger.log("Es konnte nicht aus greetings.txt bzw byebyes.txt gelesen werden.", Type.ERROR); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.log("greetings_and_byebyes_on erfolgreich geladen", Type.INFO); |
|
|
|
|
|
|
|
|
if (!greetings_and_byebyes_on) return true; |
|
|
|
|
|
} else greetings_and_byebyes_on = true; |
|
|
|
|
|
|
|
|
|
|
|
greetings = Files.readAllLines(Paths.get(greetingsPath)); |
|
|
|
|
|
byebyes = Files.readAllLines(Paths.get(byebyesPath)); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
public static String getRandomGreeting(String name){ |
|
|
|
|
|
if(!greetings_and_byebyes_on) return null; |
|
|
|
|
|
return greetings.get((new Random()).nextInt(greetings.size())).replace("#", name); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String getRandomGreeting(String name) { |
|
|
|
|
|
return greetings_and_byebyes_on ? String.format(getRandomFrom(greetings), name) : null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static String getRandomByebye(String name) { |
|
|
|
|
|
return greetings_and_byebyes_on ? String.format(getRandomFrom(byebyes), name) : null; |
|
|
} |
|
|
} |
|
|
public static String getRandomByebye(String name){ |
|
|
|
|
|
if(!greetings_and_byebyes_on) return null; |
|
|
|
|
|
return byebyes.get(new Random().nextInt(byebyes.size())).replace("#", name); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static String getRandomFrom(List<String> pool) { |
|
|
|
|
|
return pool.get(YoshiBot.getInstance().getRandom().nextInt(pool.size())); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean initChannelRestrict() { |
|
|
private static boolean initChannelRestrict() { |
|
|
if (propertiesFile.containsKey("restrict_commands_to_channel")) |
|
|
if (propertiesFile.containsKey("restrict_commands_to_channel")) |
|
|
restrict_commands_to_channel = propertiesFile.getProperty("restrict_commands_to_channel").split("\\s+"); |
|
|
restrict_commands_to_channel = propertiesFile.getProperty("restrict_commands_to_channel").split("\\s+"); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean initTagFilter() { |
|
|
private static boolean initTagFilter() { |
|
|
try { |
|
|
try { |
|
|
JSONObject configBase = new JSONObject( |
|
|
JSONObject configBase = new JSONObject( |
|
@ -292,9 +238,20 @@ public final class Resources { |
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger.log("tags_general_filter erfolgreich geladen", Type.INFO); |
|
|
Logger.log("tags_general_filter erfolgreich geladen", Type.INFO); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static String verifyExists(String filename, Function<File, Boolean> checkIsValidFile) { |
|
|
|
|
|
String[] split = filename.split("/"); |
|
|
|
|
|
Logger.log(String.format("Versuche %s zu finden.", split[split.length - 1]), Type.INFO); |
|
|
|
|
|
if (checkIsValidFile.apply(new File(filename))) { |
|
|
|
|
|
return filename; |
|
|
|
|
|
} else { |
|
|
|
|
|
Logger.log(String.format("%s konnte nicht gefunden werden", filename), Type.ERROR); |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |