Fix compiler errors

This commit is contained in:
nossr50
2019-05-18 16:25:52 -07:00
parent 04b4a8e069
commit 04fb4c30fe
21 changed files with 79 additions and 433 deletions

View File

@@ -1,337 +0,0 @@
package com.gmail.nossr50.config.experience;
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.MaterialType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class ExperienceConfig extends AutoUpdateConfigLoader {
private static ExperienceConfig instance;
private ExperienceConfig() {
super("experience.yml");
validate();
}
public static ExperienceConfig getInstance() {
if (instance == null) {
instance = new ExperienceConfig();
}
return instance;
}
@Override
protected void loadKeys() {}
@Override
protected boolean validateKeys() {
List<String> reason = new ArrayList<String>();
/*
* FORMULA SETTINGS
*/
/* Curve values */
if (getMultiplier(FormulaType.EXPONENTIAL) <= 0) {
reason.add("Experience_Formula.Exponential_Values.multiplier should be greater than 0!");
}
if (getMultiplier(FormulaType.LINEAR) <= 0) {
reason.add("Experience_Formula.Linear_Values.multiplier should be greater than 0!");
}
if (getExponent(FormulaType.EXPONENTIAL) <= 0) {
reason.add("Experience_Formula.Exponential_Values.exponent should be greater than 0!");
}
/* Global modifier */
if (getExperienceGainsGlobalMultiplier() <= 0) {
reason.add("Experience_Formula.Multiplier.Global should be greater than 0!");
}
/* PVP modifier */
if (getPlayerVersusPlayerXP() < 0) {
reason.add("Experience_Formula.Multiplier.PVP should be at least 0!");
}
/* Spawned Mob modifier */
if (getSpawnedMobXpMultiplier() < 0) {
reason.add("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
}
/* Bred Mob modifier */
if (getBredMobXpMultiplier() < 0) {
reason.add("Experience_Formula.Breeding.Multiplier should be at least 0!");
}
/* Conversion */
if (getExpModifier() <= 0) {
reason.add("Conversion.Exp_Modifier should be greater than 0!");
}
/*
* XP SETTINGS
*/
/* Alchemy */
for (PotionStage potionStage : PotionStage.values()) {
if (getPotionXP(potionStage) < 0) {
reason.add("Experience_Values.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!");
}
}
/* Archery */
if (getArcheryDistanceMultiplier() < 0) {
reason.add("Experience_Values.Archery.Distance_Multiplier should be at least 0!");
}
/* Combat XP Multipliers */
if (getAnimalsXP() < 0) {
reason.add("Experience_Values.Combat.Multiplier.Animals should be at least 0!");
}
if (getDodgeXPModifier() < 0) {
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
}
if (getRollXPModifier() < 0) {
reason.add("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
}
if (getFallXPModifier() < 0) {
reason.add("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
}
/* Fishing */
// TODO: Add validation for each fish type once enum is available.
if (getFishingShakeXP() <= 0) {
reason.add("Experience_Values.Fishing.Shake should be greater than 0!");
}
/* Repair */
if (getRepairXPBase() <= 0) {
reason.add("Experience_Values.Repair.Base should be greater than 0!");
}
/* Taming */
if (getTamingXP(EntityType.WOLF) <= 0) {
reason.add("Experience_Values.Taming.Animal_Taming.Wolf should be greater than 0!");
}
if (getTamingXP(EntityType.OCELOT) <= 0) {
reason.add("Experience_Values.Taming.Animal_Taming.Ocelot should be greater than 0!");
}
return noErrorsInConfig(reason);
}
public boolean isEarlyGameBoostEnabled() { return config.getBoolean("EarlyGameBoost.Enabled", true); }
public double getEarlyGameBoostMultiplier() { return config.getDouble("EarlyGameBoost.MaxLevelMultiplier", 0.05D); }
/*
* FORMULA SETTINGS
*/
/* EXPLOIT TOGGLES */
public boolean isEndermanEndermiteFarmingPrevented() { return config.getBoolean("ExploitFix.EndermanEndermiteFarms", true); }
public boolean isPistonExploitPrevented() { return config.getBoolean("ExploitFix.Pistons", false); }
public boolean isFishingExploitingPrevented() { return config.getBoolean("ExploitFix.Fishing", true); }
public boolean isAcrobaticsExploitingPrevented() { return config.getBoolean("ExploitFix.Acrobatics", true); }
/* Curve settings */
public FormulaType getFormulaType() { return FormulaType.getFormulaType(config.getString("Experience_Formula.Curve")); }
public boolean getCumulativeCurveEnabled() { return config.getBoolean("Experience_Formula.Cumulative_Curve", false); }
/* Curve values */
public double getMultiplier(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier"); }
public int getBase(FormulaType type) { return config.getInt("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base"); }
public double getExponent(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.exponent"); }
/* Global modifier */
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience_Formula.Multiplier.Global", 1.0); }
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience_Formula.Multiplier.Global", value); }
/* PVP modifier */
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience_Formula.Multiplier.PVP", 1.0); }
/* Spawned Mob modifier */
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); }
public double getBredMobXpMultiplier() { return config.getDouble("Experience_Formula.Breeding.Multiplier", 1.0); }
/* Skill modifiers */
public double getFormulaSkillModifier(PrimarySkillType skill) { return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
/* Custom XP perk */
public double getCustomXpPerkBoost() { return config.getDouble("Experience_Formula.Custom_XP_Perk.Boost", 1.25); }
/* Diminished Returns */
public float getDiminishedReturnsCap() { return (float) config.getDouble("Dimished_Returns.Guaranteed_Minimum_Percentage", 0.05D); }
public boolean getDiminishedReturnsEnabled() { return config.getBoolean("Diminished_Returns.Enabled", false); }
public int getDiminishedReturnsThreshold(PrimarySkillType skill) { return config.getInt("Diminished_Returns.Threshold." + StringUtils.getCapitalized(skill.toString()), 20000); }
public int getDiminishedReturnsTimeInterval() { return config.getInt("Diminished_Returns.Time_Interval", 10); }
/* Conversion */
public double getExpModifier() { return config.getDouble("Conversion.Exp_Modifier", 1); }
/*
* XP SETTINGS
*/
/* General Settings */
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience_Values.PVP.Rewards", true); }
/* Combat XP Multipliers */
public double getCombatXP(EntityType entity) { return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
public double getAnimalsXP(EntityType entity) { return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"), getAnimalsXP()); }
public double getAnimalsXP() { return config.getDouble("Experience_Values.Combat.Multiplier.Animals", 1.0); }
public boolean hasCombatXP(EntityType entity) {return config.contains("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
/* Materials */
public int getXp(PrimarySkillType skill, Material data)
{
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
if (config.contains(explicitString))
return config.getInt(explicitString);
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
if (config.contains(friendlyString))
return config.getInt(friendlyString);
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
if (config.contains(wildcardString))
return config.getInt(wildcardString);
return 0;
}
/* Materials */
public int getXp(PrimarySkillType skill, BlockData data)
{
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
if (config.contains(explicitString))
return config.getInt(explicitString);
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
if (config.contains(friendlyString))
return config.getInt(friendlyString);
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
if (config.contains(wildcardString))
return config.getInt(wildcardString);
return 0;
}
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, Material data)
{
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
if (config.contains(explicitString))
return true;
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
if (config.contains(friendlyString))
return true;
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
return config.contains(wildcardString);
}
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, BlockData data)
{
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
if (config.contains(explicitString))
return true;
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
if (config.contains(friendlyString))
return true;
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
return config.contains(wildcardString);
}
/*
* Experience Bar Stuff
*/
public boolean isPartyExperienceBarsEnabled()
{
return config.getBoolean("Experience_Bars.Update.Party", true);
}
public boolean isPassiveGainsExperienceBarsEnabled()
{
return config.getBoolean("Experience_Bars.Update.Passive", true);
}
public boolean getDoExperienceBarsAlwaysUpdateTitle()
{
return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.Enable", false) || getAddExtraDetails();
}
public boolean getAddExtraDetails() { return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.ExtraDetails", false);}
public boolean isExperienceBarsEnabled() { return config.getBoolean("Experience_Bars.Enable", true); }
public boolean isExperienceBarEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Enable", true);}
public BarColor getExperienceBarColor(PrimarySkillType primarySkillType)
{
String colorValueFromConfig = config.getString("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 = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".BarStyle");
for(BarStyle barStyle : BarStyle.values())
{
if(barStyle.toString().equalsIgnoreCase(colorValueFromConfig))
return barStyle;
}
//In case the value is invalid
return BarStyle.SOLID;
}
/* Acrobatics */
public int getDodgeXPModifier() { return config.getInt("Experience_Values.Acrobatics.Dodge", 120); }
public int getRollXPModifier() { return config.getInt("Experience_Values.Acrobatics.Roll", 80); }
public int getFallXPModifier() { return config.getInt("Experience_Values.Acrobatics.Fall", 120); }
public double getFeatherFallXPModifier() { return config.getDouble("Experience_Values.Acrobatics.FeatherFall_Multiplier", 2.0); }
/* Alchemy */
public double getPotionXP(PotionStage stage) { return config.getDouble("Experience_Values.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); }
/* Archery */
public double getArcheryDistanceMultiplier() { return config.getDouble("Experience_Values.Archery.Distance_Multiplier", 0.025); }
public int getFishingShakeXP() { return config.getInt("Experience_Values.Fishing.Shake", 50); }
/* Repair */
public double getRepairXPBase() { return config.getDouble("Experience_Values.Repair.Base", 1000.0); }
public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience_Values.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
/* Taming */
public int getTamingXP(EntityType type)
{
return config.getInt("Experience_Values.Taming.Animal_Taming." + StringUtils.getPrettyEntityTypeString(type));
}
public boolean preventStoneLavaFarming() { return config.getBoolean("ExploitFix.LavaStoneAndCobbleFarming", true);}
}

View File

@@ -8,7 +8,7 @@ public class ConfigAdminNotifications {
private static final boolean SEND_ADMIN_NOTIFICATIONS_DEFAULT = true;
@Setting(value = "Send-Admin-Notifications", comment = "Send admins notifications about sensitive commands being executed" +
"\nDefault value: "+ SEND_ADMIN_NOTIFICATIONS_DEFAULT)
"\nDefault value: " + SEND_ADMIN_NOTIFICATIONS_DEFAULT)
private boolean sendAdminNotifications = SEND_ADMIN_NOTIFICATIONS_DEFAULT;
public boolean isSendAdminNotifications() {

View File

@@ -10,7 +10,7 @@ public class ConfigSectionExploitMining {
@Setting(value = "Prevent-Stone-Cobblestone-Generator-XP", comment = "Prevents cobblestone/stone formed by lava mixing with water from granting mcMMO XP." +
"\nThis can be automated so that you can stand in place with an autoclicker for easy afk Mining XP." +
"\nThis can be unwanted on a Skyblock server or otherwise, feel free to turn it off." +
"\nDefault value: "+PREVENT_STONE_GENERATOR_XP_DEFAULT)
"\nDefault value: " + PREVENT_STONE_GENERATOR_XP_DEFAULT)
private boolean preventCobblestoneStoneGeneratorXP = PREVENT_STONE_GENERATOR_XP_DEFAULT;
public boolean isPreventCobblestoneStoneGeneratorXP() {

View File

@@ -11,17 +11,17 @@ public class ConfigEventExperienceRate {
public static final boolean SEND_TITLES_FOR_EVENT_DEFAULT = true;
@Setting(value = "Show-Details-On-Player-Join", comment = "Show players info about ongoing XP rate events when they join the server." +
"\nDefault value: "+SHOW_XP_RATE_ON_JOIN_DEFAULT)
"\nDefault value: " + SHOW_XP_RATE_ON_JOIN_DEFAULT)
private boolean showXPRateInfoOnPlayerJoin = SHOW_XP_RATE_ON_JOIN_DEFAULT;
@Setting(value = "Broadcast-Event-Messages", comment = "Whether or not to broadcast info about the event to players on the server" +
"\nA broadcast is a message sent to all players connected to the server" +
"\nDefault value: "+BROADCAST_EVENT_MESSAGES_DEFAULT)
"\nDefault value: " + BROADCAST_EVENT_MESSAGES_DEFAULT)
private boolean broadcastXPRateEventMessages = BROADCAST_EVENT_MESSAGES_DEFAULT;
@Setting(value = "Send-Title-Messages", comment = "Send title messages to players for this event." +
"\nTitles are the very large text that appears in the middle of a players screen" +
"\nDefault value: "+SEND_TITLES_FOR_EVENT_DEFAULT)
"\nDefault value: " + SEND_TITLES_FOR_EVENT_DEFAULT)
private boolean sendTitleMessages = SEND_TITLES_FOR_EVENT_DEFAULT;
public boolean isShowXPRateInfoOnPlayerJoin() {

View File

@@ -68,12 +68,12 @@ public class ConfigExperienceBars {
@Setting(value = "Party-Experience-Triggers-XP-Bars", comment = "Whether or not shared XP gains from parties will trigger XP bar displays" +
"\nThis can result in a very cluttered UI even in smaller parties, I recommend leaving this off." +
"\nDefault value: "+PARTY_XP_DEFAULT)
"\nDefault value: " + PARTY_XP_DEFAULT)
private boolean partyExperienceTriggerXpBarDisplay = PARTY_XP_DEFAULT;
@Setting(value = "Passive-Experience-Trigger-XP-Bars", comment = "Whether or not XP gained from stuff like furnaces or brewing stands will trigger XP bars" +
"\nThis is on by default, but this can also cause a lot of clutter, turn it off it you'd like a cleaner UI." +
"\nDefault value: "+PASSIVE_XP_DEFAULT)
"\nDefault value: " + PASSIVE_XP_DEFAULT)
private boolean passiveGainXPBars = PASSIVE_XP_DEFAULT;
@Setting(value = "Extra-Details", comment = "Adds extra details to the XP bar, these cause a bit more performance overhead and may not look very pretty" +
@@ -81,12 +81,12 @@ public class ConfigExperienceBars {
"\nLocale key - XPBar.Complex.Template" +
"\nThe default extra detailed XP bar will include quite a few extra things, you can actually remove each thing you don't want displayed in the locale" +
"\nFor tips on editing the locale check - https://mcmmo.org/wiki/Locale" +
"\nDefault value: "+DETAILED_XP_BARS_DEFAULT)
"\nDefault value: " + DETAILED_XP_BARS_DEFAULT)
private boolean moreDetailedXPBars = DETAILED_XP_BARS_DEFAULT;
@Setting(value = "Enable-XP-Bars", comment = "Whether or not XP bars will be displayed on certain XP gains" +
"\nBy default, some XP gains do not show as they would create a lot of UI clutter, see the other options to change this" +
"\nDefault value: "+XP_BARS_DEFAULT)
"\nDefault value: " + XP_BARS_DEFAULT)
private boolean enableXPBars = XP_BARS_DEFAULT;
@Setting(value = "Skill-XP-Bar-Toggle", comment = "Turn on or off specific XP bars" +
@@ -126,21 +126,21 @@ public class ConfigExperienceBars {
}
public boolean getXPBarToggle(PrimarySkillType primarySkillType) {
if(xpBarSpecificToggles.get(primarySkillType) == null)
if (xpBarSpecificToggles.get(primarySkillType) == null)
return true;
return xpBarSpecificToggles.get(primarySkillType);
}
public BarColor getXPBarColor(PrimarySkillType primarySkillType) {
if(xpBarColorMap.get(primarySkillType) == null)
if (xpBarColorMap.get(primarySkillType) == null)
return BarColor.WHITE;
return xpBarColorMap.get(primarySkillType);
}
public BarStyle getXPBarStyle(PrimarySkillType primarySkillType) {
if(xpBarStyleMap.get(primarySkillType) == null)
if (xpBarStyleMap.get(primarySkillType) == null)
return BarStyle.SEGMENTED_6;
return xpBarStyleMap.get(primarySkillType);

View File

@@ -231,7 +231,7 @@ public class ConfigLeveling {
case SALVAGE:
return configSectionLevelCaps.getConfigSectionSkillLevelCaps().getSalvage().getLevelCap();
default:
mcMMO.p.getLogger().severe("No defined level cap for "+primarySkillType.toString()+" - Contact the mcMMO dev team!");
mcMMO.p.getLogger().severe("No defined level cap for " + primarySkillType.toString() + " - Contact the mcMMO dev team!");
return Integer.MAX_VALUE;
}
}
@@ -269,7 +269,7 @@ public class ConfigLeveling {
case SALVAGE:
return configSectionLevelCaps.getConfigSectionSkillLevelCaps().getSalvage().isLevelCapEnabled();
default:
mcMMO.p.getLogger().severe("No defined level cap for "+primarySkillType.toString()+" - Contact the mcMMO dev team!");
mcMMO.p.getLogger().severe("No defined level cap for " + primarySkillType.toString() + " - Contact the mcMMO dev team!");
return false;
}
}

View File

@@ -44,12 +44,12 @@ public class ConfigLevelingDiminishedReturns {
private static final int DIMINISHED_TIME_DEFAULT = 10;
@Setting(value = "Enabled", comment = "Setting this to true will enable Diminished Returns on XP Gains." +
"\nDefault value: "+DIMINISHED_RETURNS_DEFAULT)
"\nDefault value: " + DIMINISHED_RETURNS_DEFAULT)
private boolean diminishedReturnsEnabled = DIMINISHED_RETURNS_DEFAULT;
@Setting(value = "Time-Interval-In-Minutes", comment = "The period of time in which to measure a players XP gain and reduce gains above a threshold during that time" +
"\nPlayers will be able to gain up to the threshold of XP in this time period before having their XP drastically reduced" +
"\nDefault value: "+DIMINISHED_TIME_DEFAULT)
"\nDefault value: " + DIMINISHED_TIME_DEFAULT)
private int dimishedReturnTimeInterval = DIMINISHED_TIME_DEFAULT;
@Setting(value = "Skill-Thresholds", comment = "The amount of XP that a player can gain without penalty in the defined time interval." +
@@ -62,7 +62,7 @@ public class ConfigLevelingDiminishedReturns {
private float guaranteedMinimums = GURANTEED_MIN_DEFAULT;
public int getSkillThreshold(PrimarySkillType primarySkillType) {
if(skillThresholds.get(primarySkillType) == null)
if (skillThresholds.get(primarySkillType) == null)
return 10000;
return skillThresholds.get(primarySkillType);