mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
Correcting issues with deserializing SkillRankProperty
This commit is contained in:
parent
e5592919b7
commit
97b70ec2a1
@ -20,20 +20,24 @@ public class SkillRankPropertySerializer implements TypeSerializer<SkillRankProp
|
||||
@Nullable
|
||||
@Override
|
||||
public SkillRankProperty deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException {
|
||||
HashMap<Integer, Integer> standardMap;
|
||||
HashMap<Integer, Integer> retroMap;
|
||||
HashMap<Integer, Integer> standardHashMap;
|
||||
HashMap<Integer, Integer> retroHashMap;
|
||||
|
||||
try {
|
||||
standardMap = (HashMap<Integer, Integer>) value.getNode(STANDARD_RANK_UNLOCK_LEVEL_REQUIREMENTS).getValue(new TypeToken<Map<?, ?>>() {});
|
||||
retroMap = (HashMap<Integer, Integer>) value.getNode(RETRO_RANK_UNLOCK_LEVEL_REQUIREMENTS).getValue(new TypeToken<Map<?, ?>>() {});
|
||||
Map<? extends Integer, ? extends Integer> standardMap = value.getNode(STANDARD_RANK_UNLOCK_LEVEL_REQUIREMENTS).getValue(new TypeToken<Map<? extends Integer, ? extends Integer>>() {});
|
||||
Map<? extends Integer, ? extends Integer> retroMap = value.getNode(RETRO_RANK_UNLOCK_LEVEL_REQUIREMENTS).getValue(new TypeToken<Map<? extends Integer, ? extends Integer>>() {});
|
||||
|
||||
standardHashMap = new HashMap<>(standardMap);
|
||||
retroHashMap = new HashMap<>(retroMap);
|
||||
|
||||
} catch (ObjectMappingException e) {
|
||||
mcMMO.p.getLogger().severe("Unable to deserialize rank property information from the config, make sure the ranks are correctly set in the config. You can delete the rank config to generate a new one if problems persist.");
|
||||
throw e;
|
||||
}
|
||||
|
||||
SkillRankProperty skillRankProperty = new SkillRankProperty();
|
||||
skillRankProperty.setStandardRanks(standardMap);
|
||||
skillRankProperty.setRetroRanks(retroMap);
|
||||
skillRankProperty.setStandardRanks(standardHashMap);
|
||||
skillRankProperty.setRetroRanks(retroHashMap);
|
||||
|
||||
return skillRankProperty;
|
||||
}
|
||||
@ -41,6 +45,6 @@ public class SkillRankPropertySerializer implements TypeSerializer<SkillRankProp
|
||||
@Override
|
||||
public void serialize(@NonNull TypeToken<?> type, @Nullable SkillRankProperty obj, @NonNull ConfigurationNode value) throws ObjectMappingException {
|
||||
value.getNode(STANDARD_RANK_UNLOCK_LEVEL_REQUIREMENTS).setValue(obj.getStandardRanks());
|
||||
value.getNode(RETRO_RANK_UNLOCK_LEVEL_REQUIREMENTS).setValue(obj.getStandardRanks());
|
||||
value.getNode(RETRO_RANK_UNLOCK_LEVEL_REQUIREMENTS).setValue(obj.getRetroRanks());
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
@ConfigSerializable
|
||||
public class ConfigRanksArchery {
|
||||
|
||||
@Setting(value = "Limit-Break")
|
||||
@Setting(value = "Archery-Limit-Break")
|
||||
private SkillRankProperty limitBreak = new SkillRankProperty(10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
|
||||
|
||||
@Setting(value = "Arrow-Retrieval")
|
||||
|
@ -6,7 +6,7 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
@ConfigSerializable
|
||||
public class ConfigRanksAxes {
|
||||
|
||||
@Setting(value = "Limit-Break")
|
||||
@Setting(value = "Axes-Limit-Break")
|
||||
private SkillRankProperty limitBreak = new SkillRankProperty(10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
|
||||
|
||||
@Setting(value = "Skull-Splitter")
|
||||
|
@ -1,8 +1,29 @@
|
||||
package com.gmail.nossr50.config.hocon.skills.ranks;
|
||||
|
||||
import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ConfigRanksRepair {
|
||||
|
||||
@Setting(value = "Arcane-Forging")
|
||||
private SkillRankProperty arcaneForging = new SkillRankProperty(10, 25, 35, 50, 65, 75, 85, 100);
|
||||
|
||||
@Setting(value = "Repair-Mastery")
|
||||
private SkillRankProperty repairMastery = new SkillRankProperty(75);
|
||||
|
||||
@Setting(value = "Super-Repair")
|
||||
private SkillRankProperty superRepair = new SkillRankProperty(40);
|
||||
|
||||
public SkillRankProperty getArcaneForging() {
|
||||
return arcaneForging;
|
||||
}
|
||||
|
||||
public SkillRankProperty getRepairMastery() {
|
||||
return repairMastery;
|
||||
}
|
||||
|
||||
public SkillRankProperty getSuperRepair() {
|
||||
return superRepair;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
@ConfigSerializable
|
||||
public class ConfigRanksSwords {
|
||||
|
||||
@Setting(value = "Limit-Break")
|
||||
@Setting(value = "Swords-Limit-Break")
|
||||
private SkillRankProperty limitBreak = new SkillRankProperty(10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
|
||||
|
||||
@Setting(value = "Stab")
|
||||
|
@ -6,7 +6,7 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
@ConfigSerializable
|
||||
public class ConfigRanksUnarmed {
|
||||
|
||||
@Setting(value = "Limit-Break")
|
||||
@Setting(value = "Unarmed-Limit-Break")
|
||||
private SkillRankProperty limitBreak = new SkillRankProperty(10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
|
||||
|
||||
@Setting(value = "Berserk")
|
||||
|
@ -36,7 +36,7 @@ public enum PrimarySkillType {
|
||||
ACROBATICS(AcrobaticsManager.class, Color.WHITE,
|
||||
ImmutableList.of(SubSkillType.ACROBATICS_DODGE, SubSkillType.ACROBATICS_ROLL), "Acrobatics"),
|
||||
ALCHEMY(AlchemyManager.class, Color.FUCHSIA,
|
||||
ImmutableList.of(SubSkillType.ALCHEMY_CATALYSIS, SubSkillType.ALCHEMY_CONCOCTIONS), "Alchemy"),
|
||||
ImmutableList.of(), "Alchemy"),
|
||||
ARCHERY(ArcheryManager.class, Color.MAROON,
|
||||
ImmutableList.of(SubSkillType.ARCHERY_DAZE, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK, SubSkillType.ARCHERY_ARROW_RETRIEVAL, SubSkillType.ARCHERY_SKILL_SHOT), "Archery"),
|
||||
AXES(AxesManager.class, Color.AQUA, SuperAbilityType.SKULL_SPLITTER, ToolType.AXE,
|
||||
@ -44,7 +44,7 @@ public enum PrimarySkillType {
|
||||
EXCAVATION(ExcavationManager.class, Color.fromRGB(139, 69, 19), SuperAbilityType.GIGA_DRILL_BREAKER, ToolType.SHOVEL,
|
||||
ImmutableList.of(SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER, SubSkillType.EXCAVATION_ARCHAEOLOGY), "Excavation"),
|
||||
FISHING(FishingManager.class, Color.NAVY,
|
||||
ImmutableList.of(SubSkillType.FISHING_FISHERMANS_DIET, SubSkillType.FISHING_TREASURE_HUNTER, SubSkillType.FISHING_ICE_FISHING, SubSkillType.FISHING_MAGIC_HUNTER, SubSkillType.FISHING_MASTER_ANGLER, SubSkillType.FISHING_SHAKE), "Fishing"),
|
||||
ImmutableList.of(SubSkillType.FISHING_FISHERMANS_DIET, SubSkillType.FISHING_TREASURE_HUNTER, SubSkillType.FISHING_ICE_FISHING, SubSkillType.FISHING_MAGIC_HUNTER, SubSkillType.FISHING_MASTER_ANGLER, SubSkillType.FISHING_SHAKE, SubSkillType.FISHING_INNER_PEACE), "Fishing"),
|
||||
HERBALISM(HerbalismManager.class, Color.GREEN, SuperAbilityType.GREEN_TERRA, ToolType.HOE,
|
||||
ImmutableList.of(SubSkillType.HERBALISM_GREEN_TERRA, SubSkillType.HERBALISM_FARMERS_DIET, SubSkillType.HERBALISM_GREEN_THUMB, SubSkillType.HERBALISM_DOUBLE_DROPS, SubSkillType.HERBALISM_HYLIAN_LUCK, SubSkillType.HERBALISM_SHROOM_THUMB), "Herbalism"),
|
||||
MINING(MiningManager.class, Color.GRAY, SuperAbilityType.SUPER_BREAKER, ToolType.PICKAXE,
|
||||
@ -151,6 +151,8 @@ public enum PrimarySkillType {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().severe("Unable to locate parent for "+subSkillType.toString());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,6 @@ public enum SubSkillType {
|
||||
ACROBATICS_ROLL,
|
||||
|
||||
/* ALCHEMY */
|
||||
ALCHEMY_CATALYSIS(1),
|
||||
ALCHEMY_CONCOCTIONS(8),
|
||||
|
||||
/* ARCHERY */
|
||||
ARCHERY_ARROW_RETRIEVAL(1),
|
||||
|
@ -222,9 +222,13 @@ public class InventoryListener implements Listener {
|
||||
|
||||
HumanEntity whoClicked = event.getWhoClicked();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.isSubSkillEnabled(whoClicked, SubSkillType.ALCHEMY_CONCOCTIONS)) {
|
||||
//TODO: This is where Alchemy permissions used to be checked
|
||||
//TODO: This is where Alchemy permissions used to be checked
|
||||
//TODO: This is where Alchemy permissions used to be checked
|
||||
//TODO: This is where Alchemy permissions used to be checked
|
||||
/*if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.isSubSkillEnabled(whoClicked, SubSkillType.ALCHEMY_CONCOCTIONS)) {
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
Player player = (Player) whoClicked;
|
||||
|
||||
@ -328,9 +332,13 @@ public class InventoryListener implements Listener {
|
||||
|
||||
HumanEntity whoClicked = event.getWhoClicked();
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.isSubSkillEnabled(whoClicked, SubSkillType.ALCHEMY_CONCOCTIONS)) {
|
||||
//TODO: This is where alchemy permissions used to be checked
|
||||
//TODO: This is where alchemy permissions used to be checked
|
||||
//TODO: This is where alchemy permissions used to be checked
|
||||
//TODO: This is where alchemy permissions used to be checked
|
||||
/*if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.isSubSkillEnabled(whoClicked, SubSkillType.ALCHEMY_CONCOCTIONS)) {
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
// if (!event.getInventorySlots().contains(Alchemy.INGREDIENT_SLOT)) {
|
||||
// return;
|
||||
|
@ -380,12 +380,14 @@ public class RankUtils {
|
||||
|
||||
try {
|
||||
SkillRankProperty skillRankProperty
|
||||
= rankConfigRoot.getNode(subSkillType.getParentSkill())
|
||||
= (SkillRankProperty) rankConfigRoot.getNode(subSkillType.getParentSkill().getCapitalizedName())
|
||||
.getNode(subSkillType.getHoconFriendlyConfigName())
|
||||
.getValue(TypeToken.of(SkillRankProperty.class));
|
||||
|
||||
return skillRankProperty.getUnlockLevel(mcMMO.isRetroModeEnabled(), rank);
|
||||
} catch (ObjectMappingException | MissingSkillPropertyDefinition e) {
|
||||
int unlockLevel = skillRankProperty.getUnlockLevel(mcMMO.isRetroModeEnabled(), rank);
|
||||
return unlockLevel;
|
||||
|
||||
} catch (ObjectMappingException | MissingSkillPropertyDefinition | NullPointerException e) {
|
||||
mcMMO.p.getLogger().severe("Error traversing nodes to SkillRankProperty for "+subSkillType.toString());
|
||||
mcMMO.p.getLogger().severe("This indicates a problem with your rank config file, edit the file and correct the issue or delete it to generate a new default one with correct values.");
|
||||
e.printStackTrace();
|
||||
|
Loading…
Reference in New Issue
Block a user