mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Featherboard compatibility
This commit is contained in:
parent
fc3e580550
commit
7c8e14fd74
@ -1,5 +1,7 @@
|
||||
Version 2.1.182
|
||||
Fixed a NPE with Scoreboards enabled when trying to update scoreboards
|
||||
Fixed an error when using mcMMO with Featherboard that broke mcMMO skill boards when using certain commands
|
||||
Added 'Scoreboard.Recovery' locale key
|
||||
Players now receive XP from harvesting Sweet Berry bushes (double XP for harvesting fully grown berries)
|
||||
Sweet Berry Bush will no longer ready tools for Super Abilities
|
||||
You can now use '.all' (for example: mcmmo.perks.xp.customboost.all) to give an XP perk to all skills
|
||||
|
@ -118,6 +118,8 @@ public class McMMOPlayer implements Identified {
|
||||
private final FixedMetadataValue playerMetadata;
|
||||
private final String playerName;
|
||||
|
||||
private PrimarySkillType lastSkillShownScoreboard = PrimarySkillType.values()[0];
|
||||
|
||||
public McMMOPlayer(Player player, PlayerProfile profile) {
|
||||
this.playerName = player.getName();
|
||||
UUID uuid = player.getUniqueId();
|
||||
@ -186,6 +188,14 @@ public class McMMOPlayer implements Identified {
|
||||
experienceBarManager.hideExperienceBar(primarySkillType);
|
||||
}*/
|
||||
|
||||
public @NotNull PrimarySkillType getLastSkillShownScoreboard() {
|
||||
return lastSkillShownScoreboard;
|
||||
}
|
||||
|
||||
public void setLastSkillShownScoreboard(PrimarySkillType primarySkillType) {
|
||||
this.lastSkillShownScoreboard = primarySkillType;
|
||||
}
|
||||
|
||||
public void processPostXpEvent(PrimarySkillType primarySkillType, Plugin plugin, XPGainSource xpGainSource)
|
||||
{
|
||||
//Check if they've reached the power level cap just now
|
||||
|
@ -285,6 +285,9 @@ public class ScoreboardManager {
|
||||
// **** Setup methods **** //
|
||||
|
||||
public static void enablePlayerSkillScoreboard(Player player, PrimarySkillType skill) {
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
mmoPlayer.setLastSkillShownScoreboard(skill);
|
||||
|
||||
ScoreboardWrapper wrapper = getWrapper(player);
|
||||
|
||||
if(wrapper == null) {
|
||||
@ -300,6 +303,25 @@ public class ScoreboardManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void retryLastSkillBoard(Player player) {
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
PrimarySkillType primarySkillType = mmoPlayer.getLastSkillShownScoreboard();
|
||||
|
||||
ScoreboardWrapper wrapper = getWrapper(player);
|
||||
|
||||
if(wrapper == null) {
|
||||
setupPlayer(player);
|
||||
wrapper = getWrapper(player);
|
||||
}
|
||||
|
||||
if(wrapper != null) {
|
||||
wrapper.setOldScoreboard();
|
||||
wrapper.setTypeSkill(primarySkillType);
|
||||
|
||||
changeScoreboard(wrapper, Config.getInstance().getSkillScoreboardTime());
|
||||
}
|
||||
}
|
||||
|
||||
public static void enablePlayerSkillLevelUpScoreboard(Player player, PrimarySkillType skill) {
|
||||
ScoreboardWrapper wrapper = getWrapper(player);
|
||||
|
||||
@ -528,8 +550,7 @@ public class ScoreboardManager {
|
||||
return mcMMO.p.getServer().getScoreboardManager();
|
||||
}
|
||||
|
||||
|
||||
private static void changeScoreboard(ScoreboardWrapper wrapper, int displayTime) {
|
||||
public static void changeScoreboard(ScoreboardWrapper wrapper, int displayTime) {
|
||||
if (displayTime == -1) {
|
||||
wrapper.showBoardWithNoRevert();
|
||||
}
|
||||
|
@ -14,9 +14,11 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -43,7 +45,7 @@ public class ScoreboardWrapper {
|
||||
// Internal usage variables (should exist)
|
||||
private SidebarType sidebarType;
|
||||
private Objective sidebarObjective;
|
||||
private final Objective powerObjective;
|
||||
private Objective powerObjective;
|
||||
|
||||
// Parameter variables (May be null / invalid)
|
||||
private Scoreboard oldBoard = null;
|
||||
@ -51,14 +53,27 @@ public class ScoreboardWrapper {
|
||||
public PrimarySkillType targetSkill = null;
|
||||
private PlayerProfile targetProfile = null;
|
||||
public int leaderboardPage = -1;
|
||||
private boolean registered = false;
|
||||
|
||||
public ScoreboardWrapper(Player player, Scoreboard scoreboard) {
|
||||
this.player = player;
|
||||
this.playerName = player.getName();
|
||||
this.scoreboard = scoreboard;
|
||||
initBoard();
|
||||
}
|
||||
|
||||
private void initBoard() {
|
||||
sidebarType = SidebarType.NONE;
|
||||
if(registered) {
|
||||
//Make sure our references are pointed at the right things
|
||||
sidebarObjective = scoreboard.getObjective(ScoreboardManager.SIDEBAR_OBJECTIVE);
|
||||
powerObjective = scoreboard.getObjective(ScoreboardManager.POWER_OBJECTIVE);
|
||||
} else {
|
||||
//Register Objectives
|
||||
sidebarObjective = this.scoreboard.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy", SIDE_OBJECTIVE);
|
||||
powerObjective = this.scoreboard.registerNewObjective(ScoreboardManager.POWER_OBJECTIVE, "dummy", POWER_OBJECTIVE);
|
||||
registered = true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getPowerLevelTagsEnabled()) {
|
||||
powerObjective.setDisplayName(ScoreboardManager.TAG_POWER_LEVEL);
|
||||
@ -399,7 +414,19 @@ public class ScoreboardWrapper {
|
||||
//Unregister objective
|
||||
McMMOScoreboardObjectiveEvent unregisterEvent = callObjectiveEvent(ScoreboardObjectiveEventReason.UNREGISTER_THIS_OBJECTIVE);
|
||||
if(!unregisterEvent.isCancelled()) {
|
||||
try {
|
||||
sidebarObjective.unregister();
|
||||
} catch (IllegalStateException e) {
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
|
||||
mcMMO.p.debug("Recovering scoreboard for player: " + player.getName());
|
||||
|
||||
if(mmoPlayer.isDebugMode())
|
||||
NotificationManager.sendPlayerInformationChatOnlyPrefixed(player, "Scoreboard.Recovery");
|
||||
|
||||
initBoard(); //Start over
|
||||
Bukkit.getScheduler().runTaskLater(mcMMO.p, () -> ScoreboardManager.retryLastSkillBoard(player), 0);
|
||||
}
|
||||
}
|
||||
|
||||
//Register objective
|
||||
|
@ -1138,3 +1138,4 @@ Chat.Channel.Off=&6(&amcMMO-Chat&6) &7Your chat messages will no longer be autom
|
||||
Chat.Spy.Party=&6[&eSPY&6-&a{2}&6] &r{0} &b\u2192 &r{1}
|
||||
Broadcasts.LevelUpMilestone=&6(&amcMMO&6) {0}&7 has reached level &a{1}&7 in &3{2}&7!
|
||||
Broadcasts.PowerLevelUpMilestone=&6(&amcMMO&6) {0}&7 has reached a Power level of &a{1}&7!
|
||||
Scoreboard.Recovery=Attempting to recover mcMMO scoreboard...
|
Loading…
Reference in New Issue
Block a user