diff options
author | Brandon <bwaggone@umich.edu> | 2018-08-18 17:58:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-18 17:58:52 -0400 |
commit | f78dc260bc113e458020cfacaacd26fb4c2a4a27 (patch) | |
tree | d73e25c9df88086ea0051e977282c9dd9b0b9d3c /src/main/java/soundchan/LocalAudioManager.java | |
parent | d72a49fbb2186f5749baa903408843797fab0971 (diff) | |
parent | e18d70d70c29a4b054bad8563ef91172ec9a6e78 (diff) | |
download | SoundChan-f78dc260bc113e458020cfacaacd26fb4c2a4a27.tar.gz SoundChan-f78dc260bc113e458020cfacaacd26fb4c2a4a27.tar.bz2 SoundChan-f78dc260bc113e458020cfacaacd26fb4c2a4a27.zip |
Merge pull request #9 from bwaggone/feature/add-audio-on-join
bugfixing add audio on join
Diffstat (limited to 'src/main/java/soundchan/LocalAudioManager.java')
-rw-r--r-- | src/main/java/soundchan/LocalAudioManager.java | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/src/main/java/soundchan/LocalAudioManager.java b/src/main/java/soundchan/LocalAudioManager.java index e645fe7..4b16850 100644 --- a/src/main/java/soundchan/LocalAudioManager.java +++ b/src/main/java/soundchan/LocalAudioManager.java @@ -72,6 +72,21 @@ public class LocalAudioManager { channel.sendMessage(toPrint).queue(); } + /** + * Lists users with sounds that will play when they join the voice channel + * @param channel Text channel messaged on + */ + public void ListUserAudio(MessageChannel channel) { + Set<String> userSounds = usernameDict.keySet(); + String toPrint = "The following users have sounds that will play when they join the voice channel:\n```"; + for (String user : userSounds) { + String sound = usernameDict.get(user); + toPrint = toPrint + " * " + user + "\t" + sound.substring(0, sound.indexOf('.')) + "\n"; + } + toPrint = toPrint + "```"; + channel.sendMessage(toPrint).queue(); + } + private void PopulateFiles(){ File folder = new File(filepath); File[] listOfFiles = folder.listFiles(); @@ -107,21 +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; } - - } |