Wire up XP bar settings

This commit is contained in:
nossr50 2019-05-13 05:25:40 -07:00
parent 59c8d16374
commit 591c9e67a3
7 changed files with 44 additions and 59 deletions

View File

@ -111,58 +111,6 @@ public class ExperienceConfig extends ConfigValidated {
return reason; return reason;
} }
/*
* Experience Bar Stuff
*/
public boolean isPartyExperienceBarsEnabled() {
return getBooleanValue(EXPERIENCE + BARS, UPDATE, PARTY);
}
public boolean isPassiveGainsExperienceBarsEnabled() {
return getBooleanValue(EXPERIENCE + BARS, UPDATE, PASSIVE);
}
public boolean getDoExperienceBarsAlwaysUpdateTitle() {
return getBooleanValue(EXPERIENCE + BARS, THIS_MAY_CAUSE_LAG, ALWAYS + UPDATE + TITLES_WHEN_XPIS_GAINED, ENABLE) || getAddExtraDetails();
}
public boolean getAddExtraDetails() {
return getBooleanValue(EXPERIENCE + BARS, THIS_MAY_CAUSE_LAG, ALWAYS + UPDATE + TITLES_WHEN_XPIS_GAINED, EXTRA_DETAILS);
}
public boolean isExperienceBarsEnabled() {
return getBooleanValue(EXPERIENCE + BARS, ENABLE);
}
public boolean isExperienceBarEnabled(PrimarySkillType primarySkillType) {
return getBooleanValue(EXPERIENCE + BARS, StringUtils.getCapitalized(primarySkillType.toString()), ENABLE);
}
public BarColor getExperienceBarColor(PrimarySkillType primarySkillType) {
String colorValueFromConfig = getStringValue(EXPERIENCE + BARS, StringUtils.getCapitalized(primarySkillType.toString()), COLOR);
for (BarColor barColor : BarColor.values()) {
if (barColor.toString().equalsIgnoreCase(colorValueFromConfig))
return barColor;
}
//In case the value is invalid
return BarColor.WHITE;
}
public BarStyle getExperienceBarStyle(PrimarySkillType primarySkillType) {
String colorValueFromConfig = getStringValue(EXPERIENCE + BARS, StringUtils.getCapitalized(primarySkillType.toString()), BAR_STYLE);
for (BarStyle barStyle : BarStyle.values()) {
if (barStyle.toString().equalsIgnoreCase(colorValueFromConfig))
return barStyle;
}
//In case the value is invalid
return BarStyle.SOLID;
}
/* Repair */ /* Repair */
public double getRepairXPBase() { public double getRepairXPBase() {
return getDoubleValue(EXPERIENCE, REPAIR, BASE1); return getDoubleValue(EXPERIENCE, REPAIR, BASE1);

View File

@ -125,6 +125,27 @@ public class ConfigExperienceBars {
return enableXPBars; return enableXPBars;
} }
public boolean getXPBarToggle(PrimarySkillType primarySkillType) {
if(xpBarSpecificToggles.get(primarySkillType) == null)
return true;
return xpBarSpecificToggles.get(primarySkillType);
}
public BarColor getXPBarColor(PrimarySkillType primarySkillType) {
if(xpBarColorMap.get(primarySkillType) == null)
return BarColor.WHITE;
return xpBarColorMap.get(primarySkillType);
}
public BarStyle getXPBarStyle(PrimarySkillType primarySkillType) {
if(xpBarStyleMap.get(primarySkillType) == null)
return BarStyle.SEGMENTED_6;
return xpBarStyleMap.get(primarySkillType);
}
public HashMap<PrimarySkillType, Boolean> getXpBarSpecificToggles() { public HashMap<PrimarySkillType, Boolean> getXpBarSpecificToggles() {
return xpBarSpecificToggles; return xpBarSpecificToggles;
} }

View File

@ -42,6 +42,14 @@ public class ConfigLeveling {
* GETTER BOILERPLATE * GETTER BOILERPLATE
*/ */
public BarColor getXPBarColor(PrimarySkillType primarySkillType) {
return configExperienceBars.getXPBarColor(primarySkillType);
}
public BarStyle getXPBarStyle(PrimarySkillType primarySkillType) {
return configExperienceBars.getXPBarStyle(primarySkillType);
}
public boolean isPartyExperienceTriggerXpBarDisplay() { public boolean isPartyExperienceTriggerXpBarDisplay() {
return configExperienceBars.isPartyExperienceTriggerXpBarDisplay(); return configExperienceBars.isPartyExperienceTriggerXpBarDisplay();
} }
@ -70,6 +78,10 @@ public class ConfigLeveling {
return configExperienceBars.getXpBarStyleMap(); return configExperienceBars.getXpBarStyleMap();
} }
public boolean getXPBarToggle(PrimarySkillType primarySkillType) {
return configExperienceBars.getXPBarToggle(primarySkillType);
}
public ConfigExperienceBars getConfigExperienceBars() { public ConfigExperienceBars getConfigExperienceBars() {
return configExperienceBars; return configExperienceBars;
} }

View File

@ -167,11 +167,11 @@ public class McMMOPlayer {
public void processPostXpEvent(XPGainReason xpGainReason, PrimarySkillType primarySkillType, Plugin plugin, XPGainSource xpGainSource) { public void processPostXpEvent(XPGainReason xpGainReason, PrimarySkillType primarySkillType, Plugin plugin, XPGainSource xpGainSource) {
//Updates from Party sources //Updates from Party sources
if (xpGainSource == XPGainSource.PARTY_MEMBERS && !ExperienceConfig.getInstance().isPartyExperienceBarsEnabled()) if (xpGainSource == XPGainSource.PARTY_MEMBERS && !mcMMO.getConfigManager().getConfigLeveling().isPartyExperienceTriggerXpBarDisplay())
return; return;
//Updates from passive sources (Alchemy, Smelting, etc...) //Updates from passive sources (Alchemy, Smelting, etc...)
if (xpGainSource == XPGainSource.PASSIVE && !ExperienceConfig.getInstance().isPassiveGainsExperienceBarsEnabled()) if (xpGainSource == XPGainSource.PASSIVE && !mcMMO.getConfigManager().getConfigLeveling().isPassiveGainXPBars())
return; return;
updateXPBar(primarySkillType, plugin); updateXPBar(primarySkillType, plugin);

View File

@ -584,7 +584,7 @@ public class BlockListener implements Listener {
player.sendMessage("[mcMMO DEBUG] This furnace does not have a registered owner"); player.sendMessage("[mcMMO DEBUG] This furnace does not have a registered owner");
} }
if (ExperienceConfig.getInstance().isExperienceBarsEnabled()) if (mcMMO.getConfigManager().getConfigLeveling().isEnableXPBars())
player.sendMessage("[mcMMO DEBUG] XP bars are enabled, however you should check per-skill settings to make sure those are enabled."); player.sendMessage("[mcMMO DEBUG] XP bars are enabled, however you should check per-skill settings to make sure those are enabled.");
} }
} }

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.util.experience;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.ExperienceBarHideTask; import com.gmail.nossr50.runnables.skills.ExperienceBarHideTask;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -26,7 +27,7 @@ public class ExperienceBarManager {
} }
public void updateExperienceBar(PrimarySkillType primarySkillType, Plugin plugin) { public void updateExperienceBar(PrimarySkillType primarySkillType, Plugin plugin) {
if (!ExperienceConfig.getInstance().isExperienceBarsEnabled() || !ExperienceConfig.getInstance().isExperienceBarEnabled(primarySkillType)) if (!mcMMO.getConfigManager().getConfigLeveling().isEnableXPBars() || !mcMMO.getConfigManager().getConfigLeveling().getXPBarToggle(primarySkillType))
return; return;
//Init Bar //Init Bar

View File

@ -4,6 +4,7 @@ import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.boss.BarColor; import org.bukkit.boss.BarColor;
@ -55,7 +56,7 @@ public class ExperienceBarWrapper {
private String getTitleTemplate() { private String getTitleTemplate() {
//If they are using extra details //If they are using extra details
if (ExperienceConfig.getInstance().getAddExtraDetails()) if (mcMMO.getConfigManager().getConfigLeveling().isMoreDetailedXPBars())
return LocaleLoader.getString("XPBar.Complex.Template", LocaleLoader.getString("XPBar." + niceSkillName, getLevel()), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel()); return LocaleLoader.getString("XPBar.Complex.Template", LocaleLoader.getString("XPBar." + niceSkillName, getLevel()), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel());
return LocaleLoader.getString("XPBar." + niceSkillName, getLevel(), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel()); return LocaleLoader.getString("XPBar." + niceSkillName, getLevel(), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel());
@ -120,7 +121,7 @@ public class ExperienceBarWrapper {
bossBar.setProgress(v); bossBar.setProgress(v);
//Every time progress updates we need to check for a title update //Every time progress updates we need to check for a title update
if (getLevel() != lastLevelUpdated || ExperienceConfig.getInstance().getDoExperienceBarsAlwaysUpdateTitle()) { if (getLevel() != lastLevelUpdated || mcMMO.getConfigManager().getConfigLeveling().isMoreDetailedXPBars()) {
updateTitle(); updateTitle();
lastLevelUpdated = getLevel(); lastLevelUpdated = getLevel();
} }
@ -148,7 +149,9 @@ public class ExperienceBarWrapper {
}*/ }*/
private void createBossBar() { private void createBossBar() {
bossBar = mcMMOPlayer.getPlayer().getServer().createBossBar(title, ExperienceConfig.getInstance().getExperienceBarColor(primarySkillType), ExperienceConfig.getInstance().getExperienceBarStyle(primarySkillType)); bossBar = mcMMOPlayer.getPlayer().getServer().createBossBar(title,
mcMMO.getConfigManager().getConfigLeveling().getXPBarColor(primarySkillType),
mcMMO.getConfigManager().getConfigLeveling().getXPBarStyle(primarySkillType));
bossBar.addPlayer(mcMMOPlayer.getPlayer()); bossBar.addPlayer(mcMMOPlayer.getPlayer());
} }
} }