Fixed a bug involving SubSkill notifications

Fixes #3808, also fixed the notification timer
This commit is contained in:
nossr50 2019-03-30 16:56:00 -07:00
parent 1f2eae0799
commit f1ecef310c
3 changed files with 15 additions and 4 deletions

View File

@ -150,6 +150,9 @@ Version 2.2.0
Added API method to check if player parties are size capped 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 grab the level cap of a skill by its PrimarySkillType ENUM definition
Added API method to check if a skill was being level capped 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 Version 2.1.30
Fixed double drops behaving oddly Fixed double drops behaving oddly

View File

@ -11,6 +11,7 @@ import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; 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.WorldGuardManager;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -40,6 +41,9 @@ public class SelfListener implements Listener {
UserManager.getPlayer(player).processUnlockNotifications(plugin, event.getSkill(), previousLevelGained); UserManager.getPlayer(player).processUnlockNotifications(plugin, event.getSkill(), previousLevelGained);
} }
//Reset the delay timer
RankUtils.resetUnlockDelayTimer();
if(mcMMO.getScoreboardSettings().getScoreboardsEnabled()) if(mcMMO.getScoreboardSettings().getScoreboardsEnabled())
ScoreboardManager.handleLevelUp(player, skill); ScoreboardManager.handleLevelUp(player, skill);

View File

@ -16,6 +16,7 @@ import java.util.HashMap;
public class RankUtils { public class RankUtils {
private static HashMap<String, HashMap<Integer, Integer>> subSkillRanks; private static HashMap<String, HashMap<Integer, Integer>> 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) public static void executeSkillUnlockNotifications(Plugin plugin, McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType, int newLevel)
{ {
int count = 0;
for(SubSkillType subSkillType : primarySkillType.getSkillAbilities()) for(SubSkillType subSkillType : primarySkillType.getSkillAbilities())
{ {
int playerRankInSkill = getRank(mcMMOPlayer.getPlayer(), subSkillType); int playerRankInSkill = getRank(mcMMOPlayer.getPlayer(), subSkillType);
@ -36,20 +35,25 @@ public class RankUtils {
//If the skill doesn't have registered ranks gtfo //If the skill doesn't have registered ranks gtfo
if(innerMap == null || innerMap.get(playerRankInSkill) == null) if(innerMap == null || innerMap.get(playerRankInSkill) == null)
return; continue;
//The players level is the exact level requirement for this skill //The players level is the exact level requirement for this skill
if(newLevel == innerMap.get(playerRankInSkill)) if(newLevel == innerMap.get(playerRankInSkill))
{ {
SkillUnlockNotificationTask skillUnlockNotificationTask = new SkillUnlockNotificationTask(mcMMOPlayer, subSkillType, newLevel); SkillUnlockNotificationTask skillUnlockNotificationTask = new SkillUnlockNotificationTask(mcMMOPlayer, subSkillType, newLevel);
skillUnlockNotificationTask.runTaskLater(plugin, ((count * 4) + 1) * 20); skillUnlockNotificationTask.runTaskLater(plugin, (count * 100));
count++; count++;
} }
} }
} }
public static void resetUnlockDelayTimer()
{
count = 0;
}
/* NEW SYSTEM */ /* NEW SYSTEM */
private static void addRanks(AbstractSubSkill abstractSubSkill) private static void addRanks(AbstractSubSkill abstractSubSkill)
{ {