privatestaticfinalString[] AUDIO_EXTENSIONS = { ".ogg", ".wav", ".mp3" }; //There are more valid types, but not really worth checking them all here
privatevoidloadAudio(Class<?> cls) {
try {
Field[] fields = cls.getDeclaredFields();
outer:
for (Fieldf : fields) {
intmodifiers = f.getModifiers();
if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers) && f.getType().equals(String.class)) {
Strings = (String) f.get(null);
if (s == null) { //If no defined value, determine path using field name
s = audioPath(f.getName());
for (Stringext : AUDIO_EXTENSIONS) {
StringtestPath = s + ext;
if (Gdx.files.internal(testPath).exists()) {
s = testPath;
BaseMod.addAudio(s, s);
f.set(null, s);
continueouter;
}
}
thrownewException("Failed to find an audio file \"" + f.getName() + "\" in " + resourcesFolder + "/audio; check to ensure the capitalization and filename are correct.");
}
else { //Otherwise, load defined path
if (Gdx.files.internal(s).exists()) {
BaseMod.addAudio(s, s);
}
else {
thrownewException("Failed to find audio file \"" + s + "\"; check to ensure this is the correct filepath.");
}
}
}
}
}
catch (Exceptione) {
logger.error("Exception occurred in loadAudio: ", e);
}
}
//These methods are used to generate the correct filepaths to various parts of the resources folder.