mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Featherboard compatibility
This commit is contained in:
parent
fc3e580550
commit
7c8e14fd74
@ -1,5 +1,7 @@
|
|||||||
Version 2.1.182
|
Version 2.1.182
|
||||||
Fixed a NPE with Scoreboards enabled when trying to update scoreboards
|
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)
|
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
|
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
|
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 FixedMetadataValue playerMetadata;
|
||||||
private final String playerName;
|
private final String playerName;
|
||||||
|
|
||||||
|
private PrimarySkillType lastSkillShownScoreboard = PrimarySkillType.values()[0];
|
||||||
|
|
||||||
public McMMOPlayer(Player player, PlayerProfile profile) {
|
public McMMOPlayer(Player player, PlayerProfile profile) {
|
||||||
this.playerName = player.getName();
|
this.playerName = player.getName();
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
@ -186,6 +188,14 @@ public class McMMOPlayer implements Identified {
|
|||||||
experienceBarManager.hideExperienceBar(primarySkillType);
|
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)
|
public void processPostXpEvent(PrimarySkillType primarySkillType, Plugin plugin, XPGainSource xpGainSource)
|
||||||
{
|
{
|
||||||
//Check if they've reached the power level cap just now
|
//Check if they've reached the power level cap just now
|
||||||
|
@ -285,6 +285,9 @@ public class ScoreboardManager {
|
|||||||
// **** Setup methods **** //
|
// **** Setup methods **** //
|
||||||
|
|
||||||
public static void enablePlayerSkillScoreboard(Player player, PrimarySkillType skill) {
|
public static void enablePlayerSkillScoreboard(Player player, PrimarySkillType skill) {
|
||||||
|
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||||
|
mmoPlayer.setLastSkillShownScoreboard(skill);
|
||||||
|
|
||||||
ScoreboardWrapper wrapper = getWrapper(player);
|
ScoreboardWrapper wrapper = getWrapper(player);
|
||||||
|
|
||||||
if(wrapper == null) {
|
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) {
|
public static void enablePlayerSkillLevelUpScoreboard(Player player, PrimarySkillType skill) {
|
||||||
ScoreboardWrapper wrapper = getWrapper(player);
|
ScoreboardWrapper wrapper = getWrapper(player);
|
||||||
|
|
||||||
@ -528,8 +550,7 @@ public class ScoreboardManager {
|
|||||||
return mcMMO.p.getServer().getScoreboardManager();
|
return mcMMO.p.getServer().getScoreboardManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void changeScoreboard(ScoreboardWrapper wrapper, int displayTime) {
|
||||||
private static void changeScoreboard(ScoreboardWrapper wrapper, int displayTime) {
|
|
||||||
if (displayTime == -1) {
|
if (displayTime == -1) {
|
||||||
wrapper.showBoardWithNoRevert();
|
wrapper.showBoardWithNoRevert();
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,11 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||||
import com.gmail.nossr50.util.Misc;
|
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.player.UserManager;
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType;
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
@ -43,7 +45,7 @@ public class ScoreboardWrapper {
|
|||||||
// Internal usage variables (should exist)
|
// Internal usage variables (should exist)
|
||||||
private SidebarType sidebarType;
|
private SidebarType sidebarType;
|
||||||
private Objective sidebarObjective;
|
private Objective sidebarObjective;
|
||||||
private final Objective powerObjective;
|
private Objective powerObjective;
|
||||||
|
|
||||||
// Parameter variables (May be null / invalid)
|
// Parameter variables (May be null / invalid)
|
||||||
private Scoreboard oldBoard = null;
|
private Scoreboard oldBoard = null;
|
||||||
@ -51,14 +53,27 @@ public class ScoreboardWrapper {
|
|||||||
public PrimarySkillType targetSkill = null;
|
public PrimarySkillType targetSkill = null;
|
||||||
private PlayerProfile targetProfile = null;
|
private PlayerProfile targetProfile = null;
|
||||||
public int leaderboardPage = -1;
|
public int leaderboardPage = -1;
|
||||||
|
private boolean registered = false;
|
||||||
|
|
||||||
public ScoreboardWrapper(Player player, Scoreboard scoreboard) {
|
public ScoreboardWrapper(Player player, Scoreboard scoreboard) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.playerName = player.getName();
|
this.playerName = player.getName();
|
||||||
this.scoreboard = scoreboard;
|
this.scoreboard = scoreboard;
|
||||||
|
initBoard();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initBoard() {
|
||||||
sidebarType = SidebarType.NONE;
|
sidebarType = SidebarType.NONE;
|
||||||
sidebarObjective = this.scoreboard.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy", SIDE_OBJECTIVE);
|
if(registered) {
|
||||||
powerObjective = this.scoreboard.registerNewObjective(ScoreboardManager.POWER_OBJECTIVE, "dummy", POWER_OBJECTIVE);
|
//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()) {
|
if (Config.getInstance().getPowerLevelTagsEnabled()) {
|
||||||
powerObjective.setDisplayName(ScoreboardManager.TAG_POWER_LEVEL);
|
powerObjective.setDisplayName(ScoreboardManager.TAG_POWER_LEVEL);
|
||||||
@ -399,7 +414,19 @@ public class ScoreboardWrapper {
|
|||||||
//Unregister objective
|
//Unregister objective
|
||||||
McMMOScoreboardObjectiveEvent unregisterEvent = callObjectiveEvent(ScoreboardObjectiveEventReason.UNREGISTER_THIS_OBJECTIVE);
|
McMMOScoreboardObjectiveEvent unregisterEvent = callObjectiveEvent(ScoreboardObjectiveEventReason.UNREGISTER_THIS_OBJECTIVE);
|
||||||
if(!unregisterEvent.isCancelled()) {
|
if(!unregisterEvent.isCancelled()) {
|
||||||
sidebarObjective.unregister();
|
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
|
//Register objective
|
||||||
|
@ -1137,4 +1137,5 @@ Chat.Channel.On=&6(&amcMMO-Chat&6) &eYour chat messages will now be automaticall
|
|||||||
Chat.Channel.Off=&6(&amcMMO-Chat&6) &7Your chat messages will no longer be automatically delivered to specific chat channels.
|
Chat.Channel.Off=&6(&amcMMO-Chat&6) &7Your chat messages will no longer be automatically delivered to specific chat channels.
|
||||||
Chat.Spy.Party=&6[&eSPY&6-&a{2}&6] &r{0} &b\u2192 &r{1}
|
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.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!
|
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