From f299f84a6f32a20248088926cb574b1d2228d47b Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 17 Mar 2019 04:44:06 -0700 Subject: [PATCH] Wire up party config pt 5 - Actually need to redo how I'm deserializing maps, gonna do that tomorrow --- .../com/gmail/nossr50/config/ConfigManager.java | 12 +++++++++--- .../party/ConfigSectionPartyItemWeights.java | 1 - .../nossr50/datatypes/party/ItemShareType.java | 4 +++- src/main/java/com/gmail/nossr50/mcMMO.java | 1 - .../com/gmail/nossr50/party/PartyManager.java | 15 +++++---------- .../com/gmail/nossr50/party/ShareHandler.java | 5 +++-- .../java/com/gmail/nossr50/util/ItemUtils.java | 4 ++-- 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/ConfigManager.java b/src/main/java/com/gmail/nossr50/config/ConfigManager.java index 82dcb7dee..44f5c4126 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigManager.java @@ -4,6 +4,7 @@ import com.gmail.nossr50.config.collectionconfigs.RepairConfig; import com.gmail.nossr50.config.collectionconfigs.SalvageConfig; import com.gmail.nossr50.config.experience.ExperienceConfig; 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.admin.ConfigAdmin; 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); 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 partyItemWeights = Maps.newHashMap(configParty.getConfig().getPartyItemShare().getItemShareMap()); //Item Share Weights partyFeatureUnlocks = Maps.newHashMap(configParty.getConfig().getPartyXP().getPartyLevel().getPartyFeatureUnlockMap()); //Party Progression @@ -419,4 +417,12 @@ public final class ConfigManager { public ConfigSuperAbilities getConfigSuperAbilities() { return configSuperAbilities.getConfig(); } + + public HashMap getPartyItemWeights() { + return partyItemWeights; + } + + public HashMap getPartyFeatureUnlocks() { + return partyFeatureUnlocks; + } } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyItemWeights.java b/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyItemWeights.java index 30f8fc8a2..daf9b71ee 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyItemWeights.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyItemWeights.java @@ -17,7 +17,6 @@ public class ConfigSectionPartyItemWeights { static { 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(NETHER_QUARTZ_ORE), 200); ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(EMERALD_ORE), 150); diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/ItemShareType.java b/src/main/java/com/gmail/nossr50/datatypes/party/ItemShareType.java index faa1b6599..7c87563f3 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/ItemShareType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/ItemShareType.java @@ -1,6 +1,8 @@ package com.gmail.nossr50.datatypes.party; +import com.gmail.nossr50.config.hocon.HOCONUtil; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.StringUtils; import org.bukkit.inventory.ItemStack; @@ -25,7 +27,7 @@ public enum ItemShareType { else if (ItemUtils.isWoodcuttingDrop(itemStack)) { return WOODCUTTING; } - else if (ItemUtils.isMiscDrop(itemStack)) { + else if (mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(HOCONUtil.serializeENUMName(itemStack.getType().toString())) != null) { return MISC; } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index c878cc822..f8e2a933d 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -138,7 +138,6 @@ public class mcMMO extends JavaPlugin { registerCustomRecipes(); PartyManager.loadParties(); - PartyManager.reloadPartyFeatureHashMap(); formulaManager = new FormulaManager(); holidayManager = new HolidayManager(); diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index a2674b672..e0690f006 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.party; 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.interactions.NotificationType; import com.gmail.nossr50.datatypes.party.*; @@ -28,18 +29,9 @@ public final class PartyManager { private static String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml"; private static List parties = new ArrayList(); private static File partyFile = new File(partiesFilePath); - private static HashMap partyFeatureUnlockMap; 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 * @param partyFeature target party feature @@ -47,7 +39,10 @@ public final class PartyManager { */ 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())); } /** diff --git a/src/main/java/com/gmail/nossr50/party/ShareHandler.java b/src/main/java/com/gmail/nossr50/party/ShareHandler.java index 49fa0277a..3c5bf1e44 100644 --- a/src/main/java/com/gmail/nossr50/party/ShareHandler.java +++ b/src/main/java/com/gmail/nossr50/party/ShareHandler.java @@ -1,5 +1,6 @@ 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.XPGainSource; import com.gmail.nossr50.datatypes.party.ItemShareType; @@ -146,10 +147,10 @@ public final class ShareHandler { } 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; 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) { diff --git a/src/main/java/com/gmail/nossr50/util/ItemUtils.java b/src/main/java/com/gmail/nossr50/util/ItemUtils.java index ec32c5b77..95f0c8792 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemUtils.java +++ b/src/main/java/com/gmail/nossr50/util/ItemUtils.java @@ -1,7 +1,7 @@ package com.gmail.nossr50.util; 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.mcMMO; import org.bukkit.ChatColor; @@ -747,7 +747,7 @@ public final class ItemUtils { * @return true if the item is a miscellaneous drop, false otherwise */ 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) {