From 034f09e3dbbff72a91d4df7f32a76043feaaf9df Mon Sep 17 00:00:00 2001 From: U61vashka Date: Mon, 5 Sep 2022 21:43:52 +0600 Subject: [PATCH] Fix java 8 compatibility --- .../com/ubivashka/plasmovoice/commands/MusicURLCommand.java | 2 +- .../plasmovoice/sound/holder/json/CachedSoundJsonHolder.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/ubivashka/plasmovoice/commands/MusicURLCommand.java b/src/main/java/com/ubivashka/plasmovoice/commands/MusicURLCommand.java index b21fe05..099f63f 100644 --- a/src/main/java/com/ubivashka/plasmovoice/commands/MusicURLCommand.java +++ b/src/main/java/com/ubivashka/plasmovoice/commands/MusicURLCommand.java @@ -63,7 +63,7 @@ public void executeUrlSubcommand(Player player, URL musicUrl, @Default("-1") @Fl InputStream urlStream = new BufferedInputStream(createProgressStream(connection.getInputStream(), connection.getContentLength(), player)); Optional optionalSoundFormat = getSoundFormat(musicUrl, urlStream); - if (optionalSoundFormat.isEmpty()) { + if (!optionalSoundFormat.isPresent()) { player.sendMessage(config.getMessages().getMessage("cannot-create-sound")); urlStream.close(); return; diff --git a/src/main/java/com/ubivashka/plasmovoice/sound/holder/json/CachedSoundJsonHolder.java b/src/main/java/com/ubivashka/plasmovoice/sound/holder/json/CachedSoundJsonHolder.java index 8cbde56..8c5488f 100644 --- a/src/main/java/com/ubivashka/plasmovoice/sound/holder/json/CachedSoundJsonHolder.java +++ b/src/main/java/com/ubivashka/plasmovoice/sound/holder/json/CachedSoundJsonHolder.java @@ -33,7 +33,7 @@ public InputStream createCachedInputStream(URL url, InputStream connectionStream plugin.getCachedSoundHolder().findFirstByPredicate(sound -> sound.getUrl().equals(url.toString())); Optional cachedSoundPath = cachedSound.map(sound -> Paths.get(sound.getCachedFile())); - if (cachedSound.isEmpty() || forceCache) { + if (!cachedSound.isPresent() || forceCache) { Path musicPath = cachedSoundPath.orElse(File.createTempFile("music", "", cacheDirectory).toPath()); Files.copy(connectionStream, musicPath, StandardCopyOption.REPLACE_EXISTING); connectionStream.close();