From 266c900d573cc4b70683e290404af663eb3f66d0 Mon Sep 17 00:00:00 2001 From: Matt Kohls Date: Tue, 16 Oct 2018 17:58:38 -0400 Subject: Adding property setting for watching local sounds --- soundchan.properties.example | 16 +++++++++++----- src/main/java/soundchan/BotListener/BotListener.java | 14 +++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/soundchan.properties.example b/soundchan.properties.example index 0655076..8780021 100644 --- a/soundchan.properties.example +++ b/soundchan.properties.example @@ -1,19 +1,25 @@ +// Example properties file for SoundChan +// +// Flag conditions are enabled with any of the following values: +// true, on, enable, yes, 1 +// any other string (or empty) will leave the condition disabled + + //The Bot Token you will have received from the discord developers page botToken=BOT_TOKEN_FROM_DISCORD //The local file path to the directory of your sounds. Don't forget to escape your slashes localFilePath=C:\\PATH\\TO\\SOUNDS\\DIRECTORY +//Flag for watching the sound directory for changes +watchLocalFilePath=FLAG_CONDITION + //The user for the followingUser=USERNAME -//Flag conditions are enabled with any of the following values: -// true, on, enable, yes, 1 -//any other string (or empty) will leave the condition disabled - //If you want SoundChan to play an audio file whit their name when a user joins the channel or have that information come from below file //This is a flag condition -audioOnUserJoin=on/off +audioOnUserJoin=FLAG_CONDITION //The file where users and sound clips are related, see usersound.properties.example for more info //If this is not set, it will default to usersounds.properties diff --git a/src/main/java/soundchan/BotListener/BotListener.java b/src/main/java/soundchan/BotListener/BotListener.java index 9177385..0dad6c0 100644 --- a/src/main/java/soundchan/BotListener/BotListener.java +++ b/src/main/java/soundchan/BotListener/BotListener.java @@ -36,7 +36,6 @@ public class BotListener extends ListenerAdapter{ private final AudioPlayerManager playerManager; private final Map musicManagers; private BotListenerHelpers helper = new BotListenerHelpers(); - private ExecutorService executorService; private Future future; // From configuration file @@ -51,8 +50,6 @@ public class BotListener extends ListenerAdapter{ AudioSourceManagers.registerRemoteSources(playerManager); AudioSourceManagers.registerLocalSource(playerManager); - executorService = Executors.newSingleThreadExecutor(); - loadProperties(properties); } @@ -75,10 +72,13 @@ public class BotListener extends ListenerAdapter{ } else localManager = new LocalAudioManager(localFilePath); - - DirectoryWatcher directoryWatcher = new DirectoryWatcher(localManager, localFilePath); - future = executorService.submit(directoryWatcher); - executorService.shutdown(); + + if(settingEnableCheck(properties.getProperty("watchLocalFilePath"))) { + ExecutorService executorService = Executors.newSingleThreadExecutor(); + DirectoryWatcher directoryWatcher = new DirectoryWatcher(localManager, localFilePath); + future = executorService.submit(directoryWatcher); + executorService.shutdown(); + } } -- cgit v1.2.3