mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 08:36:45 +01:00
Party Config Pt 5
This commit is contained in:
parent
d11f8fcdce
commit
8a6ed2f076
@ -3,7 +3,9 @@ package com.gmail.nossr50.config;
|
|||||||
import com.gmail.nossr50.config.collectionconfigs.RepairConfig;
|
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.SerializedConfigLoader;
|
import com.gmail.nossr50.config.hocon.SerializedConfigLoader;
|
||||||
|
import com.gmail.nossr50.config.hocon.admin.ConfigAdmin;
|
||||||
import com.gmail.nossr50.config.hocon.antiexploit.ConfigExploitPrevention;
|
import com.gmail.nossr50.config.hocon.antiexploit.ConfigExploitPrevention;
|
||||||
import com.gmail.nossr50.config.hocon.backup.ConfigAutomatedBackups;
|
import com.gmail.nossr50.config.hocon.backup.ConfigAutomatedBackups;
|
||||||
import com.gmail.nossr50.config.hocon.commands.ConfigCommands;
|
import com.gmail.nossr50.config.hocon.commands.ConfigCommands;
|
||||||
@ -26,14 +28,21 @@ import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
|||||||
import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig;
|
import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig;
|
||||||
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
|
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
|
||||||
import com.gmail.nossr50.config.treasure.HerbalismTreasureConfig;
|
import com.gmail.nossr50.config.treasure.HerbalismTreasureConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager;
|
import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager;
|
||||||
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||||
import com.gmail.nossr50.skills.salvage.salvageables.SimpleSalvageableManager;
|
import com.gmail.nossr50.skills.salvage.salvageables.SimpleSalvageableManager;
|
||||||
import com.gmail.nossr50.util.experience.ExperienceMapManager;
|
import com.gmail.nossr50.util.experience.ExperienceMapManager;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
|
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -93,6 +102,7 @@ public final class ConfigManager {
|
|||||||
private SerializedConfigLoader<ConfigParty> configParty;
|
private SerializedConfigLoader<ConfigParty> configParty;
|
||||||
private SerializedConfigLoader<ConfigNotifications> configNotifications;
|
private SerializedConfigLoader<ConfigNotifications> configNotifications;
|
||||||
private SerializedConfigLoader<ConfigSuperAbilities> configSuperAbilities;
|
private SerializedConfigLoader<ConfigSuperAbilities> configSuperAbilities;
|
||||||
|
private SerializedConfigLoader<ConfigAdmin> configAdmin;
|
||||||
|
|
||||||
private MainConfig mainConfig;
|
private MainConfig mainConfig;
|
||||||
private FishingTreasureConfig fishingTreasureConfig;
|
private FishingTreasureConfig fishingTreasureConfig;
|
||||||
@ -108,6 +118,9 @@ public final class ConfigManager {
|
|||||||
private RepairConfig repairConfig;
|
private RepairConfig repairConfig;
|
||||||
private SalvageConfig salvageConfig;
|
private SalvageConfig salvageConfig;
|
||||||
|
|
||||||
|
private HashMap<String, Integer> partyItemWeights;
|
||||||
|
private HashMap<String, Integer> partyFeatureUnlocks;
|
||||||
|
|
||||||
/* CONFIG ERRORS */
|
/* CONFIG ERRORS */
|
||||||
|
|
||||||
private ArrayList<String> configErrors; //Collect errors to whine about to server admins
|
private ArrayList<String> configErrors; //Collect errors to whine about to server admins
|
||||||
@ -123,6 +136,12 @@ public final class ConfigManager {
|
|||||||
// Load Config Files
|
// Load Config Files
|
||||||
// I'm pretty these are supposed to be done in a specific order, so don't rearrange them willy nilly
|
// I'm pretty these are supposed to be done in a specific order, so don't rearrange them willy nilly
|
||||||
|
|
||||||
|
//Register Custom Serializers
|
||||||
|
mcMMO.p.getLogger().info("Registering custom type serializers with Configurate...");
|
||||||
|
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(Material.class), new CustomEnumValueSerializer());
|
||||||
|
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(PartyFeature.class), new CustomEnumValueSerializer());
|
||||||
|
|
||||||
|
mcMMO.p.getLogger().info("Deserializing configs...");
|
||||||
//TODO: Not sure about the order of MainConfig
|
//TODO: Not sure about the order of MainConfig
|
||||||
//Serialized Configs
|
//Serialized Configs
|
||||||
configDatabase = new SerializedConfigLoader<>(ConfigDatabase.class, "database_settings.conf", null);
|
configDatabase = new SerializedConfigLoader<>(ConfigDatabase.class, "database_settings.conf", null);
|
||||||
@ -142,7 +161,16 @@ public final class ConfigManager {
|
|||||||
configParty = new SerializedConfigLoader<>(ConfigParty.class, "party.conf", null);
|
configParty = new SerializedConfigLoader<>(ConfigParty.class, "party.conf", null);
|
||||||
configNotifications = new SerializedConfigLoader<>(ConfigNotifications.class, "chat_and_hud_notifications.conf", null);
|
configNotifications = new SerializedConfigLoader<>(ConfigNotifications.class, "chat_and_hud_notifications.conf", null);
|
||||||
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);
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
//YAML Configs
|
||||||
mainConfig = new MainConfig();
|
mainConfig = new MainConfig();
|
||||||
|
|
||||||
fishingTreasureConfig = new FishingTreasureConfig();
|
fishingTreasureConfig = new FishingTreasureConfig();
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.gmail.nossr50.config.hocon;
|
||||||
|
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
|
import ninja.leaping.configurate.ConfigurationNode;
|
||||||
|
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||||
|
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
|
||||||
|
import ninja.leaping.configurate.util.EnumLookup;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class CustomEnumValueSerializer implements TypeSerializer<Enum> {
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked") // i continue to hate generics
|
||||||
|
public Enum deserialize(TypeToken<?> type, ConfigurationNode value) throws ObjectMappingException {
|
||||||
|
String enumConstant = HOCONUtil.deserializeENUMName(value.getString());
|
||||||
|
if (enumConstant == null) {
|
||||||
|
throw new ObjectMappingException("No value present in node " + value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<Enum> ret = (Optional) EnumLookup.lookupEnum(type.getRawType().asSubclass(Enum.class),
|
||||||
|
enumConstant); // XXX: intellij says this cast is optional but it isnt
|
||||||
|
if (!ret.isPresent()) {
|
||||||
|
throw new ObjectMappingException("Invalid enum constant provided for " + value.getKey() + ": " +
|
||||||
|
"Expected a value of enum " + type + ", got " + enumConstant);
|
||||||
|
}
|
||||||
|
return ret.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(@NonNull TypeToken<?> type, @Nullable Enum obj, @NonNull ConfigurationNode value) throws ObjectMappingException {
|
||||||
|
value.setValue(HOCONUtil.serializeENUMName(obj.name()));
|
||||||
|
}
|
||||||
|
}
|
38
src/main/java/com/gmail/nossr50/config/hocon/HOCONUtil.java
Normal file
38
src/main/java/com/gmail/nossr50/config/hocon/HOCONUtil.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package com.gmail.nossr50.config.hocon;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
|
public final class HOCONUtil {
|
||||||
|
|
||||||
|
public static String serializeENUMName(String hyphenedString)
|
||||||
|
{
|
||||||
|
String[] split = hyphenedString.split("_");
|
||||||
|
String formattedString = "";
|
||||||
|
|
||||||
|
for(int x = 0; x < split.length; x++)
|
||||||
|
{
|
||||||
|
if(x + 1 >= split.length)
|
||||||
|
formattedString += StringUtils.getCapitalized(split[x]);
|
||||||
|
else
|
||||||
|
formattedString+= (StringUtils.getCapitalized(split[x]) + '-');
|
||||||
|
}
|
||||||
|
|
||||||
|
return formattedString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String deserializeENUMName(String serializedName)
|
||||||
|
{
|
||||||
|
String[] split = serializedName.split("-");
|
||||||
|
String formattedString = "";
|
||||||
|
|
||||||
|
for(int x = 0; x < split.length; x++)
|
||||||
|
{
|
||||||
|
if(x + 1 >= split.length)
|
||||||
|
formattedString += split[x].toUpperCase();
|
||||||
|
else
|
||||||
|
formattedString+= (split[x] + '_');
|
||||||
|
}
|
||||||
|
|
||||||
|
return formattedString;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.gmail.nossr50.config.hocon.admin;
|
||||||
|
|
||||||
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
|
|
||||||
|
@ConfigSerializable
|
||||||
|
public class ConfigAdmin {
|
||||||
|
|
||||||
|
}
|
@ -28,6 +28,9 @@ public class ConfigParty {
|
|||||||
@Setting(value = "Party-Commands", comment = "Settings related to various party commands.")
|
@Setting(value = "Party-Commands", comment = "Settings related to various party commands.")
|
||||||
private ConfigSectionPartyCommands partyCommands = new ConfigSectionPartyCommands();
|
private ConfigSectionPartyCommands partyCommands = new ConfigSectionPartyCommands();
|
||||||
|
|
||||||
|
@Setting(value = "Party-Item-Share", comment = "Settings related to sharing items dropped from monsters in a party.")
|
||||||
|
private ConfigSectionPartyItemShare partyItemShare = new ConfigSectionPartyItemShare();
|
||||||
|
|
||||||
public int getPartySizeLimit() {
|
public int getPartySizeLimit() {
|
||||||
return partyGeneral.getPartySizeLimit();
|
return partyGeneral.getPartySizeLimit();
|
||||||
}
|
}
|
||||||
@ -56,6 +59,10 @@ public class ConfigParty {
|
|||||||
return partyXP;
|
return partyXP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConfigSectionPartyItemShare getPartyItemShare() {
|
||||||
|
return partyItemShare;
|
||||||
|
}
|
||||||
|
|
||||||
public String getPartyChatPrefixFormat() {
|
public String getPartyChatPrefixFormat() {
|
||||||
return partyChat.getPartyChatPrefixFormat();
|
return partyChat.getPartyChatPrefixFormat();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.gmail.nossr50.config.hocon.party;
|
||||||
|
|
||||||
|
import ninja.leaping.configurate.objectmapping.Setting;
|
||||||
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@ConfigSerializable
|
||||||
|
public class ConfigSectionPartyItemShare {
|
||||||
|
|
||||||
|
@Setting(value = "Party-Item-Weights", comment = "The values in this section are used only for loot distribution EQUAL" +
|
||||||
|
"\nWhen a player gets a good drop their odds to get another good drop plummet until other party members catch up in item weight points.")
|
||||||
|
ConfigSectionPartyItemWeights partyItemWeights = new ConfigSectionPartyItemWeights();
|
||||||
|
|
||||||
|
@Setting(value = "Party-Item-Share-Settings")
|
||||||
|
ConfigSectionPartyItemShareSettings partyItemShareSettings = new ConfigSectionPartyItemShareSettings();
|
||||||
|
|
||||||
|
public HashMap<String, Integer> getItemShareMap() {
|
||||||
|
return partyItemWeights.getItemShareMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigSectionPartyItemWeights getPartyItemWeights() {
|
||||||
|
return partyItemWeights;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigSectionPartyItemShareSettings getPartyItemShareSettings() {
|
||||||
|
return partyItemShareSettings;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.gmail.nossr50.config.hocon.party;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||||
|
import ninja.leaping.configurate.objectmapping.Setting;
|
||||||
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
|
|
||||||
|
@ConfigSerializable
|
||||||
|
public class ConfigSectionPartyItemShareSettings {
|
||||||
|
|
||||||
|
public static final ShareMode SHARE_MODE_DEFAULT = ShareMode.NONE;
|
||||||
|
|
||||||
|
@Setting(value = "Item-Share-Distribution-Model", comment = "Determines how to distribute dropped items between party members." +
|
||||||
|
"\nEQUAL: Party members have weighted dice rolls based on the quality of the loot they have recently received." +
|
||||||
|
"\nRANDOM: Party members do a fair dice roll for every item dropped." +
|
||||||
|
"\nNONE: Do not use item sharing" +
|
||||||
|
"\nDefault Value: "+"NONE")
|
||||||
|
private ShareMode shareMode = SHARE_MODE_DEFAULT;
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
package com.gmail.nossr50.config.hocon.party;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.hocon.HOCONUtil;
|
||||||
|
import ninja.leaping.configurate.objectmapping.Setting;
|
||||||
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import static org.bukkit.Material.*;
|
||||||
|
|
||||||
|
@ConfigSerializable
|
||||||
|
public class ConfigSectionPartyItemWeights {
|
||||||
|
|
||||||
|
private static final HashMap<String, Integer> ITEM_WEIGHT_MAP_DEFAULT;
|
||||||
|
|
||||||
|
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);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(EMERALD), 150);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND), 100);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_ORE), 100);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLD_INGOT), 50);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLD_ORE), 50);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_ORE), 40);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_INGOT), 40);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(LAPIS_ORE), 30);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(REDSTONE), 30);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(REDSTONE_ORE), 30);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GLOWSTONE_DUST), 20);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(COAL), 10);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(COAL_ORE), 10);
|
||||||
|
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_SHOVEL), 150);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_SWORD), 150);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_AXE), 150);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_HOE), 150);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_CHESTPLATE), 150);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_HELMET), 150);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_LEGGINGS), 150);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_BOOTS), 150);
|
||||||
|
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLDEN_SHOVEL), 75);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLDEN_SWORD), 75);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLDEN_AXE), 75);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLDEN_HOE), 75);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLDEN_CHESTPLATE), 75);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLDEN_HELMET), 75);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLDEN_LEGGINGS), 75);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLDEN_BOOTS), 75);
|
||||||
|
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_SHOVEL), 60);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_SWORD), 60);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_AXE), 60);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_HOE), 60);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_CHESTPLATE), 60);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_HELMET), 60);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_LEGGINGS), 60);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_BOOTS), 60);
|
||||||
|
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(LEATHER_CHESTPLATE), 10);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(LEATHER_HELMET), 10);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(LEATHER_BOOTS), 10);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(LEATHER_LEGGINGS), 10);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Setting(value = "Party-Item-Share-Weight-Values",
|
||||||
|
comment = "These weight values help control item distribution when using \"EQUAL\" distribution")
|
||||||
|
private HashMap<String, Integer> itemShareMap = ITEM_WEIGHT_MAP_DEFAULT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes an input like 'NETHER_BRICK' and turns it into 'Nether-Brick'
|
||||||
|
* @param material target Material to convert
|
||||||
|
* @return a HOCON serializer friendly key name
|
||||||
|
*/
|
||||||
|
private static String getHOCONFriendly(Material material)
|
||||||
|
{
|
||||||
|
return HOCONUtil.serializeENUMName(material.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, Integer> getItemShareMap() {
|
||||||
|
return itemShareMap;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package com.gmail.nossr50.config.hocon.party;
|
package com.gmail.nossr50.config.hocon.party;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.hocon.HOCONUtil;
|
||||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
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;
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ import java.util.Map;
|
|||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
public class ConfigSectionPartyLevel {
|
public class ConfigSectionPartyLevel {
|
||||||
|
|
||||||
private static final HashMap<PartyFeature, Integer> PARTY_FEATURE_MAP_DEFAULT;
|
private static final HashMap<String, Integer> PARTY_FEATURE_MAP_DEFAULT;
|
||||||
public static final boolean INFORM_PARTY_ON_LEVELUP_DEFAULT = true;
|
public static final boolean INFORM_PARTY_ON_LEVELUP_DEFAULT = true;
|
||||||
|
|
||||||
public static final boolean PARTY_LEVELING_NEEDS_NERBY_MEMBERS_DEFAULT = true;
|
public static final boolean PARTY_LEVELING_NEEDS_NERBY_MEMBERS_DEFAULT = true;
|
||||||
@ -28,11 +28,11 @@ public class ConfigSectionPartyLevel {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
PARTY_FEATURE_MAP_DEFAULT = new HashMap<>();
|
PARTY_FEATURE_MAP_DEFAULT = new HashMap<>();
|
||||||
PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.TELEPORT, TELEPORT_DEFAULT);
|
PARTY_FEATURE_MAP_DEFAULT.put(HOCONUtil.serializeENUMName(PartyFeature.TELEPORT.toString()), TELEPORT_DEFAULT);
|
||||||
PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.ALLIANCE, ALLIANCE_DEFAULT);
|
PARTY_FEATURE_MAP_DEFAULT.put(HOCONUtil.serializeENUMName(PartyFeature.ALLIANCE.toString()), ALLIANCE_DEFAULT);
|
||||||
PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.ITEM_SHARE, ITEM_SHARE_DEFAULT);
|
PARTY_FEATURE_MAP_DEFAULT.put(HOCONUtil.serializeENUMName(PartyFeature.ITEM_SHARE.toString()), ITEM_SHARE_DEFAULT);
|
||||||
PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.XP_SHARE, XP_SHARE_DEFAULT);
|
PARTY_FEATURE_MAP_DEFAULT.put(HOCONUtil.serializeENUMName(PartyFeature.XP_SHARE.toString()), XP_SHARE_DEFAULT);
|
||||||
PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.CHAT, PARTY_CHAT_DEFAULT);
|
PARTY_FEATURE_MAP_DEFAULT.put(HOCONUtil.serializeENUMName(PartyFeature.CHAT.toString()), PARTY_CHAT_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -73,7 +73,9 @@ public class ConfigSectionPartyLevel {
|
|||||||
"\nALIANCE: "+ALLIANCE_DEFAULT +
|
"\nALIANCE: "+ALLIANCE_DEFAULT +
|
||||||
"\nITEM SHARE: "+ITEM_SHARE_DEFAULT +
|
"\nITEM SHARE: "+ITEM_SHARE_DEFAULT +
|
||||||
"\nXP SHARE: "+XP_SHARE_DEFAULT)
|
"\nXP SHARE: "+XP_SHARE_DEFAULT)
|
||||||
private Map<PartyFeature, Integer> partyFeatureUnlockMap = PARTY_FEATURE_MAP_DEFAULT;
|
private Map<String, Integer> partyFeatureUnlockMap = PARTY_FEATURE_MAP_DEFAULT;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int getPartyXpCurveMultiplier() {
|
public int getPartyXpCurveMultiplier() {
|
||||||
return partyXPFormula.getPartyXpCurveMultiplier();
|
return partyXPFormula.getPartyXpCurveMultiplier();
|
||||||
@ -87,7 +89,5 @@ public class ConfigSectionPartyLevel {
|
|||||||
return informPartyMembersOnLevelup;
|
return informPartyMembersOnLevelup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<PartyFeature, Integer> getPartyFeatureUnlockMap() {
|
public Map<String, Integer> getPartyFeatureUnlockMap() { return partyFeatureUnlockMap; }
|
||||||
return Maps.newHashMap(partyFeatureUnlockMap);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -19,7 +19,10 @@ public enum PartyFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getFeatureLockedLocaleString() {
|
public String getFeatureLockedLocaleString() {
|
||||||
return LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Party.Feature.Locked." + StringUtils.getPrettyPartyFeatureString(this).replace(" ", ""), PartyManager.getPartyFeatureUnlockLevel(this)));
|
return LocaleLoader.getString("Ability.Generic.Template.Lock",
|
||||||
|
LocaleLoader.getString("Party.Feature.Locked."
|
||||||
|
+ StringUtils.getPrettyPartyFeatureString(this).replace(" ", ""),
|
||||||
|
PartyManager.getPartyFeatureUnlockLevel(this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(Player player) {
|
public boolean hasPermission(Player player) {
|
||||||
|
@ -425,6 +425,8 @@ public class PlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!drop.hasMetadata(mcMMO.droppedItemKey) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
|
if (!drop.hasMetadata(mcMMO.droppedItemKey) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
|
||||||
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
|
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user