From f1ecef310c32f8876d44f5794ac48e4b9536d10e Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 30 Mar 2019 16:56:00 -0700 Subject: [PATCH] Fixed a bug involving SubSkill notifications Fixes #3808, also fixed the notification timer --- Changelog.txt | 3 +++ .../com/gmail/nossr50/listeners/SelfListener.java | 4 ++++ .../com/gmail/nossr50/util/skills/RankUtils.java | 12 ++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 9a4a48984..d1d920694 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -150,6 +150,9 @@ Version 2.2.0 Added API method to check if player parties are size capped Added API method to grab the level cap of a skill by its PrimarySkillType ENUM definition Added API method to check if a skill was being level capped +Version 2.1.31 + Fixed a bug where certain SubSkills did not properly send unlock or rank up notifications + Fixed a bug where unlock notifications would send simultaneously for a specific skill (still happens if mmoedit changes all skill levels on a player at once) Version 2.1.30 Fixed double drops behaving oddly diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java index f41c0a37e..8ac64704f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java @@ -11,6 +11,7 @@ import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; +import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; import org.bukkit.entity.Player; @@ -40,6 +41,9 @@ public class SelfListener implements Listener { UserManager.getPlayer(player).processUnlockNotifications(plugin, event.getSkill(), previousLevelGained); } + //Reset the delay timer + RankUtils.resetUnlockDelayTimer(); + if(mcMMO.getScoreboardSettings().getScoreboardsEnabled()) ScoreboardManager.handleLevelUp(player, skill); diff --git a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java index 21ba0a678..b5df535a0 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java @@ -16,6 +16,7 @@ import java.util.HashMap; public class RankUtils { private static HashMap> subSkillRanks; + private static int count = 0; /** * @@ -26,8 +27,6 @@ public class RankUtils { */ public static void executeSkillUnlockNotifications(Plugin plugin, McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType, int newLevel) { - int count = 0; - for(SubSkillType subSkillType : primarySkillType.getSkillAbilities()) { int playerRankInSkill = getRank(mcMMOPlayer.getPlayer(), subSkillType); @@ -36,20 +35,25 @@ public class RankUtils { //If the skill doesn't have registered ranks gtfo if(innerMap == null || innerMap.get(playerRankInSkill) == null) - return; + continue; //The players level is the exact level requirement for this skill if(newLevel == innerMap.get(playerRankInSkill)) { SkillUnlockNotificationTask skillUnlockNotificationTask = new SkillUnlockNotificationTask(mcMMOPlayer, subSkillType, newLevel); - skillUnlockNotificationTask.runTaskLater(plugin, ((count * 4) + 1) * 20); + skillUnlockNotificationTask.runTaskLater(plugin, (count * 100)); count++; } } } + public static void resetUnlockDelayTimer() + { + count = 0; + } + /* NEW SYSTEM */ private static void addRanks(AbstractSubSkill abstractSubSkill) {