From 88b99a3835bea0d1a6b9fe43ef6aa721a71f6cea Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Tue, 1 Mar 2016 13:08:11 -0500 Subject: [PATCH] I *think* this should be backwards compatible, I may be wrong and it could break both. --- .../gmail/nossr50/datatypes/party/Party.java | 3 +- .../nossr50/datatypes/player/McMMOPlayer.java | 3 +- .../nossr50/listeners/BlockListener.java | 10 +- .../nossr50/listeners/PlayerListener.java | 5 +- .../com/gmail/nossr50/party/PartyManager.java | 3 +- .../nossr50/runnables/skills/AprilTask.java | 3 +- .../runnables/skills/KrakenAttackTask.java | 5 +- .../skills/fishing/FishingManager.java | 5 +- .../nossr50/skills/repair/RepairManager.java | 5 +- .../skills/salvage/SalvageManager.java | 7 +- .../skills/smelting/SmeltingManager.java | 3 +- .../nossr50/skills/taming/TamingManager.java | 3 +- .../skills/taming/TrackedTamingEntity.java | 3 +- .../com/gmail/nossr50/util/ChimaeraWing.java | 3 +- .../gmail/nossr50/util/HolidayManager.java | 4 +- .../nossr50/util/adapter/SoundAdapter.java | 91 +++++++++++++++++++ 16 files changed, 129 insertions(+), 27 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/util/adapter/SoundAdapter.java diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java index 97c82eeed..f40842473 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java @@ -20,6 +20,7 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.adapter.SoundAdapter; public class Party { private final LinkedHashMap members = new LinkedHashMap(); @@ -227,7 +228,7 @@ public class Party { leader.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, getLevel())); if (Config.getInstance().getLevelUpSoundsEnabled()) { - leader.playSound(leader.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH); + leader.playSound(leader.getLocation(), SoundAdapter.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH); } } return; diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 37d900ae1..6897c0291 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -53,6 +53,7 @@ import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.adapter.SoundAdapter; import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.SkillUtils; @@ -504,7 +505,7 @@ public class McMMOPlayer { } if (Config.getInstance().getLevelUpSoundsEnabled()) { - player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH); + player.playSound(player.getLocation(), SoundAdapter.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH); } player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(skillType.toString()) + ".Skillup", levelsGained, getSkillLevel(skillType))); diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index eb6c8d9ee..fdc1a182a 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -5,7 +5,6 @@ import java.util.List; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; @@ -33,8 +32,6 @@ import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; import com.gmail.nossr50.events.fake.FakeBlockDamageEvent; -import com.gmail.nossr50.runnables.PistonTrackerTask; -import com.gmail.nossr50.runnables.StickyPistonTrackerTask; import com.gmail.nossr50.skills.alchemy.Alchemy; import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.skills.herbalism.Herbalism; @@ -49,6 +46,7 @@ import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.adapter.SoundAdapter; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.SkillUtils; import org.bukkit.metadata.FixedMetadataValue; @@ -382,7 +380,7 @@ public class BlockListener implements Listener { * We don't need to check permissions here because they've already been checked for the ability to even activate. */ if (mcMMOPlayer.getAbilityMode(AbilityType.TREE_FELLER) && BlockUtils.isLog(blockState) && Config.getInstance().getTreeFellerSoundsEnabled()) { - player.playSound(blockState.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, Misc.FIZZ_VOLUME, Misc.getFizzPitch()); + player.playSound(blockState.getLocation(), SoundAdapter.FIZZ, Misc.FIZZ_VOLUME, Misc.getFizzPitch()); } } @@ -421,7 +419,7 @@ public class BlockListener implements Listener { else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && heldItem.getType() == Material.AIR) { if (AbilityType.BERSERK.blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true)) { event.setInstaBreak(true); - player.playSound(block.getLocation(), Sound.ENTITY_ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch()); + player.playSound(block.getLocation(), SoundAdapter.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch()); } else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState) && EventUtils.simulateBlockBreak(block, player, true)) { if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) { @@ -431,7 +429,7 @@ public class BlockListener implements Listener { } else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isLeaves(blockState) && EventUtils.simulateBlockBreak(block, player, true)) { event.setInstaBreak(true); - player.playSound(blockState.getLocation(), Sound.ENTITY_ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch()); + player.playSound(blockState.getLocation(), SoundAdapter.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch()); } } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 3d9d0b38e..ca15c9f42 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -62,6 +62,7 @@ import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.MobHealthbarUtils; import com.gmail.nossr50.util.Motd; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.adapter.SoundAdapter; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.SkillUtils; @@ -325,7 +326,7 @@ public class PlayerListener implements Listener { event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer)); if (event.isCancelled()) { - player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch()); + player.playSound(player.getLocation(), SoundAdapter.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch()); return; } } @@ -336,7 +337,7 @@ public class PlayerListener implements Listener { event.setCancelled(cancel); if (pickupSuccess) { - player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch()); + player.playSound(player.getLocation(), SoundAdapter.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch()); player.updateInventory(); return; } diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 82a682c51..ebafb0814 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -27,6 +27,7 @@ import com.gmail.nossr50.events.party.McMMOPartyChangeEvent; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.adapter.SoundAdapter; import com.gmail.nossr50.util.player.UserManager; public final class PartyManager { @@ -729,7 +730,7 @@ public final class PartyManager { member.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, level)); if (levelUpSoundsEnabled) { - member.playSound(member.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH); + member.playSound(member.getLocation(), SoundAdapter.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH); } } } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AprilTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AprilTask.java index 280d9db97..7299e7545 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AprilTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AprilTask.java @@ -9,6 +9,7 @@ import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.HolidayManager; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.adapter.SoundAdapter; public class AprilTask extends BukkitRunnable { @@ -23,7 +24,7 @@ public class AprilTask extends BukkitRunnable { int random = Misc.getRandom().nextInt(40) + 11; int betterRandom = Misc.getRandom().nextInt(2000); if (betterRandom == 0) { - player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH); + player.playSound(player.getLocation(), SoundAdapter.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH); player.sendMessage(unknown("superskill") + " skill increased by 1. Total (" + unknown("12") + ")"); fireworksShow(player); } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/KrakenAttackTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/KrakenAttackTask.java index 9731cfbf5..4e12cd6bf 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/KrakenAttackTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/KrakenAttackTask.java @@ -9,6 +9,7 @@ import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.adapter.SoundAdapter; public class KrakenAttackTask extends BukkitRunnable { private LivingEntity kraken; @@ -86,11 +87,11 @@ public class KrakenAttackTask extends BukkitRunnable { player.damage(AdvancedConfig.getInstance().getKrakenAttackDamage(), kraken); if (GLOBAL_EFFECTS) { - world.playSound(playerLocation, Sound.ENTITY_GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch()); + world.playSound(playerLocation, SoundAdapter.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch()); world.strikeLightningEffect(playerLocation); } else { - player.playSound(playerLocation, Sound.ENTITY_GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch()); + player.playSound(playerLocation, SoundAdapter.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch()); world.createExplosion(playerLocation.getX(), playerLocation.getY(), playerLocation.getZ(), 0F, false, false); } } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index e730fb676..ca5dfdce1 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -61,6 +61,7 @@ import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.adapter.SoundAdapter; import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.SkillUtils; @@ -122,7 +123,7 @@ public class FishingManager extends SkillManager { world.strikeLightningEffect(location); world.strikeLightningEffect(location); - world.playSound(location, Sound.ENTITY_GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch()); + world.playSound(location, SoundAdapter.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch()); mcMMO.p.getServer().broadcastMessage(ChatColor.RED + AdvancedConfig.getInstance().getServerUnleashMessage().replace("(PLAYER)", player.getDisplayName())); } else { @@ -130,7 +131,7 @@ public class FishingManager extends SkillManager { world.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false); world.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false); - player.playSound(location, Sound.ENTITY_GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch()); + player.playSound(location, SoundAdapter.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch()); } if (player.getItemInHand().getType() == Material.FISHING_ROD) { diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java index 23fb2107c..17cdc3de4 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -26,6 +26,7 @@ import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.adapter.SoundAdapter; import com.gmail.nossr50.util.skills.SkillUtils; public class RepairManager extends SkillManager { @@ -51,7 +52,7 @@ public class RepairManager extends SkillManager { } if (Config.getInstance().getRepairAnvilPlaceSoundsEnabled()) { - player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); + player.playSound(player.getLocation(), SoundAdapter.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); } togglePlacedAnvil(); @@ -145,7 +146,7 @@ public class RepairManager extends SkillManager { // BWONG BWONG BWONG if (Config.getInstance().getRepairAnvilUseSoundsEnabled()) { - player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); + player.playSound(player.getLocation(), SoundAdapter.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); } // Repair the item! diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java index c14a7e8e4..08bd93ad2 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java @@ -23,6 +23,7 @@ import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.adapter.SoundAdapter; import com.gmail.nossr50.util.skills.SkillUtils; public class SalvageManager extends SkillManager { @@ -48,7 +49,7 @@ public class SalvageManager extends SkillManager { } if (Config.getInstance().getSalvageAnvilPlaceSoundsEnabled()) { - player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); + player.playSound(player.getLocation(), SoundAdapter.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); } togglePlacedAnvil(); @@ -112,8 +113,8 @@ public class SalvageManager extends SkillManager { // BWONG BWONG BWONG - CLUNK! if (Config.getInstance().getSalvageAnvilUseSoundsEnabled()) { - player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); - player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, 1.0F); + player.playSound(player.getLocation(), SoundAdapter.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); + player.playSound(player.getLocation(), SoundAdapter.ITEM_BREAK, 1.0F, 1.0F); } player.sendMessage(LocaleLoader.getString("Salvage.Skills.Success")); diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java index fd3c00be8..624e4c738 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java @@ -28,6 +28,7 @@ import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.adapter.SoundAdapter; import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.SkillUtils; @@ -89,7 +90,7 @@ public class SmeltingManager extends SkillManager { blockState.setType(Material.AIR); if (Config.getInstance().getFluxPickaxeSoundEnabled()) { - player.playSound(blockState.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, Misc.FIZZ_VOLUME, Misc.getFizzPitch()); + player.playSound(blockState.getLocation(), SoundAdapter.FIZZ, Misc.FIZZ_VOLUME, Misc.getFizzPitch()); } ParticleEffectUtils.playFluxEffect(blockState.getLocation()); diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index d79f5839f..43911bb3f 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -31,6 +31,7 @@ import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.adapter.SoundAdapter; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.SkillUtils; @@ -333,7 +334,7 @@ public class TamingManager extends SkillManager { } player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete") + lifeSpan); - player.playSound(location, Sound.ENTITY_FIREWORK_BLAST_FAR, 1F, 0.5F); + player.playSound(location, SoundAdapter.FIREWORK_BLAST_FAR, 1F, 0.5F); } private boolean rangeCheck(EntityType type) { diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java b/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java index 1d6909780..06007206e 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java @@ -11,6 +11,7 @@ import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.adapter.SoundAdapter; import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils; @@ -35,7 +36,7 @@ public class TrackedTamingEntity extends BukkitRunnable { public void run() { if (livingEntity.isValid()) { Location location = livingEntity.getLocation(); - location.getWorld().playSound(location, Sound.BLOCK_FIRE_EXTINGUISH, 0.8F, 0.8F); + location.getWorld().playSound(location, SoundAdapter.FIZZ, 0.8F, 0.8F); ParticleEffectUtils.playCallOfTheWildEffect(livingEntity); CombatUtils.dealDamage(livingEntity, livingEntity.getMaxHealth(), DamageCause.SUICIDE, livingEntity); } diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index c256d431a..e83dc8023 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -18,6 +18,7 @@ import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.runnables.items.ChimaeraWingWarmup; +import com.gmail.nossr50.util.adapter.SoundAdapter; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.SkillUtils; @@ -135,7 +136,7 @@ public final class ChimaeraWing { mcMMOPlayer.setTeleportCommenceLocation(null); if (Config.getInstance().getChimaeraSoundEnabled()) { - player.playSound(location, Sound.ENTITY_BAT_TAKEOFF, Misc.BAT_VOLUME, Misc.BAT_PITCH); + player.playSound(location, SoundAdapter.BAT_TAKEOFF, Misc.BAT_VOLUME, Misc.BAT_PITCH); } player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass")); diff --git a/src/main/java/com/gmail/nossr50/util/HolidayManager.java b/src/main/java/com/gmail/nossr50/util/HolidayManager.java index fb8ea3ec8..22f232b48 100644 --- a/src/main/java/com/gmail/nossr50/util/HolidayManager.java +++ b/src/main/java/com/gmail/nossr50/util/HolidayManager.java @@ -21,7 +21,6 @@ import org.bukkit.Color; import org.bukkit.DyeColor; import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect.Type; -import org.bukkit.Sound; import org.bukkit.Statistic; import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; @@ -34,6 +33,7 @@ import org.bukkit.inventory.meta.FireworkMeta; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.commands.skills.AprilCommand; import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.util.adapter.SoundAdapter; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.ParticleEffectUtils; @@ -376,7 +376,7 @@ public final class HolidayManager { public void levelUpApril(Player player, FakeSkillType fakeSkillType) { int levelTotal = Misc.getRandom().nextInt(1 + UserManager.getPlayer(player).getSkillLevel(SkillType.MINING)) + 1; - player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH); + player.playSound(player.getLocation(), SoundAdapter.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH); player.sendMessage(ChatColor.YELLOW + StringUtils.getCapitalized(fakeSkillType.toString()) + " skill increased by 1. Total (" + levelTotal + ")"); ParticleEffectUtils.fireworkParticleShower(player, ALL_COLORS.get(Misc.getRandom().nextInt(ALL_COLORS.size()))); } diff --git a/src/main/java/com/gmail/nossr50/util/adapter/SoundAdapter.java b/src/main/java/com/gmail/nossr50/util/adapter/SoundAdapter.java new file mode 100644 index 000000000..eb2d45295 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/util/adapter/SoundAdapter.java @@ -0,0 +1,91 @@ +package com.gmail.nossr50.util.adapter; + +import org.bukkit.Sound; + +public class SoundAdapter { + public static final Sound FIZZ; + public static final Sound LEVEL_UP; + public static final Sound FIREWORK_BLAST_FAR; + public static final Sound ITEM_PICKUP; + public static final Sound GHAST_SCREAM; + public static final Sound ANVIL_LAND; + public static final Sound ANVIL_USE; + public static final Sound ITEM_BREAK; + public static final Sound BAT_TAKEOFF; + + static { + Sound temp = null; + try { + temp = Sound.valueOf("BLOCK_FIRE_EXTINGUISH"); + } catch (Exception e) { + temp = Sound.valueOf("FIZZ"); + } finally { + FIZZ = temp; + } + temp = null; + try { + temp = Sound.valueOf("ENTITY_PLAYER_LEVELUP"); + } catch (Exception e) { + temp = Sound.valueOf("LEVEL_UP"); + } finally { + LEVEL_UP = temp; + } + temp = null; + try { + temp = Sound.valueOf("ENTITY_GHAST_SCREAM"); + } catch (Exception e) { + temp = Sound.valueOf("GHAST_SCREAM"); + } finally { + GHAST_SCREAM = temp; + } + temp = null; + try { + temp = Sound.valueOf("ENTITY_ITEM_PICKUP"); + } catch (Exception e) { + temp = Sound.valueOf("ITEM_PICKUP"); + } finally { + ITEM_PICKUP = temp; + } + temp = null; + try { + temp = Sound.valueOf("ENTITY_ITEM_BREAK"); + } catch (Exception e) { + temp = Sound.valueOf("ITEM_BREAK"); + } finally { + ITEM_BREAK = temp; + } + temp = null; + try { + temp = Sound.valueOf("BLOCK_ANVIL_USE"); + } catch (Exception e) { + temp = Sound.valueOf("ANVIL_USE"); + } finally { + ANVIL_USE = temp; + } + temp = null; + try { + temp = Sound.valueOf("BLOCK_ANVIL_LAND"); + } catch (Exception e) { + temp = Sound.valueOf("ANVIL_LAND"); + } finally { + ANVIL_LAND = temp; + } + temp = null; + try { + temp = Sound.valueOf("ENTITY_BAT_TAKEOFF"); + } catch (Exception e) { + temp = Sound.valueOf("BAT_TAKEOFF"); + } finally { + BAT_TAKEOFF = temp; + } + temp = null; + try { + temp = Sound.valueOf("ENTITY_FIREWORK_BLAST_FAR"); + } catch (Exception e) { + temp = Sound.valueOf("FIREWORK_LARGE_BLAST2"); + } finally { + FIREWORK_BLAST_FAR = temp; + } + } + +}