diff options
| -rw-r--r-- | bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/SoundUtils.java | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/SoundUtils.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/SoundUtils.java index 1d8bdc71..17c566ec 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/SoundUtils.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/util/SoundUtils.java @@ -68,17 +68,21 @@ public class SoundUtils { return; } - Sound sound; - try { - // TODO make per version sound getter - sound = soundCache.computeIfAbsent(parts[0], name -> { - try { - return (Sound) soundValueOfMethod.invoke(null, parts[0]); - } catch (IllegalAccessException | InvocationTargetException e) { + Sound sound = soundCache.computeIfAbsent(parts[0], name -> { + try { + return (Sound) soundValueOfMethod.invoke(null, parts[0]); + } catch (IllegalAccessException | InvocationTargetException e) { + final Throwable cause = e.getCause(); + + if (cause instanceof IllegalArgumentException) { + return null; + } else { throw new IllegalStateException("Sound#valueOf invocation failed", e); } - }); - } catch (IllegalArgumentException ignored) { + } + }); + + if (sound == null) { return; } |
