@@ -209,14 +209,21 @@ private void updateConfigFile(@NotNull CommentedConfig defaultConfig) {
209209 }
210210 }
211211
212+ @ Nullable
213+ private File getFile (@ NotNull String key ) {
214+ String path = config .get (key );
215+ return path == null ? null : new File (path );
216+ }
217+
212218 @ NotNull
213219 private String [] getStringArray (@ NotNull String key , char separator ) {
214220 String str = config .get (key );
215221 if ((str = str .trim ()).isEmpty ()) return new String [0 ];
216222 else return Utils .split (str , separator );
217223 }
218224
219- private @ NotNull AudioQuality preferredQuality () {
225+ @ NotNull
226+ private AudioQuality preferredQuality () {
220227 try {
221228 return config .getEnum ("player.preferredAudioQuality" , AudioQuality .class );
222229 } catch (IllegalArgumentException ex ) { // Retro-compatibility
@@ -236,13 +243,15 @@ private String[] getStringArray(@NotNull String key, char separator) {
236243 }
237244 }
238245
239- private @ Nullable File outputPipe () {
246+ @ Nullable
247+ private File outputPipe () {
240248 String path = config .get ("player.pipe" );
241249 if (path == null || path .isEmpty ()) return null ;
242250 return new File (path );
243251 }
244252
245- private @ Nullable File metadataPipe () {
253+ @ Nullable
254+ private File metadataPipe () {
246255 String path = config .get ("player.metadataPipe" );
247256 if (path == null || path .isEmpty ()) return null ;
248257 return new File (path );
@@ -261,42 +270,51 @@ private float normalisationPregain() {
261270 }
262271 }
263272
264- private @ Nullable String deviceId () {
273+ @ Nullable
274+ private String deviceId () {
265275 String val = config .get ("deviceId" );
266276 return val == null || val .isEmpty () ? null : val ;
267277 }
268278
269- private @ NotNull String deviceName () {
279+ @ NotNull
280+ private String deviceName () {
270281 return config .get ("deviceName" );
271282 }
272283
273- private @ NotNull Connect .DeviceType deviceType () {
284+ @ NotNull
285+ private Connect .DeviceType deviceType () {
274286 return config .getEnum ("deviceType" , Connect .DeviceType .class );
275287 }
276288
277- private @ NotNull String preferredLocale () {
289+ @ NotNull
290+ private String preferredLocale () {
278291 return config .get ("preferredLocale" );
279292 }
280293
281- private @ NotNull String authUsername () {
294+ @ NotNull
295+ private String authUsername () {
282296 return config .get ("auth.username" );
283297 }
284298
285- private @ NotNull String authPassword () {
299+ @ NotNull
300+ private String authPassword () {
286301 return config .get ("auth.password" );
287302 }
288303
289- private @ NotNull String authBlob () {
304+ @ NotNull
305+ private String authBlob () {
290306 return config .get ("auth.blob" );
291307 }
292308
293- private @ Nullable File credentialsFile () {
309+ @ Nullable
310+ private File credentialsFile () {
294311 String path = config .get ("auth.credentialsFile" );
295312 if (path == null || path .isEmpty ()) return null ;
296313 return new File (path );
297314 }
298315
299- public @ NotNull Level loggingLevel () {
316+ @ NotNull
317+ public Level loggingLevel () {
300318 return Level .toLevel (config .get ("logLevel" ));
301319 }
302320
@@ -309,11 +327,13 @@ public int apiPort() {
309327 return config .get ("api.port" );
310328 }
311329
312- public @ NotNull String apiHost () {
330+ @ NotNull
331+ public String apiHost () {
313332 return config .get ("api.host" );
314333 }
315334
316- public @ NotNull ShellEvents .Configuration toEventsShell () {
335+ @ NotNull
336+ public ShellEvents .Configuration toEventsShell () {
317337 return new ShellEvents .Configuration .Builder ()
318338 .setEnabled (config .get ("shell.enabled" ))
319339 .setOnContextChanged (config .get ("shell.onContextChanged" ))
@@ -379,7 +399,7 @@ public Session.Builder initSessionBuilder() throws IOException, GeneralSecurityE
379399 public Session .Configuration toSession () {
380400 return new Session .Configuration .Builder ()
381401 .setCacheEnabled (config .get ("cache.enabled" ))
382- .setCacheDir (new File (( String ) config . get ( "cache.dir" ) ))
402+ .setCacheDir (getFile ( "cache.dir" ))
383403 .setDoCacheCleanUp (config .get ("cache.doCleanUp" ))
384404 .setStoreCredentials (config .get ("auth.storeCredentials" ))
385405 .setStoredCredentialsFile (credentialsFile ())
0 commit comments