diff --git a/src/main/java/me/william278/huskhomes2/config/Settings.java b/src/main/java/me/william278/huskhomes2/config/Settings.java index 500352eb..992038d1 100644 --- a/src/main/java/me/william278/huskhomes2/config/Settings.java +++ b/src/main/java/me/william278/huskhomes2/config/Settings.java @@ -228,13 +228,23 @@ public class Settings { // Retrieve sounds used in plugin; if invalid, use defaults. try { this.teleportationCompleteSound = Sound.valueOf(config.getString("general.sounds.teleportation_complete", "ENTITY_ENDERMAN_TELEPORT")); + } catch (IllegalArgumentException exception) { + Bukkit.getLogger().severe("Invalid sound specified for teleportation_complete, using no sound instead"); + this.teleportationCompleteSound = null; + } + + try { this.teleportWarmupSound = Sound.valueOf(config.getString("general.sounds.teleportation_warmup", "BLOCK_NOTE_BLOCK_BANJO")); + } catch (IllegalArgumentException exception) { + Bukkit.getLogger().severe("Invalid sound specified for teleportation_warmup, using no sound instead"); + this.teleportWarmupSound = null; + } + + try { this.teleportCancelledSound = Sound.valueOf(config.getString("general.sounds.teleportation_cancelled", "ENTITY_ITEM_BREAK")); } catch (IllegalArgumentException exception) { - Bukkit.getLogger().severe("Invalid sound specified in config.yml; using default sounds instead."); - this.teleportationCompleteSound = Sound.ENTITY_ENDERMAN_TELEPORT; - this.teleportWarmupSound = Sound.BLOCK_NOTE_BLOCK_BANJO; - this.teleportCancelledSound = Sound.ENTITY_ITEM_BREAK; + Bukkit.getLogger().severe("Invalid sound specified for teleportation_cancelled, using no sound instead"); + this.teleportCancelledSound = null; } this.allowUnicodeInDescriptions = config.getBoolean("allow_unicode_descriptions", true); diff --git a/src/main/java/me/william278/huskhomes2/teleport/TeleportManager.java b/src/main/java/me/william278/huskhomes2/teleport/TeleportManager.java index a9f2a7d0..a43ed6bd 100644 --- a/src/main/java/me/william278/huskhomes2/teleport/TeleportManager.java +++ b/src/main/java/me/william278/huskhomes2/teleport/TeleportManager.java @@ -105,7 +105,9 @@ public class TeleportManager { player.eject(); // Eject passengers before teleporting } PaperLib.teleportAsync(player, targetLocation).thenRun(() -> { - player.playSound(targetLocation, HuskHomes.getSettings().getTeleportationCompleteSound(), 1, 1); + if (HuskHomes.getSettings().getTeleportationCompleteSound() != null) { + player.playSound(targetLocation, HuskHomes.getSettings().getTeleportationCompleteSound(), 1, 1); + } MessageManager.sendMessage(player, "teleporting_complete"); }); }); diff --git a/src/main/java/me/william278/huskhomes2/teleport/TimedTeleport.java b/src/main/java/me/william278/huskhomes2/teleport/TimedTeleport.java index d1d63a4c..a3102998 100644 --- a/src/main/java/me/william278/huskhomes2/teleport/TimedTeleport.java +++ b/src/main/java/me/william278/huskhomes2/teleport/TimedTeleport.java @@ -76,14 +76,18 @@ public class TimedTeleport { } if (hasMoved(executablePlayer)) { cancel(); - executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportCancelledSound(), 1, 1); + if (HuskHomes.getSettings().getTeleportCancelledSound() != null) { + executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportCancelledSound(), 1, 1); + } MessageManager.sendMessage(player, "teleporting_cancelled_movement"); sendWarmupMessage(player, "teleporting_action_bar_cancelled"); return; } if (hasLostHealth(executablePlayer)) { cancel(); - executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportCancelledSound(), 1, 1); + if (HuskHomes.getSettings().getTeleportCancelledSound() != null) { + executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportCancelledSound(), 1, 1); + } MessageManager.sendMessage(player, "teleporting_cancelled_damage"); sendWarmupMessage(player, "teleporting_action_bar_cancelled"); return; @@ -138,7 +142,9 @@ public class TimedTeleport { return; } sendWarmupMessage(executablePlayer, "teleporting_action_bar_countdown", Integer.toString(i[0])); - executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportWarmupSound(), 1, 1); + if (HuskHomes.getSettings().getTeleportWarmupSound() != null) { + executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportWarmupSound(), 1, 1); + } } }.runTaskTimer(plugin, 0, 20L); }