From 4b1cdbf49334ee279762f090bddb45bb9fe0c587 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 24 Sep 2019 15:06:49 -0700 Subject: [PATCH] Remove Static Abuse - SoundManager --- .../gmail/nossr50/datatypes/party/Party.java | 3 +-- .../nossr50/datatypes/player/McMMOPlayer.java | 9 +++---- .../skills/subskills/acrobatics/Roll.java | 5 ++-- .../nossr50/dumpster/HolidayManager.java | 2 +- .../nossr50/listeners/BlockListener.java | 7 +++-- .../nossr50/listeners/PlayerListener.java | 3 +-- src/main/java/com/gmail/nossr50/mcMMO.java | 11 ++++++++ .../com/gmail/nossr50/party/PartyManager.java | 3 +-- .../runnables/skills/BleedTimerTask.java | 3 +-- .../skills/fishing/FishingManager.java | 3 +-- .../nossr50/skills/repair/RepairManager.java | 7 +++-- .../skills/salvage/SalvageManager.java | 5 ++-- .../nossr50/skills/taming/TamingManager.java | 3 +-- .../gmail/nossr50/skills/unarmed/Unarmed.java | 3 +-- .../com/gmail/nossr50/util/ChimaeraWing.java | 3 +-- .../util/player/NotificationManager.java | 3 +-- .../nossr50/util/sounds/SoundManager.java | 26 ++++++++++++------- 17 files changed, 52 insertions(+), 47 deletions(-) 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 ac13373e1..0d1808376 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.party.ShareHandler; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -257,7 +256,7 @@ public class Party { if (leader != null) { leader.sendMessage(pluginRef.getLocaleManager().getString("Party.LevelUp", levelsGained, getLevel())); - SoundManager.sendSound(leader, leader.getLocation(), SoundType.LEVEL_UP); + pluginRef.getSoundManager().sendSound(leader, leader.getLocation(), SoundType.LEVEL_UP); } 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 0c4db40ae..d08c85ea3 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -33,7 +33,6 @@ import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.experience.ExperienceBarManager; import com.gmail.nossr50.util.skills.PerksUtils; -import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import org.apache.commons.lang.Validate; import org.bukkit.GameMode; @@ -683,7 +682,7 @@ public class McMMOPlayer { return; } - SoundManager.sendSound(player, player.getLocation(), SoundType.LEVEL_UP); + pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.LEVEL_UP); /* * Check to see if the player unlocked any new skills @@ -924,7 +923,7 @@ public class McMMOPlayer { */ if (primarySkillType == PrimarySkillType.WOODCUTTING || primarySkillType == PrimarySkillType.AXES) { pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining)); - //SoundManager.sendSound(player, player.getLocation(), SoundType.TIRED); + //pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.TIRED); } return; @@ -942,7 +941,7 @@ public class McMMOPlayer { pluginRef.getSkillTools().getSuperAbilityOtherPlayerActivationStr(superAbility)); //Sounds - SoundManager.worldSendSound(player.getWorld(), player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC); + pluginRef.getSoundManager().worldSendSound(player.getWorld(), player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC); int abilityLength = pluginRef.getSkillTools().calculateAbilityLengthPerks(this, primarySkillType, superAbility); @@ -998,7 +997,7 @@ public class McMMOPlayer { if (pluginRef.getConfigManager().getConfigNotifications().isSuperAbilityToolMessage()) { pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.TOOL, tool.getRaiseTool()); - SoundManager.sendSound(player, player.getLocation(), SoundType.TOOL_READY); + pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.TOOL_READY); } setToolPreparationMode(tool, true); diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java index 241ab3926..ef38ce963 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java @@ -9,7 +9,6 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.random.RandomChanceSkill; import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.SkillActivationType; -import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import net.md_5.bungee.api.chat.ComponentBuilder; import org.bukkit.Location; @@ -201,7 +200,7 @@ public class Roll extends AcrobaticsSubSkill { if (!isFatal(player, modifiedDamage) && pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ACROBATICS_ROLL, player)) { pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Roll.Text"); - SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS); + pluginRef.getSoundManager().sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS); if (!pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) pluginRef.getSkillTools().applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE); @@ -240,7 +239,7 @@ public class Roll extends AcrobaticsSubSkill { if (!isFatal(player, modifiedDamage) && pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(rcs)) { pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc"); - SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS, 0.5F); + pluginRef.getSoundManager().sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS, 0.5F); if (!pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) pluginRef.getSkillTools().applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE); diff --git a/src/main/java/com/gmail/nossr50/dumpster/HolidayManager.java b/src/main/java/com/gmail/nossr50/dumpster/HolidayManager.java index 97d1633f4..1da8bccd3 100644 --- a/src/main/java/com/gmail/nossr50/dumpster/HolidayManager.java +++ b/src/main/java/com/gmail/nossr50/dumpster/HolidayManager.java @@ -368,7 +368,7 @@ // return; // // int levelTotal = Misc.getRandom().nextInt(1 + pluginRef.getUserManager().getPlayer(player).getSkillLevel(PrimarySkillType.MINING)) + 1; -// SoundManager.sendSound(player, player.getLocation(), SoundType.LEVEL_UP); +// pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.LEVEL_UP); // mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.HOLIDAY, "Holiday.AprilFools.Levelup", StringUtils.getCapitalized(fakeSkillType.toString()), String.valueOf(levelTotal)); //// ParticleEffectUtils.fireworkParticleShower(player, ALL_COLORS.get(Misc.getRandom().nextInt(ALL_COLORS.size()))); // } diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 8febe7f8c..77a6d9805 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -13,7 +13,6 @@ import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; -import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -456,7 +455,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. */ - SoundManager.sendSound(player, blockState.getLocation(), SoundType.FIZZ); + pluginRef.getSoundManager().sendSound(player, blockState.getLocation(), SoundType.FIZZ); } private Player getPlayerFromFurnace(Block furnaceBlock) { @@ -520,7 +519,7 @@ public class BlockListener implements Listener { if (pluginRef.getSkillTools().superAbilityBlockCheck(SuperAbilityType.BERSERK, block.getState()) && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) { event.setInstaBreak(true); - SoundManager.sendSound(player, block.getLocation(), SoundType.POP); + pluginRef.getSoundManager().sendSound(player, block.getLocation(), SoundType.POP); } else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && pluginRef.getBlockTools().affectedByBlockCracker(blockState) && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) { if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) { blockState.update(); @@ -528,7 +527,7 @@ public class BlockListener implements Listener { } } else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && pluginRef.getBlockTools().isLeaves(blockState) && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) { event.setInstaBreak(true); - SoundManager.sendSound(player, block.getLocation(), SoundType.POP); + pluginRef.getSoundManager().sendSound(player, block.getLocation(), SoundType.POP); } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index eb76181ee..cb303dc6c 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -19,7 +19,6 @@ import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.util.ChimaeraWing; import com.gmail.nossr50.util.HardcoreManager; import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -455,7 +454,7 @@ public class PlayerListener implements Listener { if (!drop.hasMetadata(MetadataConstants.DROPPED_ITEM_TRACKING_METAKEY) && mcMMOPlayer.inParty() && pluginRef.getItemTools().isSharable(dropStack)) { event.setCancelled(mcMMOPlayer.getParty().getShareHandler().handleItemShare(drop, mcMMOPlayer)); - SoundManager.sendSound(player, player.getLocation(), SoundType.POP); + pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.POP); } /*if (player.getInventory().getItemInMainHand().getType() == Material.AIR) { diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 8499ba58c..6135f4892 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -43,6 +43,7 @@ import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.skills.CombatTools; import com.gmail.nossr50.util.skills.RankTools; import com.gmail.nossr50.util.skills.SkillTools; +import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; import net.shatteredlands.shatt.backup.ZipLibrary; @@ -84,6 +85,7 @@ public class mcMMO extends JavaPlugin { private EventManager eventManager; private UserManager userManager; private ScoreboardManager scoreboardManager; + private SoundManager soundManager; /* Not-Managers but my naming scheme sucks */ private DatabaseManagerFactory databaseManagerFactory; @@ -284,6 +286,9 @@ public class mcMMO extends JavaPlugin { //Init MOTD Utils messageOfTheDayUtils = new MessageOfTheDayUtils(this); + + //Init Sound Manager + soundManager = new SoundManager(this); } @Override @@ -821,5 +826,11 @@ public class mcMMO extends JavaPlugin { return messageOfTheDayUtils; } + public SoundManager getSoundManager() { + return soundManager; + } + public ChunkManagerFactory getChunkManagerFactory() { + return chunkManagerFactory; + } } diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 941e80e9a..00f1676e7 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -10,7 +10,6 @@ import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.items.TeleportationWarmup; import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; @@ -887,7 +886,7 @@ public final class PartyManager { for (Player member : party.getOnlineMembers()) { member.sendMessage(pluginRef.getLocaleManager().getString("Party.LevelUp", levelsGained, level)); - SoundManager.sendSound(member, member.getLocation(), SoundType.LEVEL_UP); + pluginRef.getSoundManager().sendSound(member, member.getLocation(), SoundType.LEVEL_UP); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java index cc2ac6925..4dd707c13 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.skills.BleedContainer; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.skills.ParticleEffectUtils; -import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -162,7 +161,7 @@ public class BleedTimerTask extends BukkitRunnable { if (victimHealthAftermath <= 0 || victimHealth != victimHealthAftermath) { //Play Bleed Sound - SoundManager.worldSendSound(target.getWorld(), target.getLocation(), SoundType.BLEED); + pluginRef.getSoundManager().worldSendSound(target.getWorld(), target.getLocation(), SoundType.BLEED); ParticleEffectUtils.playBleedEffect(target); } 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 88ffb833e..5de5f53d4 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.behaviours.FishingBehaviour; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -69,7 +68,7 @@ public class FishingManager extends SkillManager { if (lastWarnedExhaust + (1000) < currentTime) { getPlayer().sendMessage(pluginRef.getLocaleManager().getString("Fishing.Exhausting")); lastWarnedExhaust = currentTime; - SoundManager.sendSound(getPlayer(), getPlayer().getLocation(), SoundType.TIRED); + pluginRef.getSoundManager().sendSound(getPlayer(), getPlayer().getLocation(), SoundType.TIRED); } } 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 7d85913ce..ada6cdb13 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -9,7 +9,6 @@ import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.skills.SkillActivationType; -import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; @@ -41,7 +40,7 @@ public class RepairManager extends SkillManager { } if (pluginRef.getConfigManager().getConfigRepair().getRepairGeneral().isAnvilPlacedSounds()) { - SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL); + pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.ANVIL); } togglePlacedAnvil(); @@ -160,8 +159,8 @@ public class RepairManager extends SkillManager { // // // BWONG BWONG BWONG // if (mcMMO.getConfigManager().getConfigRepair().getRepairGeneral().isAnvilUseSounds()) { -// SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL); -// SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_BREAK); +// pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.ANVIL); +// pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.ITEM_BREAK); // } // // // 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 364885683..1e9b1c918 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java @@ -11,7 +11,6 @@ import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.random.RandomChanceSkillStatic; -import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import org.bukkit.Location; import org.bukkit.Material; @@ -48,7 +47,7 @@ public class SalvageManager extends SkillManager { } if (pluginRef.getConfigManager().getConfigSalvage().getGeneral().isAnvilPlacedSounds()) { - SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL); + pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.ANVIL); } togglePlacedAnvil(); @@ -154,7 +153,7 @@ public class SalvageManager extends SkillManager { // BWONG BWONG BWONG - CLUNK! if (pluginRef.getConfigManager().getConfigSalvage().getGeneral().isAnvilUseSounds()) { - SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_BREAK); + pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.ITEM_BREAK); } pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Salvage.Skills.Success"); 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 6a12dbf78..e7d3aedfc 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -16,7 +16,6 @@ import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.SkillActivationType; -import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import org.bukkit.Location; import org.bukkit.entity.*; @@ -294,7 +293,7 @@ public class TamingManager extends SkillManager { } //Send Sound - SoundManager.sendSound(player, player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC); + pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC); amountSummoned++; } diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java b/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java index f0f9197ba..76cf88fa6 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.unarmed; -import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityPickupItemEvent; @@ -63,7 +62,7 @@ public class Unarmed { event.setCancelled(true); if (grabbedItem) { - SoundManager.sendSound(player, player.getLocation(), SoundType.POP); + pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.POP); player.updateInventory(); } } diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index 7c619e223..a66537bd6 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.items.ChimaeraWingWarmup; -import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import org.bukkit.Location; import org.bukkit.Material; @@ -121,7 +120,7 @@ public final class ChimaeraWing { mcMMOPlayer.setTeleportCommenceLocation(null); if (pluginRef.getConfigManager().getConfigItems().isChimaeraWingSoundEnabled()) { - SoundManager.sendSound(player, location, SoundType.CHIMAERA_WING); + pluginRef.getSoundManager().sendSound(player, location, SoundType.CHIMAERA_WING); } pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Item.ChimaeraWing.Pass"); diff --git a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java index 598adb4f6..84b461f00 100644 --- a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java @@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; @@ -193,7 +192,7 @@ public class NotificationManager { mcMMOPlayer.getPlayer().spigot().sendMessage(pluginRef.getTextComponentFactory().getSubSkillUnlockedNotificationComponents(mcMMOPlayer.getPlayer(), subSkillType)); //Unlock Sound Effect - SoundManager.sendCategorizedSound(mcMMOPlayer.getPlayer(), mcMMOPlayer.getPlayer().getLocation(), SoundType.SKILL_UNLOCKED, SoundCategory.MASTER); + pluginRef.getSoundManager().sendCategorizedSound(mcMMOPlayer.getPlayer(), mcMMOPlayer.getPlayer().getLocation(), SoundType.SKILL_UNLOCKED, SoundCategory.MASTER); } /** diff --git a/src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java b/src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java index ea4940eee..fa07586d9 100644 --- a/src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java +++ b/src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.util.sounds; import com.gmail.nossr50.config.hocon.sound.SoundSetting; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import org.bukkit.Location; import org.bukkit.Sound; @@ -9,29 +10,36 @@ import org.bukkit.World; import org.bukkit.entity.Player; public class SoundManager { + + private final mcMMO pluginRef; + + public SoundManager(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + /** * Sends a sound to the player * * @param soundType the type of sound */ - public static void sendSound(Player player, Location location, SoundType soundType) { + public void sendSound(Player player, Location location, SoundType soundType) { if (pluginRef.getConfigManager().getConfigSound().isSoundEnabled(soundType)) player.playSound(location, getSound(soundType), SoundCategory.MASTER, getVolume(soundType), getPitch(soundType)); } - public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory) { + public void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory) { if (pluginRef.getConfigManager().getConfigSound().isSoundEnabled(soundType)) player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(soundType)); } - public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory, float pitchModifier) { + public void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory, float pitchModifier) { float totalPitch = Math.min(2.0F, (getPitch(soundType) + pitchModifier)); if (pluginRef.getConfigManager().getConfigSound().isSoundEnabled(soundType)) player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch); } - public static void worldSendSound(World world, Location location, SoundType soundType) { + public void worldSendSound(World world, Location location, SoundType soundType) { if (pluginRef.getConfigManager().getConfigSound().isSoundEnabled(soundType)) world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType)); } @@ -42,12 +50,12 @@ public class SoundManager { * @param soundType target soundtype * @return the volume for this soundtype */ - private static float getVolume(SoundType soundType) { + private float getVolume(SoundType soundType) { SoundSetting soundSetting = pluginRef.getConfigManager().getConfigSound().getSoundSetting(soundType); return soundSetting.getVolume() * (float) pluginRef.getConfigManager().getConfigSound().getMasterVolume(); } - private static float getPitch(SoundType soundType) { + private float getPitch(SoundType soundType) { if (soundType == SoundType.FIZZ) return getFizzPitch(); else if (soundType == SoundType.POP) @@ -58,7 +66,7 @@ public class SoundManager { } } - private static Sound getSound(SoundType soundType) { + private Sound getSound(SoundType soundType) { switch (soundType) { case ANVIL: return Sound.BLOCK_ANVIL_PLACE; @@ -91,11 +99,11 @@ public class SoundManager { } } - public static float getFizzPitch() { + public float getFizzPitch() { return 2.6F + (Misc.getRandom().nextFloat() - Misc.getRandom().nextFloat()) * 0.8F; } - public static float getPopPitch() { + public float getPopPitch() { return ((Misc.getRandom().nextFloat() - Misc.getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F; } }