From e74bc9fd956163d106c67f6d451a42b7fcd5f2f7 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 18 Jan 2019 16:18:29 -0800 Subject: [PATCH] XP bars can now be toggled off --- .../config/experience/ExperienceConfig.java | 8 +- .../util/experience/ExperienceBarManager.java | 4 + .../util/experience/ExperienceBarWrapper.java | 1 - src/main/resources/experience.yml | 108 ++++++++++-------- 4 files changed, 72 insertions(+), 49 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java index d80ae3818..74d106228 100644 --- a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java +++ b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java @@ -254,9 +254,13 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { { return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained", false); } + + public boolean isExperienceBarsEnabled() { return config.getBoolean("Experience_Bars.Enable"); } + public boolean isExperienceBarEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Enable");} + public BarColor getExperienceBarColor(PrimarySkillType primarySkillType) { - String colorValueFromConfig = config.getString("Experience_Bars.Style."+StringUtils.getCapitalized(primarySkillType.toString())+".Color"); + String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Color"); for(BarColor barColor : BarColor.values()) { @@ -270,7 +274,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { public BarStyle getExperienceBarStyle(PrimarySkillType primarySkillType) { - String colorValueFromConfig = config.getString("Experience_Bars.Style."+StringUtils.getCapitalized(primarySkillType.toString())+".BarStyle"); + String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".BarStyle"); for(BarStyle barStyle : BarStyle.values()) { diff --git a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java index 8137af358..b8cc12cb8 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java @@ -1,5 +1,6 @@ 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; @@ -28,6 +29,9 @@ public class ExperienceBarManager { public void updateExperienceBar(PrimarySkillType primarySkillType, mcMMO plugin) { + if(!ExperienceConfig.getInstance().isExperienceBarsEnabled() || !ExperienceConfig.getInstance().isExperienceBarEnabled(primarySkillType)) + return; + //Init Bar if(experienceBars.get(primarySkillType) == null) experienceBars.put(primarySkillType, new ExperienceBarWrapper(primarySkillType, mcMMOPlayer)); diff --git a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java index cc7cd5c84..1c460be50 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java +++ b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.StringUtils; -import org.bukkit.ChatColor; import org.bukkit.Server; import org.bukkit.boss.*; import org.bukkit.entity.Player; diff --git a/src/main/resources/experience.yml b/src/main/resources/experience.yml index fc64ef781..5c10d7a98 100644 --- a/src/main/resources/experience.yml +++ b/src/main/resources/experience.yml @@ -23,56 +23,72 @@ #SOLID # The bar is one solid piece Experience_Bars: + # Turn this to false if you wanna disable XP bars + Enable: true # If you want to use a fancy edited title from the locale, then you'll probably want to turn this on, but it will make your server do a lot more work! # I recommend leaving this off! ThisMayCauseLag: AlwaysUpdateTitlesWhenXPIsGained: false - Style: - Acrobatics: - Color: PINK - BarStyle: SEGMENTED_6 - Alchemy: - Color: PURPLE - BarStyle: SEGMENTED_6 - Archery: - Color: BLUE - BarStyle: SEGMENTED_6 - Axes: - Color: BLUE - BarStyle: SEGMENTED_6 - Excavation: - Color: YELLOW - BarStyle: SEGMENTED_6 - Fishing: - Color: PURPLE - BarStyle: SEGMENTED_6 - Herbalism: - Color: GREEN - BarStyle: SEGMENTED_6 - Mining: - Color: YELLOW - BarStyle: SEGMENTED_6 - Repair: - Color: PURPLE - BarStyle: SEGMENTED_6 - Salvage: - Color: PURPLE - BarStyle: SEGMENTED_6 - Smelting: - Color: PURPLE - BarStyle: SEGMENTED_6 - Swords: - Color: BLUE - BarStyle: SEGMENTED_6 - Taming: - Color: RED - BarStyle: SEGMENTED_6 - Unarmed: - Color: BLUE - BarStyle: SEGMENTED_6 - Woodcutting: - Color: GREEN - BarStyle: SEGMENTED_6 + Acrobatics: + Enable: true + Color: PINK + BarStyle: SEGMENTED_6 + Alchemy: + Enable: true + Color: PURPLE + BarStyle: SEGMENTED_6 + Archery: + Enable: true + Color: BLUE + BarStyle: SEGMENTED_6 + Axes: + Enable: true + Color: BLUE + BarStyle: SEGMENTED_6 + Excavation: + Enable: true + Color: YELLOW + BarStyle: SEGMENTED_6 + Fishing: + Enable: true + Color: PURPLE + BarStyle: SEGMENTED_6 + Herbalism: + Enable: true + Color: GREEN + BarStyle: SEGMENTED_6 + Mining: + Enable: true + Color: YELLOW + BarStyle: SEGMENTED_6 + Repair: + Enable: true + Color: PURPLE + BarStyle: SEGMENTED_6 + Salvage: + Enable: true + Color: PURPLE + BarStyle: SEGMENTED_6 + Smelting: + Enable: true + Color: PURPLE + BarStyle: SEGMENTED_6 + Swords: + Enable: true + Color: BLUE + BarStyle: SEGMENTED_6 + Taming: + Enable: true + Color: RED + BarStyle: SEGMENTED_6 + Unarmed: + Enable: true + Color: BLUE + BarStyle: SEGMENTED_6 + Woodcutting: + Enable: true + Color: GREEN + BarStyle: SEGMENTED_6 # # Settings for XP formula ###