mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-26 18:47:57 +01:00
Avoid race conditions
This commit is contained in:
parent
4ab688b302
commit
48a3621ac6
@ -206,6 +206,13 @@ public final class ConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initSerializedConfigs() {
|
private void initSerializedConfigs() {
|
||||||
|
//There's some race conditions here because mcMMO is goddamn spaghetti mess, language has to load first
|
||||||
|
configLanguage = new SerializedConfigLoader<>(ConfigLanguage.class, "language.conf", "Language", null);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* No more race conditions
|
||||||
|
*/
|
||||||
|
|
||||||
configDatabase = new SerializedConfigLoader<>(ConfigDatabase.class, "database_settings.conf", "Database", null);
|
configDatabase = new SerializedConfigLoader<>(ConfigDatabase.class, "database_settings.conf", "Database", null);
|
||||||
configScoreboard = new SerializedConfigLoader<>(ConfigScoreboard.class, "scoreboard.conf", "Scoreboard", null);
|
configScoreboard = new SerializedConfigLoader<>(ConfigScoreboard.class, "scoreboard.conf", "Scoreboard", null);
|
||||||
configLeveling = new SerializedConfigLoader<>(ConfigLeveling.class, "player_leveling.conf", "Player-Leveling", null);
|
configLeveling = new SerializedConfigLoader<>(ConfigLeveling.class, "player_leveling.conf", "Player-Leveling", null);
|
||||||
@ -218,7 +225,6 @@ public final class ConfigManager {
|
|||||||
configAutomatedBackups = new SerializedConfigLoader<>(ConfigAutomatedBackups.class, "automated_backups.conf", "Automated-Backups", null);
|
configAutomatedBackups = new SerializedConfigLoader<>(ConfigAutomatedBackups.class, "automated_backups.conf", "Automated-Backups", null);
|
||||||
configCommands = new SerializedConfigLoader<>(ConfigCommands.class, "commands.conf", "Commands", null);
|
configCommands = new SerializedConfigLoader<>(ConfigCommands.class, "commands.conf", "Commands", null);
|
||||||
configItems = new SerializedConfigLoader<>(ConfigItems.class, "custom_items.conf", "Items", null);
|
configItems = new SerializedConfigLoader<>(ConfigItems.class, "custom_items.conf", "Items", null);
|
||||||
configLanguage = new SerializedConfigLoader<>(ConfigLanguage.class, "language.conf", "Language", null);
|
|
||||||
configParticles = new SerializedConfigLoader<>(ConfigParticles.class, "particle_spawning.conf", "Particles", null);
|
configParticles = new SerializedConfigLoader<>(ConfigParticles.class, "particle_spawning.conf", "Particles", null);
|
||||||
configParty = new SerializedConfigLoader<>(ConfigParty.class, "party.conf", "Party", null);
|
configParty = new SerializedConfigLoader<>(ConfigParty.class, "party.conf", "Party", null);
|
||||||
configNotifications = new SerializedConfigLoader<>(ConfigNotifications.class, "alerts_and_notifications.conf", "Notifications", null);
|
configNotifications = new SerializedConfigLoader<>(ConfigNotifications.class, "alerts_and_notifications.conf", "Notifications", null);
|
||||||
|
@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.experience.CustomXPPerk;
|
|||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.google.common.reflect.TypeResolver;
|
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import ninja.leaping.configurate.ConfigurationNode;
|
import ninja.leaping.configurate.ConfigurationNode;
|
||||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||||
|
@ -101,7 +101,15 @@ public class SerializedConfigLoader<T> {
|
|||||||
.setDefaultOptions(configurationOptions)
|
.setDefaultOptions(configurationOptions)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
//Catch errors
|
||||||
|
try {
|
||||||
this.configMapper = ObjectMapper.forClass(clazz).bindToNew();
|
this.configMapper = ObjectMapper.forClass(clazz).bindToNew();
|
||||||
|
} catch (ObjectMappingException e) {
|
||||||
|
if(e.getMessage() != null)
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
reload();
|
reload();
|
||||||
save();
|
save();
|
||||||
|
@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.experience.CustomXPPerk;
|
|||||||
import ninja.leaping.configurate.objectmapping.Setting;
|
import ninja.leaping.configurate.objectmapping.Setting;
|
||||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ public class ConfigExperience {
|
|||||||
* BOILER PLATE GETTERS
|
* BOILER PLATE GETTERS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public HashSet<CustomXPPerk> getCustomXPBoosts() {
|
public ArrayList<CustomXPPerk> getCustomXPBoosts() {
|
||||||
return configExperienceCustomBoosts.getCustomXPBoosts();
|
return configExperienceCustomBoosts.getCustomXPBoosts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,15 +5,15 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
|||||||
import ninja.leaping.configurate.objectmapping.Setting;
|
import ninja.leaping.configurate.objectmapping.Setting;
|
||||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
public class ConfigExperienceCustomBoosts {
|
public class ConfigExperienceCustomBoosts {
|
||||||
|
|
||||||
private static final HashSet<CustomXPPerk> CUSTOM_BOOST_SET_DEFAULT;
|
private static final ArrayList<CustomXPPerk> CUSTOM_BOOST_SET_DEFAULT;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
CUSTOM_BOOST_SET_DEFAULT = new HashSet<>();
|
CUSTOM_BOOST_SET_DEFAULT = new ArrayList<>();
|
||||||
CustomXPPerk customXPPerk = new CustomXPPerk("examplecustomxpperk");
|
CustomXPPerk customXPPerk = new CustomXPPerk("examplecustomxpperk");
|
||||||
customXPPerk.setCustomXPValue(PrimarySkillType.MINING, 13.37f);
|
customXPPerk.setCustomXPValue(PrimarySkillType.MINING, 13.37f);
|
||||||
customXPPerk.setCustomXPValue(PrimarySkillType.WOODCUTTING, 4.0f);
|
customXPPerk.setCustomXPValue(PrimarySkillType.WOODCUTTING, 4.0f);
|
||||||
@ -23,9 +23,9 @@ public class ConfigExperienceCustomBoosts {
|
|||||||
@Setting(value = "Custom-Global-XP-Permissions", comment = "You can give custom global xp perks to players by adding 'mcmmo.customperks.xp.<PERK NAME HERE>' to your players" +
|
@Setting(value = "Custom-Global-XP-Permissions", comment = "You can give custom global xp perks to players by adding 'mcmmo.customperks.xp.<PERK NAME HERE>' to your players" +
|
||||||
"\nEnter the name of a permission node and the value of the XP boost that permission node should have." +
|
"\nEnter the name of a permission node and the value of the XP boost that permission node should have." +
|
||||||
"\nPlayers do not benefit from custom xp perks without being assigned positive permission nodes for said xp perks")
|
"\nPlayers do not benefit from custom xp perks without being assigned positive permission nodes for said xp perks")
|
||||||
private HashSet<CustomXPPerk> customXPBoosts = CUSTOM_BOOST_SET_DEFAULT;
|
private ArrayList<CustomXPPerk> customXPBoosts = CUSTOM_BOOST_SET_DEFAULT;
|
||||||
|
|
||||||
public HashSet<CustomXPPerk> getCustomXPBoosts() {
|
public ArrayList<CustomXPPerk> getCustomXPBoosts() {
|
||||||
return customXPBoosts;
|
return customXPBoosts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,26 +3,34 @@ package com.gmail.nossr50.config.hocon.experience;
|
|||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import ninja.leaping.configurate.objectmapping.Setting;
|
import ninja.leaping.configurate.objectmapping.Setting;
|
||||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
|
import static com.gmail.nossr50.datatypes.skills.PrimarySkillType.*;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
public class ConfigExperienceSkillMultiplier {
|
public class ConfigExperienceSkillMultiplier {
|
||||||
|
|
||||||
private static final HashMap<PrimarySkillType, Double> SKILL_GLOBAL_MULT_DEFAULT;
|
private static final HashMap<PrimarySkillType, Float> SKILL_GLOBAL_MULT_DEFAULT;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SKILL_GLOBAL_MULT_DEFAULT = new HashMap<>();
|
SKILL_GLOBAL_MULT_DEFAULT = new HashMap<>();
|
||||||
for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {
|
SKILL_GLOBAL_MULT_DEFAULT.put(ACROBATICS, 1.0f);
|
||||||
if (primarySkillType.isChildSkill())
|
SKILL_GLOBAL_MULT_DEFAULT.put(ALCHEMY, 1.0f);
|
||||||
continue;
|
SKILL_GLOBAL_MULT_DEFAULT.put(ARCHERY, 1.0f);
|
||||||
|
SKILL_GLOBAL_MULT_DEFAULT.put(AXES, 1.0f);
|
||||||
SKILL_GLOBAL_MULT_DEFAULT.put(primarySkillType, 1.0D);
|
SKILL_GLOBAL_MULT_DEFAULT.put(EXCAVATION, 1.0f);
|
||||||
}
|
SKILL_GLOBAL_MULT_DEFAULT.put(FISHING, 1.0f);
|
||||||
|
SKILL_GLOBAL_MULT_DEFAULT.put(HERBALISM, 1.0f);
|
||||||
|
SKILL_GLOBAL_MULT_DEFAULT.put(MINING, 1.0f);
|
||||||
|
SKILL_GLOBAL_MULT_DEFAULT.put(REPAIR, 1.0f);
|
||||||
|
SKILL_GLOBAL_MULT_DEFAULT.put(SWORDS, 1.0f);
|
||||||
|
SKILL_GLOBAL_MULT_DEFAULT.put(TAMING, 1.0f);
|
||||||
|
SKILL_GLOBAL_MULT_DEFAULT.put(UNARMED, 1.0f);
|
||||||
|
SKILL_GLOBAL_MULT_DEFAULT.put(WOODCUTTING, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Setting(value = "Skill-XP-Multipliers")
|
@Setting(value = "Skill-XP-Multipliers")
|
||||||
private HashMap<PrimarySkillType, Double> perSkillGlobalMultiplier = SKILL_GLOBAL_MULT_DEFAULT;
|
private HashMap<PrimarySkillType, Float> perSkillGlobalMultiplier = SKILL_GLOBAL_MULT_DEFAULT;
|
||||||
|
|
||||||
public double getSkillGlobalMultiplier(PrimarySkillType primarySkillType) {
|
public double getSkillGlobalMultiplier(PrimarySkillType primarySkillType) {
|
||||||
return perSkillGlobalMultiplier.get(primarySkillType);
|
return perSkillGlobalMultiplier.get(primarySkillType);
|
||||||
|
@ -11,16 +11,24 @@ import java.util.HashMap;
|
|||||||
public class ConfigExperienceFormula {
|
public class ConfigExperienceFormula {
|
||||||
|
|
||||||
public static final boolean CUMULATIVE_CURVE_DEFAULT = false;
|
public static final boolean CUMULATIVE_CURVE_DEFAULT = false;
|
||||||
private static final HashMap<PrimarySkillType, Double> SKILL_FORMULA_MODIFIER_DEFAULT;
|
private static final HashMap<PrimarySkillType, Float> SKILL_FORMULA_MODIFIER_DEFAULT;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SKILL_FORMULA_MODIFIER_DEFAULT = new HashMap<>();
|
SKILL_FORMULA_MODIFIER_DEFAULT = new HashMap<>();
|
||||||
for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {
|
//TODO: This code is causing compiler issues
|
||||||
if (primarySkillType.isChildSkill())
|
SKILL_FORMULA_MODIFIER_DEFAULT.put(PrimarySkillType.ACROBATICS, 1.0f);
|
||||||
continue;
|
SKILL_FORMULA_MODIFIER_DEFAULT.put(PrimarySkillType.ALCHEMY, 1.0f);
|
||||||
|
SKILL_FORMULA_MODIFIER_DEFAULT.put(PrimarySkillType.AXES, 1.0f);
|
||||||
SKILL_FORMULA_MODIFIER_DEFAULT.put(primarySkillType, 1.0D);
|
SKILL_FORMULA_MODIFIER_DEFAULT.put(PrimarySkillType.ARCHERY, 1.0f);
|
||||||
}
|
SKILL_FORMULA_MODIFIER_DEFAULT.put(PrimarySkillType.EXCAVATION, 1.0f);
|
||||||
|
SKILL_FORMULA_MODIFIER_DEFAULT.put(PrimarySkillType.FISHING, 1.0f);
|
||||||
|
SKILL_FORMULA_MODIFIER_DEFAULT.put(PrimarySkillType.HERBALISM, 1.0f);
|
||||||
|
SKILL_FORMULA_MODIFIER_DEFAULT.put(PrimarySkillType.MINING, 1.0f);
|
||||||
|
SKILL_FORMULA_MODIFIER_DEFAULT.put(PrimarySkillType.REPAIR, 1.0f);
|
||||||
|
SKILL_FORMULA_MODIFIER_DEFAULT.put(PrimarySkillType.SWORDS, 1.0f);
|
||||||
|
SKILL_FORMULA_MODIFIER_DEFAULT.put(PrimarySkillType.TAMING, 1.0f);
|
||||||
|
SKILL_FORMULA_MODIFIER_DEFAULT.put(PrimarySkillType.UNARMED, 1.0f);
|
||||||
|
SKILL_FORMULA_MODIFIER_DEFAULT.put(PrimarySkillType.WOODCUTTING, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Setting(value = "Player-XP-Formula-Type", comment = "Determines which formula is used to determine XP needed to level" +
|
@Setting(value = "Player-XP-Formula-Type", comment = "Determines which formula is used to determine XP needed to level" +
|
||||||
@ -42,13 +50,13 @@ public class ConfigExperienceFormula {
|
|||||||
|
|
||||||
@Setting(value = "Skill-Formula-Multipliers", comment = "The end result of how much XP is needed to level is determined by multiplying against this value" +
|
@Setting(value = "Skill-Formula-Multipliers", comment = "The end result of how much XP is needed to level is determined by multiplying against this value" +
|
||||||
"\nHigher values will make skills take longer to level, lower values will decrease time to level instead.")
|
"\nHigher values will make skills take longer to level, lower values will decrease time to level instead.")
|
||||||
private HashMap<PrimarySkillType, Double> skillXpModifier = SKILL_FORMULA_MODIFIER_DEFAULT;
|
private HashMap<PrimarySkillType, Float> skillXpModifier = SKILL_FORMULA_MODIFIER_DEFAULT;
|
||||||
|
|
||||||
public FormulaType getFormulaType() {
|
public FormulaType getFormulaType() {
|
||||||
return formulaType;
|
return formulaType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getSkillXpFormulaModifier(PrimarySkillType primarySkillType) {
|
public float getSkillXpFormulaModifier(PrimarySkillType primarySkillType) {
|
||||||
return skillXpModifier.get(primarySkillType);
|
return skillXpModifier.get(primarySkillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +72,7 @@ public class ConfigExperienceFormula {
|
|||||||
return configExperienceFormulaExponential;
|
return configExperienceFormulaExponential;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMultiplier(FormulaType formulaType) {
|
public float getMultiplier(FormulaType formulaType) {
|
||||||
switch (formulaType) {
|
switch (formulaType) {
|
||||||
case LINEAR:
|
case LINEAR:
|
||||||
return getLinearMultiplier();
|
return getLinearMultiplier();
|
||||||
@ -90,11 +98,11 @@ public class ConfigExperienceFormula {
|
|||||||
return configExperienceFormulaExponential.getExponentialBaseModifier();
|
return configExperienceFormulaExponential.getExponentialBaseModifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getExponentialMultiplier() {
|
public float getExponentialMultiplier() {
|
||||||
return configExperienceFormulaExponential.getExponentialMultiplier();
|
return configExperienceFormulaExponential.getExponentialMultiplier();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getExponentialExponent() {
|
public float getExponentialExponent() {
|
||||||
return configExperienceFormulaExponential.getExponentialExponent();
|
return configExperienceFormulaExponential.getExponentialExponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +110,7 @@ public class ConfigExperienceFormula {
|
|||||||
return configExperienceFormulaLinear.getLinearBaseModifier();
|
return configExperienceFormulaLinear.getLinearBaseModifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getLinearMultiplier() {
|
public float getLinearMultiplier() {
|
||||||
return configExperienceFormulaLinear.getLinearMultiplier();
|
return configExperienceFormulaLinear.getLinearMultiplier();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,27 +7,27 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
|||||||
public class ConfigExperienceFormulaExponential {
|
public class ConfigExperienceFormulaExponential {
|
||||||
|
|
||||||
private static final int BASE_DEFAULT = 2000;
|
private static final int BASE_DEFAULT = 2000;
|
||||||
private static final double MULTIPLIER_DEFAULT = 0.1;
|
private static final float MULTIPLIER_DEFAULT = 0.1f;
|
||||||
private static final double EXPONENT_DEFAULT = 1.80;
|
private static final float EXPONENT_DEFAULT = 1.80f;
|
||||||
|
|
||||||
@Setting(value = "Base-Amount", comment = "Default value: " + BASE_DEFAULT)
|
@Setting(value = "Base-Amount", comment = "Default value: " + BASE_DEFAULT)
|
||||||
private int baseModifier = BASE_DEFAULT;
|
private int baseModifier = BASE_DEFAULT;
|
||||||
|
|
||||||
@Setting(value = "Multiplier", comment = "Default value: " + MULTIPLIER_DEFAULT)
|
@Setting(value = "Multiplier", comment = "Default value: " + MULTIPLIER_DEFAULT)
|
||||||
private double multiplier = MULTIPLIER_DEFAULT;
|
private float multiplier = MULTIPLIER_DEFAULT;
|
||||||
|
|
||||||
@Setting(value = "Exponent", comment = "Default value: " + EXPONENT_DEFAULT)
|
@Setting(value = "Exponent", comment = "Default value: " + EXPONENT_DEFAULT)
|
||||||
private double exponent = EXPONENT_DEFAULT;
|
private float exponent = EXPONENT_DEFAULT;
|
||||||
|
|
||||||
public int getExponentialBaseModifier() {
|
public int getExponentialBaseModifier() {
|
||||||
return baseModifier;
|
return baseModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getExponentialMultiplier() {
|
public float getExponentialMultiplier() {
|
||||||
return multiplier;
|
return multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getExponentialExponent() {
|
public float getExponentialExponent() {
|
||||||
return exponent;
|
return exponent;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,19 +7,19 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
|||||||
public class ConfigExperienceFormulaLinear {
|
public class ConfigExperienceFormulaLinear {
|
||||||
|
|
||||||
private static final int BASE_DEFAULT = 1020;
|
private static final int BASE_DEFAULT = 1020;
|
||||||
private static final double MULTIPLIER_DEFAULT = 20.0D;
|
private static final float MULTIPLIER_DEFAULT = 20.0F;
|
||||||
|
|
||||||
@Setting(value = "Base-Amount", comment = "Default value: " + BASE_DEFAULT)
|
@Setting(value = "Base-Amount", comment = "Default value: " + BASE_DEFAULT)
|
||||||
private int baseModifier = BASE_DEFAULT;
|
private int baseModifier = BASE_DEFAULT;
|
||||||
|
|
||||||
@Setting(value = "Multiplier", comment = "Default value: " + MULTIPLIER_DEFAULT)
|
@Setting(value = "Multiplier", comment = "Default value: " + MULTIPLIER_DEFAULT)
|
||||||
private double multiplier = MULTIPLIER_DEFAULT;
|
private float multiplier = MULTIPLIER_DEFAULT;
|
||||||
|
|
||||||
public int getLinearBaseModifier() {
|
public int getLinearBaseModifier() {
|
||||||
return baseModifier;
|
return baseModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getLinearMultiplier() {
|
public float getLinearMultiplier() {
|
||||||
return multiplier;
|
return multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ import org.bukkit.enchantments.Enchantment;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import sun.security.krb5.Config;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
Loading…
Reference in New Issue
Block a user