mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
Wire up XP bar settings
This commit is contained in:
parent
59c8d16374
commit
591c9e67a3
@ -111,58 +111,6 @@ public class ExperienceConfig extends ConfigValidated {
|
||||
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 */
|
||||
public double getRepairXPBase() {
|
||||
return getDoubleValue(EXPERIENCE, REPAIR, BASE1);
|
||||
|
@ -125,6 +125,27 @@ public class ConfigExperienceBars {
|
||||
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() {
|
||||
return xpBarSpecificToggles;
|
||||
}
|
||||
|
@ -42,6 +42,14 @@ public class ConfigLeveling {
|
||||
* GETTER BOILERPLATE
|
||||
*/
|
||||
|
||||
public BarColor getXPBarColor(PrimarySkillType primarySkillType) {
|
||||
return configExperienceBars.getXPBarColor(primarySkillType);
|
||||
}
|
||||
|
||||
public BarStyle getXPBarStyle(PrimarySkillType primarySkillType) {
|
||||
return configExperienceBars.getXPBarStyle(primarySkillType);
|
||||
}
|
||||
|
||||
public boolean isPartyExperienceTriggerXpBarDisplay() {
|
||||
return configExperienceBars.isPartyExperienceTriggerXpBarDisplay();
|
||||
}
|
||||
@ -70,6 +78,10 @@ public class ConfigLeveling {
|
||||
return configExperienceBars.getXpBarStyleMap();
|
||||
}
|
||||
|
||||
public boolean getXPBarToggle(PrimarySkillType primarySkillType) {
|
||||
return configExperienceBars.getXPBarToggle(primarySkillType);
|
||||
}
|
||||
|
||||
public ConfigExperienceBars getConfigExperienceBars() {
|
||||
return configExperienceBars;
|
||||
}
|
||||
|
@ -167,11 +167,11 @@ public class McMMOPlayer {
|
||||
|
||||
public void processPostXpEvent(XPGainReason xpGainReason, PrimarySkillType primarySkillType, Plugin plugin, XPGainSource xpGainSource) {
|
||||
//Updates from Party sources
|
||||
if (xpGainSource == XPGainSource.PARTY_MEMBERS && !ExperienceConfig.getInstance().isPartyExperienceBarsEnabled())
|
||||
if (xpGainSource == XPGainSource.PARTY_MEMBERS && !mcMMO.getConfigManager().getConfigLeveling().isPartyExperienceTriggerXpBarDisplay())
|
||||
return;
|
||||
|
||||
//Updates from passive sources (Alchemy, Smelting, etc...)
|
||||
if (xpGainSource == XPGainSource.PASSIVE && !ExperienceConfig.getInstance().isPassiveGainsExperienceBarsEnabled())
|
||||
if (xpGainSource == XPGainSource.PASSIVE && !mcMMO.getConfigManager().getConfigLeveling().isPassiveGainXPBars())
|
||||
return;
|
||||
|
||||
updateXPBar(primarySkillType, plugin);
|
||||
|
@ -584,7 +584,7 @@ public class BlockListener implements Listener {
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ 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;
|
||||
|
||||
@ -26,7 +27,7 @@ public class ExperienceBarManager {
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
//Init Bar
|
||||
|
@ -4,6 +4,7 @@ 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.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.boss.BarColor;
|
||||
@ -55,7 +56,7 @@ public class ExperienceBarWrapper {
|
||||
|
||||
private String getTitleTemplate() {
|
||||
//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." + niceSkillName, getLevel(), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel());
|
||||
@ -120,7 +121,7 @@ public class ExperienceBarWrapper {
|
||||
bossBar.setProgress(v);
|
||||
|
||||
//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();
|
||||
lastLevelUpdated = getLevel();
|
||||
}
|
||||
@ -148,7 +149,9 @@ public class ExperienceBarWrapper {
|
||||
}*/
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user