mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
Custom Serializer Attempt #2
This commit is contained in:
parent
c01b8e4ad4
commit
133dadccec
@ -122,8 +122,8 @@ public final class ConfigManager {
|
|||||||
private RepairConfig repairConfig;
|
private RepairConfig repairConfig;
|
||||||
private SalvageConfig salvageConfig;
|
private SalvageConfig salvageConfig;
|
||||||
|
|
||||||
private HashMap<String, Integer> partyItemWeights;
|
private HashMap<Material, Integer> partyItemWeights;
|
||||||
private HashMap<String, Integer> partyFeatureUnlocks;
|
private HashMap<PartyFeature, Integer> partyFeatureUnlocks;
|
||||||
|
|
||||||
/* CONFIG ERRORS */
|
/* CONFIG ERRORS */
|
||||||
|
|
||||||
@ -142,8 +142,29 @@ public final class ConfigManager {
|
|||||||
|
|
||||||
//Register Custom Serializers
|
//Register Custom Serializers
|
||||||
mcMMO.p.getLogger().info("Registering custom type serializers with Configurate...");
|
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());
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
TypeTokens are obtained in two ways
|
||||||
|
|
||||||
|
For Raw basic classes:
|
||||||
|
|
||||||
|
TypeToken<String> stringTok = TypeToken.of(String.class);
|
||||||
|
TypeToken<Integer> intTok = TypeToken.of(Integer.class);
|
||||||
|
|
||||||
|
For Generics:
|
||||||
|
|
||||||
|
TypeToken<List<String>> stringListTok = new TypeToken<List<String>>() {};
|
||||||
|
|
||||||
|
Wildcard example:
|
||||||
|
|
||||||
|
TypeToken<Map<?, ?>> wildMapTok = new TypeToken<Map<?, ?>>() {};
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
TypeSerializers.getDefaultSerializers().registerType(new TypeToken<Material>() {}, new CustomEnumValueSerializer());
|
||||||
|
TypeSerializers.getDefaultSerializers().registerType(new TypeToken<PartyFeature>() {}, new CustomEnumValueSerializer());
|
||||||
|
|
||||||
mcMMO.p.getLogger().info("Deserializing configs...");
|
mcMMO.p.getLogger().info("Deserializing configs...");
|
||||||
//TODO: Not sure about the order of MainConfig
|
//TODO: Not sure about the order of MainConfig
|
||||||
@ -427,11 +448,11 @@ public final class ConfigManager {
|
|||||||
return configSuperAbilities.getConfig();
|
return configSuperAbilities.getConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, Integer> getPartyItemWeights() {
|
public HashMap<Material, Integer> getPartyItemWeights() {
|
||||||
return partyItemWeights;
|
return partyItemWeights;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, Integer> getPartyFeatureUnlocks() {
|
public HashMap<PartyFeature, Integer> getPartyFeatureUnlocks() {
|
||||||
return partyFeatureUnlocks;
|
return partyFeatureUnlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,8 +226,6 @@ public class ExperienceConfig extends ConfigValidated {
|
|||||||
return getBooleanValue(EXPLOIT_FIX, ENDERMAN_ENDERMITE_FARMS);
|
return getBooleanValue(EXPLOIT_FIX, ENDERMAN_ENDERMITE_FARMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFishingExploitingPrevented() { return config.getBoolean("ExploitFix.Fishing", true); }
|
|
||||||
|
|
||||||
/* Curve settings */
|
/* Curve settings */
|
||||||
public FormulaType getFormulaType() {
|
public FormulaType getFormulaType() {
|
||||||
return FormulaType.getFormulaType(getStringValue(EXPERIENCE_FORMULA, CURVE));
|
return FormulaType.getFormulaType(getStringValue(EXPERIENCE_FORMULA, CURVE));
|
||||||
|
@ -11,6 +11,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class CustomEnumValueSerializer implements TypeSerializer<Enum> {
|
public class CustomEnumValueSerializer implements TypeSerializer<Enum> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked") // i continue to hate generics
|
@SuppressWarnings("unchecked") // i continue to hate generics
|
||||||
public Enum deserialize(TypeToken<?> type, ConfigurationNode value) throws ObjectMappingException {
|
public Enum deserialize(TypeToken<?> type, ConfigurationNode value) throws ObjectMappingException {
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
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 CustomEnumValueSerializerPartyFeature 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()));
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.config.hocon.party;
|
|||||||
|
|
||||||
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 org.bukkit.Material;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ public class ConfigSectionPartyItemShare {
|
|||||||
@Setting(value = "Party-Item-Share-Settings")
|
@Setting(value = "Party-Item-Share-Settings")
|
||||||
ConfigSectionPartyItemShareSettings partyItemShareSettings = new ConfigSectionPartyItemShareSettings();
|
ConfigSectionPartyItemShareSettings partyItemShareSettings = new ConfigSectionPartyItemShareSettings();
|
||||||
|
|
||||||
public HashMap<String, Integer> getItemShareMap() {
|
public HashMap<Material, Integer> getItemShareMap() {
|
||||||
return partyItemWeights.getItemShareMap();
|
return partyItemWeights.getItemShareMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.config.hocon.party;
|
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.Setting;
|
||||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -12,77 +11,66 @@ import static org.bukkit.Material.*;
|
|||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
public class ConfigSectionPartyItemWeights {
|
public class ConfigSectionPartyItemWeights {
|
||||||
|
|
||||||
private static final HashMap<String, Integer> ITEM_WEIGHT_MAP_DEFAULT;
|
private static final HashMap<Material, Integer> ITEM_WEIGHT_MAP_DEFAULT;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ITEM_WEIGHT_MAP_DEFAULT = new HashMap<>();
|
ITEM_WEIGHT_MAP_DEFAULT = new HashMap<>();
|
||||||
|
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(QUARTZ), 200);
|
ITEM_WEIGHT_MAP_DEFAULT.put(QUARTZ, 200);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(NETHER_QUARTZ_ORE), 200);
|
ITEM_WEIGHT_MAP_DEFAULT.put(NETHER_QUARTZ_ORE, 200);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(EMERALD_ORE), 150);
|
ITEM_WEIGHT_MAP_DEFAULT.put(EMERALD_ORE, 150);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(EMERALD), 150);
|
ITEM_WEIGHT_MAP_DEFAULT.put(EMERALD, 150);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND), 100);
|
ITEM_WEIGHT_MAP_DEFAULT.put(DIAMOND, 100);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_ORE), 100);
|
ITEM_WEIGHT_MAP_DEFAULT.put(DIAMOND_ORE, 100);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLD_INGOT), 50);
|
ITEM_WEIGHT_MAP_DEFAULT.put(GOLD_INGOT, 50);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLD_ORE), 50);
|
ITEM_WEIGHT_MAP_DEFAULT.put(GOLD_ORE, 50);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_ORE), 40);
|
ITEM_WEIGHT_MAP_DEFAULT.put(IRON_ORE, 40);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_INGOT), 40);
|
ITEM_WEIGHT_MAP_DEFAULT.put(IRON_INGOT, 40);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(LAPIS_ORE), 30);
|
ITEM_WEIGHT_MAP_DEFAULT.put(LAPIS_ORE, 30);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(REDSTONE), 30);
|
ITEM_WEIGHT_MAP_DEFAULT.put(REDSTONE, 30);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(REDSTONE_ORE), 30);
|
ITEM_WEIGHT_MAP_DEFAULT.put(REDSTONE_ORE, 30);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GLOWSTONE_DUST), 20);
|
ITEM_WEIGHT_MAP_DEFAULT.put(GLOWSTONE_DUST, 20);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(COAL), 10);
|
ITEM_WEIGHT_MAP_DEFAULT.put(COAL, 10);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(COAL_ORE), 10);
|
ITEM_WEIGHT_MAP_DEFAULT.put(COAL_ORE, 10);
|
||||||
|
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_SHOVEL), 150);
|
ITEM_WEIGHT_MAP_DEFAULT.put(DIAMOND_SHOVEL, 150);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_SWORD), 150);
|
ITEM_WEIGHT_MAP_DEFAULT.put(DIAMOND_SWORD, 150);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_AXE), 150);
|
ITEM_WEIGHT_MAP_DEFAULT.put(DIAMOND_AXE, 150);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_HOE), 150);
|
ITEM_WEIGHT_MAP_DEFAULT.put(DIAMOND_HOE, 150);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_CHESTPLATE), 150);
|
ITEM_WEIGHT_MAP_DEFAULT.put(DIAMOND_CHESTPLATE, 150);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_HELMET), 150);
|
ITEM_WEIGHT_MAP_DEFAULT.put(DIAMOND_HELMET, 150);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_LEGGINGS), 150);
|
ITEM_WEIGHT_MAP_DEFAULT.put(DIAMOND_LEGGINGS, 150);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(DIAMOND_BOOTS), 150);
|
ITEM_WEIGHT_MAP_DEFAULT.put(DIAMOND_BOOTS, 150);
|
||||||
|
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLDEN_SHOVEL), 75);
|
ITEM_WEIGHT_MAP_DEFAULT.put(GOLDEN_SHOVEL, 75);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLDEN_SWORD), 75);
|
ITEM_WEIGHT_MAP_DEFAULT.put(GOLDEN_SWORD, 75);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLDEN_AXE), 75);
|
ITEM_WEIGHT_MAP_DEFAULT.put(GOLDEN_AXE, 75);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLDEN_HOE), 75);
|
ITEM_WEIGHT_MAP_DEFAULT.put(GOLDEN_HOE, 75);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLDEN_CHESTPLATE), 75);
|
ITEM_WEIGHT_MAP_DEFAULT.put(GOLDEN_CHESTPLATE, 75);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLDEN_HELMET), 75);
|
ITEM_WEIGHT_MAP_DEFAULT.put(GOLDEN_HELMET, 75);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLDEN_LEGGINGS), 75);
|
ITEM_WEIGHT_MAP_DEFAULT.put(GOLDEN_LEGGINGS, 75);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(GOLDEN_BOOTS), 75);
|
ITEM_WEIGHT_MAP_DEFAULT.put(GOLDEN_BOOTS, 75);
|
||||||
|
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_SHOVEL), 60);
|
ITEM_WEIGHT_MAP_DEFAULT.put(IRON_SHOVEL, 60);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_SWORD), 60);
|
ITEM_WEIGHT_MAP_DEFAULT.put(IRON_SWORD, 60);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_AXE), 60);
|
ITEM_WEIGHT_MAP_DEFAULT.put(IRON_AXE, 60);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_HOE), 60);
|
ITEM_WEIGHT_MAP_DEFAULT.put(IRON_HOE, 60);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_CHESTPLATE), 60);
|
ITEM_WEIGHT_MAP_DEFAULT.put(IRON_CHESTPLATE, 60);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_HELMET), 60);
|
ITEM_WEIGHT_MAP_DEFAULT.put(IRON_HELMET, 60);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_LEGGINGS), 60);
|
ITEM_WEIGHT_MAP_DEFAULT.put(IRON_LEGGINGS, 60);
|
||||||
ITEM_WEIGHT_MAP_DEFAULT.put(getHOCONFriendly(IRON_BOOTS), 60);
|
ITEM_WEIGHT_MAP_DEFAULT.put(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);
|
|
||||||
|
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(LEATHER_CHESTPLATE, 10);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(LEATHER_HELMET, 10);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(LEATHER_BOOTS, 10);
|
||||||
|
ITEM_WEIGHT_MAP_DEFAULT.put(LEATHER_LEGGINGS, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Setting(value = "Party-Item-Share-Weight-Values",
|
@Setting(value = "Party-Item-Share-Weight-Values",
|
||||||
comment = "These weight values help control item distribution when using \"EQUAL\" distribution")
|
comment = "These weight values help control item distribution when using \"EQUAL\" distribution")
|
||||||
private HashMap<String, Integer> itemShareMap = ITEM_WEIGHT_MAP_DEFAULT;
|
private HashMap<Material, Integer> itemShareMap = ITEM_WEIGHT_MAP_DEFAULT;
|
||||||
|
|
||||||
/**
|
public HashMap<Material, Integer> getItemShareMap() {
|
||||||
* 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;
|
return itemShareMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
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 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 +10,7 @@ import java.util.Map;
|
|||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
public class ConfigSectionPartyLevel {
|
public class ConfigSectionPartyLevel {
|
||||||
|
|
||||||
private static final HashMap<String, Integer> PARTY_FEATURE_MAP_DEFAULT;
|
private static final HashMap<PartyFeature, 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 +27,11 @@ public class ConfigSectionPartyLevel {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
PARTY_FEATURE_MAP_DEFAULT = new HashMap<>();
|
PARTY_FEATURE_MAP_DEFAULT = new HashMap<>();
|
||||||
PARTY_FEATURE_MAP_DEFAULT.put(HOCONUtil.serializeENUMName(PartyFeature.TELEPORT.toString()), TELEPORT_DEFAULT);
|
PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.TELEPORT, TELEPORT_DEFAULT);
|
||||||
PARTY_FEATURE_MAP_DEFAULT.put(HOCONUtil.serializeENUMName(PartyFeature.ALLIANCE.toString()), ALLIANCE_DEFAULT);
|
PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.ALLIANCE, ALLIANCE_DEFAULT);
|
||||||
PARTY_FEATURE_MAP_DEFAULT.put(HOCONUtil.serializeENUMName(PartyFeature.ITEM_SHARE.toString()), ITEM_SHARE_DEFAULT);
|
PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.ITEM_SHARE, ITEM_SHARE_DEFAULT);
|
||||||
PARTY_FEATURE_MAP_DEFAULT.put(HOCONUtil.serializeENUMName(PartyFeature.XP_SHARE.toString()), XP_SHARE_DEFAULT);
|
PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.XP_SHARE, XP_SHARE_DEFAULT);
|
||||||
PARTY_FEATURE_MAP_DEFAULT.put(HOCONUtil.serializeENUMName(PartyFeature.CHAT.toString()), PARTY_CHAT_DEFAULT);
|
PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.CHAT, PARTY_CHAT_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -73,7 +72,7 @@ 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<String, Integer> partyFeatureUnlockMap = PARTY_FEATURE_MAP_DEFAULT;
|
private Map<PartyFeature, Integer> partyFeatureUnlockMap = PARTY_FEATURE_MAP_DEFAULT;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -89,5 +88,5 @@ public class ConfigSectionPartyLevel {
|
|||||||
return informPartyMembersOnLevelup;
|
return informPartyMembersOnLevelup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Integer> getPartyFeatureUnlockMap() { return partyFeatureUnlockMap; }
|
public Map<PartyFeature, Integer> getPartyFeatureUnlockMap() { return partyFeatureUnlockMap; }
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
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.mcMMO;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
@ -27,7 +26,7 @@ public enum ItemShareType {
|
|||||||
else if (ItemUtils.isWoodcuttingDrop(itemStack)) {
|
else if (ItemUtils.isWoodcuttingDrop(itemStack)) {
|
||||||
return WOODCUTTING;
|
return WOODCUTTING;
|
||||||
}
|
}
|
||||||
else if (mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(HOCONUtil.serializeENUMName(itemStack.getType().toString())) != null) {
|
else if (mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(itemStack.getType()) != null) {
|
||||||
return MISC;
|
return MISC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
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.*;
|
||||||
@ -42,10 +41,10 @@ public final class PartyManager {
|
|||||||
*/
|
*/
|
||||||
public static int getPartyFeatureUnlockLevel(PartyFeature partyFeature)
|
public static int getPartyFeatureUnlockLevel(PartyFeature partyFeature)
|
||||||
{
|
{
|
||||||
if(mcMMO.getConfigManager().getPartyFeatureUnlocks().get(HOCONUtil.serializeENUMName(partyFeature.toString())) == null)
|
if(mcMMO.getConfigManager().getPartyFeatureUnlocks().get(partyFeature) == null)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return mcMMO.getConfigManager().getPartyFeatureUnlocks().get(HOCONUtil.serializeENUMName(partyFeature.toString()));
|
return mcMMO.getConfigManager().getPartyFeatureUnlocks().get(partyFeature);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
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;
|
||||||
@ -147,10 +146,10 @@ public final class ShareHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getItemWeight(Material material) {
|
public static int getItemWeight(Material material) {
|
||||||
if(mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(HOCONUtil.serializeENUMName(material.toString())) == null)
|
if(mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(material) == null)
|
||||||
return 5;
|
return 5;
|
||||||
else
|
else
|
||||||
return mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(HOCONUtil.serializeENUMName(material.toString()));
|
return mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(material);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static XPGainReason getSharedXpGainReason(XPGainReason xpGainReason) {
|
public static XPGainReason getSharedXpGainReason(XPGainReason xpGainReason) {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
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.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 +746,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 mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(HOCONUtil.serializeENUMName(item.getType().toString())) != null;
|
return mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(item.getType()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isMcMMOItem(ItemStack item) {
|
public static boolean isMcMMOItem(ItemStack item) {
|
||||||
|
Loading…
Reference in New Issue
Block a user