From d2299bfe0371d4a262dfaf9ec3c743cf2da7492b Mon Sep 17 00:00:00 2001 From: Zrips Date: Wed, 2 Mar 2016 16:14:44 +0200 Subject: [PATCH] Sound fix --- com/gamingmesh/jobs/PlayerManager.java | 29 +++++++++++++++---- .../jobs/listeners/JobsPaymentListener.java | 2 +- plugin.yml | 2 +- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/com/gamingmesh/jobs/PlayerManager.java b/com/gamingmesh/jobs/PlayerManager.java index 7772c597..18454073 100644 --- a/com/gamingmesh/jobs/PlayerManager.java +++ b/com/gamingmesh/jobs/PlayerManager.java @@ -328,6 +328,14 @@ public class PlayerManager { // } } + private Sound getSound(String soundName) { + for (Sound one : Sound.values()) { + if (one.name().equalsIgnoreCase(soundName)) + return one; + } + return null; + } + /** * Broadcasts level up about a player * @param jPlayer @@ -352,8 +360,13 @@ public class PlayerManager { if (levelUpEvent.isCancelled()) return; - if (ConfigManager.getJobsConfiguration().SoundLevelupUse) - player.getWorld().playSound(player.getLocation(), Sound.valueOf(levelUpEvent.getSoundName()), levelUpEvent.getSoundVolume(), levelUpEvent.getSoundPitch()); + if (ConfigManager.getJobsConfiguration().SoundLevelupUse) { + Sound sound = getSound(levelUpEvent.getSoundName()); + if (sound != null) + player.getWorld().playSound(player.getLocation(), sound, levelUpEvent.getSoundVolume(), levelUpEvent.getSoundPitch()); + else + Bukkit.getConsoleSender().sendMessage("[Jobs] Cant find sound by name: " + levelUpEvent.getTitleChangeSoundName() + ". Please update it"); + } String message; if (ConfigManager.getJobsConfiguration().isBroadcastingLevelups()) { @@ -388,10 +401,14 @@ public class PlayerManager { if (levelUpEvent.getNewTitle() != null && !levelUpEvent.getNewTitle().equals(levelUpEvent.getOldTitle())) { - if (ConfigManager.getJobsConfiguration().SoundTitleChangeUse) - player.getWorld().playSound(player.getLocation(), Sound.valueOf(levelUpEvent.getTitleChangeSoundName()), levelUpEvent.getTitleChangeVolume(), levelUpEvent - .getTitleChangePitch()); - + if (ConfigManager.getJobsConfiguration().SoundTitleChangeUse) { + Sound sound = getSound(levelUpEvent.getTitleChangeSoundName()); + if (sound != null) + player.getWorld().playSound(player.getLocation(), sound, levelUpEvent.getTitleChangeVolume(), + levelUpEvent.getTitleChangePitch()); + else + Bukkit.getConsoleSender().sendMessage("[Jobs] Cant find sound by name: " + levelUpEvent.getTitleChangeSoundName() + ". Please update it"); + } // user would skill up if (ConfigManager.getJobsConfiguration().isBroadcastingSkillups()) { message = Language.getMessage("message.skillup.broadcast"); diff --git a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index cb7ea096..70f7818e 100644 --- a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -326,7 +326,7 @@ public class JobsPaymentListener implements Listener { multiplier = multiplier * ConfigManager.getJobsConfiguration().gigaDrillMultiplier; else if (AbilityAPI.superBreakerEnabled(player)) multiplier = multiplier * ConfigManager.getJobsConfiguration().superBreakerMultiplier; - } catch (IndexOutOfBoundsException e) { + } catch (Exception e) { } // Item in hand diff --git a/plugin.yml b/plugin.yml index 3b9b8369..006386e5 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: Jobs description: Jobs Plugin for the BukkitAPI main: com.gamingmesh.jobs.JobsPlugin -version: 2.63.0 +version: 2.63.1 author: phrstbrn softdepend: [Vault, CoreProtect, MythicMobs, McMMO] commands: