Wire up party config pt 5 - Actually need to redo how I'm deserializing maps, gonna do that tomorrow

This commit is contained in:
nossr50 2019-03-17 04:44:06 -07:00
parent 80df1dd4bd
commit f299f84a6f
7 changed files with 22 additions and 20 deletions

View File

@ -4,6 +4,7 @@ import com.gmail.nossr50.config.collectionconfigs.RepairConfig;
import com.gmail.nossr50.config.collectionconfigs.SalvageConfig; import com.gmail.nossr50.config.collectionconfigs.SalvageConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.hocon.CustomEnumValueSerializer; import com.gmail.nossr50.config.hocon.CustomEnumValueSerializer;
import com.gmail.nossr50.config.hocon.HOCONUtil;
import com.gmail.nossr50.config.hocon.SerializedConfigLoader; import com.gmail.nossr50.config.hocon.SerializedConfigLoader;
import com.gmail.nossr50.config.hocon.admin.ConfigAdmin; import com.gmail.nossr50.config.hocon.admin.ConfigAdmin;
import com.gmail.nossr50.config.hocon.antiexploit.ConfigExploitPrevention; import com.gmail.nossr50.config.hocon.antiexploit.ConfigExploitPrevention;
@ -161,9 +162,6 @@ public final class ConfigManager {
configSuperAbilities = new SerializedConfigLoader<>(ConfigSuperAbilities.class, "skill_super_abilities.conf", null); configSuperAbilities = new SerializedConfigLoader<>(ConfigSuperAbilities.class, "skill_super_abilities.conf", null);
configAdmin = new SerializedConfigLoader<>(ConfigAdmin.class, "admin.conf", null); configAdmin = new SerializedConfigLoader<>(ConfigAdmin.class, "admin.conf", null);
mcMMO.p.getLogger().info("Value of Default from item map: " + configParty.getConfig().getPartyItemShare().getItemShareMap().get("DEFAULT"));
mcMMO.p.getLogger().info("Value of Default keyset from item map: " + configParty.getConfig().getPartyItemShare().getItemShareMap().keySet().size());
//Assign Maps //Assign Maps
partyItemWeights = Maps.newHashMap(configParty.getConfig().getPartyItemShare().getItemShareMap()); //Item Share Weights partyItemWeights = Maps.newHashMap(configParty.getConfig().getPartyItemShare().getItemShareMap()); //Item Share Weights
partyFeatureUnlocks = Maps.newHashMap(configParty.getConfig().getPartyXP().getPartyLevel().getPartyFeatureUnlockMap()); //Party Progression partyFeatureUnlocks = Maps.newHashMap(configParty.getConfig().getPartyXP().getPartyLevel().getPartyFeatureUnlockMap()); //Party Progression
@ -419,4 +417,12 @@ public final class ConfigManager {
public ConfigSuperAbilities getConfigSuperAbilities() { public ConfigSuperAbilities getConfigSuperAbilities() {
return configSuperAbilities.getConfig(); return configSuperAbilities.getConfig();
} }
public HashMap<String, Integer> getPartyItemWeights() {
return partyItemWeights;
}
public HashMap<String, Integer> getPartyFeatureUnlocks() {
return partyFeatureUnlocks;
}
} }

View File

@ -17,7 +17,6 @@ public class ConfigSectionPartyItemWeights {
static { static {
ITEM_WEIGHT_MAP_DEFAULT = new HashMap<>(); ITEM_WEIGHT_MAP_DEFAULT = new HashMap<>();
ITEM_WEIGHT_MAP_DEFAULT.put("Default", 5);
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(QUARTZ), 200); ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(QUARTZ), 200);
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(NETHER_QUARTZ_ORE), 200); ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(NETHER_QUARTZ_ORE), 200);
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(EMERALD_ORE), 150); ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(EMERALD_ORE), 150);

View File

@ -1,6 +1,8 @@
package com.gmail.nossr50.datatypes.party; package com.gmail.nossr50.datatypes.party;
import com.gmail.nossr50.config.hocon.HOCONUtil;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -25,7 +27,7 @@ public enum ItemShareType {
else if (ItemUtils.isWoodcuttingDrop(itemStack)) { else if (ItemUtils.isWoodcuttingDrop(itemStack)) {
return WOODCUTTING; return WOODCUTTING;
} }
else if (ItemUtils.isMiscDrop(itemStack)) { else if (mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(HOCONUtil.serializeENUMName(itemStack.getType().toString())) != null) {
return MISC; return MISC;
} }

View File

@ -138,7 +138,6 @@ public class mcMMO extends JavaPlugin {
registerCustomRecipes(); registerCustomRecipes();
PartyManager.loadParties(); PartyManager.loadParties();
PartyManager.reloadPartyFeatureHashMap();
formulaManager = new FormulaManager(); formulaManager = new FormulaManager();
holidayManager = new HolidayManager(); holidayManager = new HolidayManager();

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.party; package com.gmail.nossr50.party;
import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.hocon.HOCONUtil;
import com.gmail.nossr50.datatypes.chat.ChatMode; import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.party.*; import com.gmail.nossr50.datatypes.party.*;
@ -28,18 +29,9 @@ public final class PartyManager {
private static String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml"; private static String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
private static List<Party> parties = new ArrayList<Party>(); private static List<Party> parties = new ArrayList<Party>();
private static File partyFile = new File(partiesFilePath); private static File partyFile = new File(partiesFilePath);
private static HashMap<PartyFeature, Integer> partyFeatureUnlockMap;
private PartyManager() {} private PartyManager() {}
/**
* Sets the unlock feature map for parties to the currently loaded hash map representation from the User's Config File
*/
public static void reloadPartyFeatureHashMap()
{
partyFeatureUnlockMap = mcMMO.getPartyLevelSettings().getPartyFeatureUnlockMap();
}
/** /**
* Grab the appropriate unlock level for a party feature * Grab the appropriate unlock level for a party feature
* @param partyFeature target party feature * @param partyFeature target party feature
@ -47,7 +39,10 @@ public final class PartyManager {
*/ */
public static int getPartyFeatureUnlockLevel(PartyFeature partyFeature) public static int getPartyFeatureUnlockLevel(PartyFeature partyFeature)
{ {
return partyFeatureUnlockMap.get(partyFeature); if(mcMMO.getConfigManager().getPartyFeatureUnlocks().get(HOCONUtil.serializeENUMName(partyFeature.toString())) == null)
return 0;
else
return mcMMO.getConfigManager().getPartyFeatureUnlocks().get(HOCONUtil.serializeENUMName(partyFeature.toString()));
} }
/** /**

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.party; package com.gmail.nossr50.party;
import com.gmail.nossr50.config.hocon.HOCONUtil;
import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.experience.XPGainSource; import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.party.ItemShareType; import com.gmail.nossr50.datatypes.party.ItemShareType;
@ -146,10 +147,10 @@ public final class ShareHandler {
} }
public static int getItemWeight(Material material) { public static int getItemWeight(Material material) {
if(mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(material) == null) if(mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(HOCONUtil.serializeENUMName(material.toString())) == null)
return 5; return 5;
else else
return mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(material); return mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(HOCONUtil.serializeENUMName(material.toString()));
} }
public static XPGainReason getSharedXpGainReason(XPGainReason xpGainReason) { public static XPGainReason getSharedXpGainReason(XPGainReason xpGainReason) {

View File

@ -1,7 +1,7 @@
package com.gmail.nossr50.util; package com.gmail.nossr50.util;
import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.party.ItemWeightConfig; import com.gmail.nossr50.config.hocon.HOCONUtil;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -747,7 +747,7 @@ public final class ItemUtils {
* @return true if the item is a miscellaneous drop, false otherwise * @return true if the item is a miscellaneous drop, false otherwise
*/ */
public static boolean isMiscDrop(ItemStack item) { public static boolean isMiscDrop(ItemStack item) {
return ItemWeightConfig.getInstance().getMiscItems().contains(item.getType()); return mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(HOCONUtil.serializeENUMName(item.getType().toString())) != null;
} }
public static boolean isMcMMOItem(ItemStack item) { public static boolean isMcMMOItem(ItemStack item) {