mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Fixed a sync problem where XP bars were 1-step behind
This commit is contained in:
parent
b7b0ff13e7
commit
b8a146f8bd
@ -50,6 +50,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -143,18 +144,18 @@ public class McMMOPlayer {
|
||||
experienceBarManager.hideExperienceBar(primarySkillType);
|
||||
}*/
|
||||
|
||||
public void processPostXpEvent(XPGainReason xpGainReason, PrimarySkillType primarySkillType, mcMMO plugin, int xpGained)
|
||||
public void processPostXpEvent(XPGainReason xpGainReason, PrimarySkillType primarySkillType, Plugin plugin)
|
||||
{
|
||||
if(xpGainReason != XPGainReason.SHARED_PVP && xpGainReason != XPGainReason.SHARED_PVE && xpGainReason != XPGainReason.VAMPIRISM)
|
||||
updateXPBar(primarySkillType, plugin);
|
||||
}
|
||||
|
||||
public void processUnlockNotifications(mcMMO plugin, PrimarySkillType primarySkillType, int level)
|
||||
public void processUnlockNotifications(mcMMO plugin, PrimarySkillType primarySkillType)
|
||||
{
|
||||
RankUtils.executeSkillUnlockNotifications(plugin, this, primarySkillType, profile.getSkillLevel(primarySkillType));
|
||||
}
|
||||
|
||||
public void updateXPBar(PrimarySkillType primarySkillType, mcMMO plugin)
|
||||
public void updateXPBar(PrimarySkillType primarySkillType, Plugin plugin)
|
||||
{
|
||||
//Skill Unlock Notifications
|
||||
|
||||
@ -533,6 +534,7 @@ public class McMMOPlayer {
|
||||
*/
|
||||
private void checkXp(PrimarySkillType primarySkillType, XPGainReason xpGainReason) {
|
||||
if (getSkillXpLevelRaw(primarySkillType) < getXpToLevel(primarySkillType)) {
|
||||
UserManager.getPlayer(player).processPostXpEvent(xpGainReason, primarySkillType, mcMMO.p);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -550,6 +552,7 @@ public class McMMOPlayer {
|
||||
}
|
||||
|
||||
if (!EventUtils.handleLevelChangeEvent(player, primarySkillType, levelsGained, xpRemoved, true, xpGainReason)) {
|
||||
UserManager.getPlayer(player).processPostXpEvent(xpGainReason, primarySkillType, mcMMO.p);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -562,6 +565,9 @@ public class McMMOPlayer {
|
||||
*/
|
||||
|
||||
NotificationManager.sendPlayerLevelUpNotification(UserManager.getPlayer(player), primarySkillType, profile.getSkillLevel(primarySkillType));
|
||||
|
||||
//UPDATE XP BARS
|
||||
UserManager.getPlayer(player).processPostXpEvent(xpGainReason, primarySkillType, mcMMO.p);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -30,7 +30,8 @@ public class SelfListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
PrimarySkillType skill = event.getSkill();
|
||||
|
||||
UserManager.getPlayer(player).processUnlockNotifications(plugin, event.getSkill(), event.getSkillLevel());
|
||||
//Send player skill unlock notifications
|
||||
UserManager.getPlayer(player).processUnlockNotifications(plugin, event.getSkill());
|
||||
|
||||
if(Config.getInstance().getScoreboardsEnabled())
|
||||
ScoreboardManager.handleLevelUp(player, skill);
|
||||
@ -64,8 +65,6 @@ public class SelfListener implements Listener {
|
||||
|
||||
if (event.getXpGainReason() == XPGainReason.COMMAND)
|
||||
{
|
||||
//Update the XP Bar
|
||||
mcMMOPlayer.processPostXpEvent(event.getXpGainReason(), primarySkillType, plugin, (int) event.getRawXpGained());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -73,8 +72,6 @@ public class SelfListener implements Listener {
|
||||
|
||||
if (threshold <= 0 || !ExperienceConfig.getInstance().getDiminishedReturnsEnabled()) {
|
||||
// Diminished returns is turned off
|
||||
//Update the XP Bar
|
||||
mcMMOPlayer.processPostXpEvent(event.getXpGainReason(), primarySkillType, plugin, (int) event.getRawXpGained());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -117,9 +114,5 @@ public class SelfListener implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Update the XP Bar
|
||||
if(!event.isCancelled())
|
||||
mcMMOPlayer.processPostXpEvent(event.getXpGainReason(), primarySkillType, plugin, (int) event.getRawXpGained());
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.skills;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
@ -41,6 +41,7 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -3,8 +3,8 @@ package com.gmail.nossr50.util.experience;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.skills.ExperienceBarHideTask;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@ -27,7 +27,7 @@ public class ExperienceBarManager {
|
||||
this.mcMMOPlayer = mcMMOPlayer;
|
||||
}
|
||||
|
||||
public void updateExperienceBar(PrimarySkillType primarySkillType, mcMMO plugin)
|
||||
public void updateExperienceBar(PrimarySkillType primarySkillType, Plugin plugin)
|
||||
{
|
||||
if(!ExperienceConfig.getInstance().isExperienceBarsEnabled() || !ExperienceConfig.getInstance().isExperienceBarEnabled(primarySkillType))
|
||||
return;
|
||||
@ -55,7 +55,7 @@ public class ExperienceBarManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleHideTask(PrimarySkillType primarySkillType, mcMMO plugin) {
|
||||
private void scheduleHideTask(PrimarySkillType primarySkillType, Plugin plugin) {
|
||||
ExperienceBarHideTask experienceBarHideTask = new ExperienceBarHideTask(this, mcMMOPlayer, primarySkillType);
|
||||
experienceBarHideTask.runTaskLater(plugin, 20*2);
|
||||
experienceBarHideTaskHashMap.put(primarySkillType, experienceBarHideTask);
|
||||
|
Loading…
Reference in New Issue
Block a user