Remove Static Abuse - SoundManager

This commit is contained in:
nossr50 2019-09-24 15:06:49 -07:00
parent f0636ef47e
commit 4b1cdbf493
17 changed files with 52 additions and 47 deletions

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.ShareHandler; import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -257,7 +256,7 @@ public class Party {
if (leader != null) { if (leader != null) {
leader.sendMessage(pluginRef.getLocaleManager().getString("Party.LevelUp", levelsGained, getLevel())); 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; return;
} }

View File

@ -33,7 +33,6 @@ import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.experience.ExperienceBarManager; import com.gmail.nossr50.util.experience.ExperienceBarManager;
import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -683,7 +682,7 @@ public class McMMOPlayer {
return; 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 * Check to see if the player unlocked any new skills
@ -924,7 +923,7 @@ public class McMMOPlayer {
*/ */
if (primarySkillType == PrimarySkillType.WOODCUTTING || primarySkillType == PrimarySkillType.AXES) { if (primarySkillType == PrimarySkillType.WOODCUTTING || primarySkillType == PrimarySkillType.AXES) {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining)); 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; return;
@ -942,7 +941,7 @@ public class McMMOPlayer {
pluginRef.getSkillTools().getSuperAbilityOtherPlayerActivationStr(superAbility)); pluginRef.getSkillTools().getSuperAbilityOtherPlayerActivationStr(superAbility));
//Sounds //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); int abilityLength = pluginRef.getSkillTools().calculateAbilityLengthPerks(this, primarySkillType, superAbility);
@ -998,7 +997,7 @@ public class McMMOPlayer {
if (pluginRef.getConfigManager().getConfigNotifications().isSuperAbilityToolMessage()) { if (pluginRef.getConfigManager().getConfigNotifications().isSuperAbilityToolMessage()) {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.TOOL, tool.getRaiseTool()); 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); setToolPreparationMode(tool, true);

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.random.RandomChanceSkill; import com.gmail.nossr50.util.random.RandomChanceSkill;
import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.ComponentBuilder;
import org.bukkit.Location; import org.bukkit.Location;
@ -201,7 +200,7 @@ public class Roll extends AcrobaticsSubSkill {
if (!isFatal(player, modifiedDamage) if (!isFatal(player, modifiedDamage)
&& pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ACROBATICS_ROLL, player)) { && pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ACROBATICS_ROLL, player)) {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Roll.Text"); 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()) if (!pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse())
pluginRef.getSkillTools().applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE); pluginRef.getSkillTools().applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);
@ -240,7 +239,7 @@ public class Roll extends AcrobaticsSubSkill {
if (!isFatal(player, modifiedDamage) if (!isFatal(player, modifiedDamage)
&& pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(rcs)) { && pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(rcs)) {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc"); 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()) if (!pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse())
pluginRef.getSkillTools().applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE); pluginRef.getSkillTools().applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);

View File

@ -368,7 +368,7 @@
// return; // return;
// //
// int levelTotal = Misc.getRandom().nextInt(1 + pluginRef.getUserManager().getPlayer(player).getSkillLevel(PrimarySkillType.MINING)) + 1; // 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)); // 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()))); //// ParticleEffectUtils.fireworkParticleShower(player, ALL_COLORS.get(Misc.getRandom().nextInt(ALL_COLORS.size())));
// } // }

View File

@ -13,7 +13,6 @@ import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; 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. * 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) { private Player getPlayerFromFurnace(Block furnaceBlock) {
@ -520,7 +519,7 @@ public class BlockListener implements Listener {
if (pluginRef.getSkillTools().superAbilityBlockCheck(SuperAbilityType.BERSERK, block.getState()) if (pluginRef.getSkillTools().superAbilityBlockCheck(SuperAbilityType.BERSERK, block.getState())
&& pluginRef.getEventManager().simulateBlockBreak(block, player, true)) { && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) {
event.setInstaBreak(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)) { } else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && pluginRef.getBlockTools().affectedByBlockCracker(blockState) && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) {
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) { if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
blockState.update(); 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)) { } else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && pluginRef.getBlockTools().isLeaves(blockState) && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) {
event.setInstaBreak(true); event.setInstaBreak(true);
SoundManager.sendSound(player, block.getLocation(), SoundType.POP); pluginRef.getSoundManager().sendSound(player, block.getLocation(), SoundType.POP);
} }
} }

View File

@ -19,7 +19,6 @@ import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.util.ChimaeraWing; import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.HardcoreManager; import com.gmail.nossr50.util.HardcoreManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; 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)) { if (!drop.hasMetadata(MetadataConstants.DROPPED_ITEM_TRACKING_METAKEY) && mcMMOPlayer.inParty() && pluginRef.getItemTools().isSharable(dropStack)) {
event.setCancelled(mcMMOPlayer.getParty().getShareHandler().handleItemShare(drop, mcMMOPlayer)); 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) { /*if (player.getInventory().getItemInMainHand().getType() == Material.AIR) {

View File

@ -43,6 +43,7 @@ import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.CombatTools; import com.gmail.nossr50.util.skills.CombatTools;
import com.gmail.nossr50.util.skills.RankTools; import com.gmail.nossr50.util.skills.RankTools;
import com.gmail.nossr50.util.skills.SkillTools; 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.WorldGuardManager;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
import net.shatteredlands.shatt.backup.ZipLibrary; import net.shatteredlands.shatt.backup.ZipLibrary;
@ -84,6 +85,7 @@ public class mcMMO extends JavaPlugin {
private EventManager eventManager; private EventManager eventManager;
private UserManager userManager; private UserManager userManager;
private ScoreboardManager scoreboardManager; private ScoreboardManager scoreboardManager;
private SoundManager soundManager;
/* Not-Managers but my naming scheme sucks */ /* Not-Managers but my naming scheme sucks */
private DatabaseManagerFactory databaseManagerFactory; private DatabaseManagerFactory databaseManagerFactory;
@ -284,6 +286,9 @@ public class mcMMO extends JavaPlugin {
//Init MOTD Utils //Init MOTD Utils
messageOfTheDayUtils = new MessageOfTheDayUtils(this); messageOfTheDayUtils = new MessageOfTheDayUtils(this);
//Init Sound Manager
soundManager = new SoundManager(this);
} }
@Override @Override
@ -821,5 +826,11 @@ public class mcMMO extends JavaPlugin {
return messageOfTheDayUtils; return messageOfTheDayUtils;
} }
public SoundManager getSoundManager() {
return soundManager;
}
public ChunkManagerFactory getChunkManagerFactory() {
return chunkManagerFactory;
}
} }

View File

@ -10,7 +10,6 @@ import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.items.TeleportationWarmup; import com.gmail.nossr50.runnables.items.TeleportationWarmup;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -887,7 +886,7 @@ public final class PartyManager {
for (Player member : party.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
member.sendMessage(pluginRef.getLocaleManager().getString("Party.LevelUp", levelsGained, level)); 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);
} }
} }

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.skills.BleedContainer; import com.gmail.nossr50.datatypes.skills.BleedContainer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -162,7 +161,7 @@ public class BleedTimerTask extends BukkitRunnable {
if (victimHealthAftermath <= 0 || victimHealth != victimHealthAftermath) { if (victimHealthAftermath <= 0 || victimHealth != victimHealthAftermath) {
//Play Bleed Sound //Play Bleed Sound
SoundManager.worldSendSound(target.getWorld(), target.getLocation(), SoundType.BLEED); pluginRef.getSoundManager().worldSendSound(target.getWorld(), target.getLocation(), SoundType.BLEED);
ParticleEffectUtils.playBleedEffect(target); ParticleEffectUtils.playBleedEffect(target);
} }

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.behaviours.FishingBehaviour; import com.gmail.nossr50.datatypes.skills.behaviours.FishingBehaviour;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -69,7 +68,7 @@ public class FishingManager extends SkillManager {
if (lastWarnedExhaust + (1000) < currentTime) { if (lastWarnedExhaust + (1000) < currentTime) {
getPlayer().sendMessage(pluginRef.getLocaleManager().getString("Fishing.Exhausting")); getPlayer().sendMessage(pluginRef.getLocaleManager().getString("Fishing.Exhausting"));
lastWarnedExhaust = currentTime; lastWarnedExhaust = currentTime;
SoundManager.sendSound(getPlayer(), getPlayer().getLocation(), SoundType.TIRED); pluginRef.getSoundManager().sendSound(getPlayer(), getPlayer().getLocation(), SoundType.TIRED);
} }
} }

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -41,7 +40,7 @@ public class RepairManager extends SkillManager {
} }
if (pluginRef.getConfigManager().getConfigRepair().getRepairGeneral().isAnvilPlacedSounds()) { if (pluginRef.getConfigManager().getConfigRepair().getRepairGeneral().isAnvilPlacedSounds()) {
SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL); pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.ANVIL);
} }
togglePlacedAnvil(); togglePlacedAnvil();
@ -160,8 +159,8 @@ public class RepairManager extends SkillManager {
// //
// // BWONG BWONG BWONG // // BWONG BWONG BWONG
// if (mcMMO.getConfigManager().getConfigRepair().getRepairGeneral().isAnvilUseSounds()) { // if (mcMMO.getConfigManager().getConfigRepair().getRepairGeneral().isAnvilUseSounds()) {
// SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL); // pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.ANVIL);
// SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_BREAK); // pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.ITEM_BREAK);
// } // }
// //
// // Repair the item! // // Repair the item!

View File

@ -11,7 +11,6 @@ import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -48,7 +47,7 @@ public class SalvageManager extends SkillManager {
} }
if (pluginRef.getConfigManager().getConfigSalvage().getGeneral().isAnvilPlacedSounds()) { if (pluginRef.getConfigManager().getConfigSalvage().getGeneral().isAnvilPlacedSounds()) {
SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL); pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.ANVIL);
} }
togglePlacedAnvil(); togglePlacedAnvil();
@ -154,7 +153,7 @@ public class SalvageManager extends SkillManager {
// BWONG BWONG BWONG - CLUNK! // BWONG BWONG BWONG - CLUNK!
if (pluginRef.getConfigManager().getConfigSalvage().getGeneral().isAnvilUseSounds()) { 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"); pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Salvage.Skills.Success");

View File

@ -16,7 +16,6 @@ import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.*; import org.bukkit.entity.*;
@ -294,7 +293,7 @@ public class TamingManager extends SkillManager {
} }
//Send Sound //Send Sound
SoundManager.sendSound(player, player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC); pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC);
amountSummoned++; amountSummoned++;
} }

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.skills.unarmed; package com.gmail.nossr50.skills.unarmed;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityPickupItemEvent; import org.bukkit.event.entity.EntityPickupItemEvent;
@ -63,7 +62,7 @@ public class Unarmed {
event.setCancelled(true); event.setCancelled(true);
if (grabbedItem) { if (grabbedItem) {
SoundManager.sendSound(player, player.getLocation(), SoundType.POP); pluginRef.getSoundManager().sendSound(player, player.getLocation(), SoundType.POP);
player.updateInventory(); player.updateInventory();
} }
} }

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.items.ChimaeraWingWarmup; import com.gmail.nossr50.runnables.items.ChimaeraWingWarmup;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -121,7 +120,7 @@ public final class ChimaeraWing {
mcMMOPlayer.setTeleportCommenceLocation(null); mcMMOPlayer.setTeleportCommenceLocation(null);
if (pluginRef.getConfigManager().getConfigItems().isChimaeraWingSoundEnabled()) { 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"); pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Item.ChimaeraWing.Pass");

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent; import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent; 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)); mcMMOPlayer.getPlayer().spigot().sendMessage(pluginRef.getTextComponentFactory().getSubSkillUnlockedNotificationComponents(mcMMOPlayer.getPlayer(), subSkillType));
//Unlock Sound Effect //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);
} }
/** /**

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.util.sounds; package com.gmail.nossr50.util.sounds;
import com.gmail.nossr50.config.hocon.sound.SoundSetting; import com.gmail.nossr50.config.hocon.sound.SoundSetting;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -9,29 +10,36 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class SoundManager { public class SoundManager {
private final mcMMO pluginRef;
public SoundManager(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
/** /**
* Sends a sound to the player * Sends a sound to the player
* *
* @param soundType the type of sound * @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)) if (pluginRef.getConfigManager().getConfigSound().isSoundEnabled(soundType))
player.playSound(location, getSound(soundType), SoundCategory.MASTER, getVolume(soundType), getPitch(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)) if (pluginRef.getConfigManager().getConfigSound().isSoundEnabled(soundType))
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(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)); float totalPitch = Math.min(2.0F, (getPitch(soundType) + pitchModifier));
if (pluginRef.getConfigManager().getConfigSound().isSoundEnabled(soundType)) if (pluginRef.getConfigManager().getConfigSound().isSoundEnabled(soundType))
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch); 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)) if (pluginRef.getConfigManager().getConfigSound().isSoundEnabled(soundType))
world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType)); world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType));
} }
@ -42,12 +50,12 @@ public class SoundManager {
* @param soundType target soundtype * @param soundType target soundtype
* @return the volume for this 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); SoundSetting soundSetting = pluginRef.getConfigManager().getConfigSound().getSoundSetting(soundType);
return soundSetting.getVolume() * (float) pluginRef.getConfigManager().getConfigSound().getMasterVolume(); return soundSetting.getVolume() * (float) pluginRef.getConfigManager().getConfigSound().getMasterVolume();
} }
private static float getPitch(SoundType soundType) { private float getPitch(SoundType soundType) {
if (soundType == SoundType.FIZZ) if (soundType == SoundType.FIZZ)
return getFizzPitch(); return getFizzPitch();
else if (soundType == SoundType.POP) 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) { switch (soundType) {
case ANVIL: case ANVIL:
return Sound.BLOCK_ANVIL_PLACE; 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; 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; return ((Misc.getRandom().nextFloat() - Misc.getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F;
} }
} }