aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Kohls <mattkohls13@gmail.com>2018-07-19 21:01:40 -0400
committerMatt Kohls <mattkohls13@gmail.com>2018-07-19 21:01:40 -0400
commit7f0976b74dff706d223c96b40fb350f09bbc2c7f (patch)
tree624d3565c9f78d8b40c2c9eaa5cbad6fb386981b
parent8641c37bc02a1e4234e521aa7e276ab450c116ec (diff)
downloadSoundChan-7f0976b74dff706d223c96b40fb350f09bbc2c7f.tar.gz
SoundChan-7f0976b74dff706d223c96b40fb350f09bbc2c7f.tar.bz2
SoundChan-7f0976b74dff706d223c96b40fb350f09bbc2c7f.zip
Adding checks that usersound file exists
-rw-r--r--src/main/java/soundchan/BotListener/BotListener.java2
-rw-r--r--src/main/java/soundchan/LocalAudioManager.java22
2 files changed, 14 insertions, 10 deletions
diff --git a/src/main/java/soundchan/BotListener/BotListener.java b/src/main/java/soundchan/BotListener/BotListener.java
index 028f13b..9bcccfe 100644
--- a/src/main/java/soundchan/BotListener/BotListener.java
+++ b/src/main/java/soundchan/BotListener/BotListener.java
@@ -58,7 +58,7 @@ public class BotListener extends ListenerAdapter{
audioOnUserJoin = settingEnableCheck(properties.getProperty("audioOnUserJoin"));
if(audioOnUserJoin) {
String userAudioPath = properties.getProperty("userAudioFilePath");
- if(userAudioPath.contentEquals("") || userAudioPath == null) {
+ if(userAudioPath == null || userAudioPath.contentEquals("")) {
localManager = new LocalAudioManager(localFilePath, "usersound.properties");
}
else {
diff --git a/src/main/java/soundchan/LocalAudioManager.java b/src/main/java/soundchan/LocalAudioManager.java
index 80e3790..4b16850 100644
--- a/src/main/java/soundchan/LocalAudioManager.java
+++ b/src/main/java/soundchan/LocalAudioManager.java
@@ -122,19 +122,23 @@ public class LocalAudioManager {
private static Properties LoadProperties(String filename){
Properties properties = new Properties();
InputStream input = null;
- try{
- input = new FileInputStream(filename);
- properties.load(input);
-
- }catch (IOException ex){
- ex.printStackTrace();
- } finally {
+ File file = new File(filename);
+ if(file.exists() && !file.isDirectory()) {
try {
- input.close();
+ input = new FileInputStream(filename);
+ properties.load(input);
} catch (IOException ex) {
ex.printStackTrace();
+ } finally {
+ try {
+ input.close();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
}
+ return properties;
+ } else {
+ return properties;
}
- return properties;
}
}