Browse Source

Skill Unlock notifications now have sounds

nossr50 6 years ago
parent
commit
e962f645b6

+ 2 - 2
src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java

@@ -149,9 +149,9 @@ public class McMMOPlayer {
             updateXPBar(primarySkillType, plugin);
     }
 
-    public void processUnlockNotifications(mcMMO plugin, PrimarySkillType primarySkillType)
+    public void processUnlockNotifications(mcMMO plugin, PrimarySkillType primarySkillType, int skillLevel)
     {
-        RankUtils.executeSkillUnlockNotifications(plugin, this, primarySkillType, profile.getSkillLevel(primarySkillType));
+        RankUtils.executeSkillUnlockNotifications(plugin, this, primarySkillType, skillLevel);
     }
 
     public void updateXPBar(PrimarySkillType primarySkillType, Plugin plugin)

+ 7 - 2
src/main/java/com/gmail/nossr50/listeners/SelfListener.java

@@ -30,8 +30,13 @@ public class SelfListener implements Listener {
         Player player = event.getPlayer();
         PrimarySkillType skill = event.getSkill();
 
-        //Send player skill unlock notifications
-        UserManager.getPlayer(player).processUnlockNotifications(plugin, event.getSkill());
+        //Players can gain multiple levels especially during xprate events
+        for(int i = 0; i < event.getLevelsGained(); i++)
+        {
+            int previousLevelGained = event.getSkillLevel() - i;
+            //Send player skill unlock notifications
+            UserManager.getPlayer(player).processUnlockNotifications(plugin, event.getSkill(), previousLevelGained);
+        }
 
         if(Config.getInstance().getScoreboardsEnabled())
             ScoreboardManager.handleLevelUp(player, skill);

+ 6 - 0
src/main/java/com/gmail/nossr50/util/player/NotificationManager.java

@@ -8,11 +8,14 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
 import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent;
 import com.gmail.nossr50.util.Misc;
 import com.gmail.nossr50.util.TextComponentFactory;
+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;
 import org.bukkit.Bukkit;
 import org.bukkit.Location;
 import org.bukkit.Server;
+import org.bukkit.SoundCategory;
 import org.bukkit.entity.Player;
 
 public class NotificationManager {
@@ -122,6 +125,9 @@ public class NotificationManager {
         //CHAT MESSAGE
         mcMMOPlayer.getPlayer().spigot().sendMessage(TextComponentFactory.getSubSkillUnlockedNotificationComponents(mcMMOPlayer.getPlayer(), subSkillType));
 
+        //Unlock Sound Effect
+        SoundManager.sendCategorizedSound(mcMMOPlayer.getPlayer(), mcMMOPlayer.getPlayer().getLocation(), SoundType.SKILL_UNLOCKED, SoundCategory.MASTER);
+
         //ACTION BAR MESSAGE
         /*if(AdvancedConfig.getInstance().doesNotificationUseActionBar(NotificationType.SUBSKILL_UNLOCKED))
             mcMMOPlayer.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(LocaleLoader.getString("JSON.SkillUnlockMessage",

+ 7 - 1
src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java

@@ -4,6 +4,7 @@ import com.gmail.nossr50.config.SoundConfig;
 import com.gmail.nossr50.util.Misc;
 import org.bukkit.Location;
 import org.bukkit.Sound;
+import org.bukkit.SoundCategory;
 import org.bukkit.World;
 import org.bukkit.entity.Player;
 
@@ -14,7 +15,12 @@ public class SoundManager {
      */
     public static void sendSound(Player player, Location location, SoundType soundType)
     {
-        player.playSound(location, getSound(soundType), 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)
+    {
+        player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(soundType));
     }
 
     public static void worldSendSound(World world, Location location, SoundType soundType)