diff options
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java index c88d09f9..7277f884 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java @@ -6,6 +6,7 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import java.util.HashMap; @@ -34,10 +35,10 @@ public class XPInformation { private static Pattern SKILL_PATTERN = Pattern.compile("\\+(\\d+(?:\\.\\d+)?) (.+) \\((\\d+(?:,\\d+)*(?:\\.\\d+)?)/(\\d+(?:,\\d+)*(?:\\.\\d+)?)\\)"); public SkillInfo getSkillInfo(String skillName) { - return skillInfoMap.get(skillName); + return skillInfoMap.get(skillName.toLowerCase()); } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onChatReceived(ClientChatReceivedEvent event) { if(event.type == 2) { JsonObject leveling = Constants.LEVELING; @@ -71,7 +72,7 @@ public class XPInformation { skillInfo.level++; } - skillInfoMap.put(skillS, skillInfo); + skillInfoMap.put(skillS.toLowerCase(), skillInfo); } } } @@ -82,9 +83,23 @@ public class XPInformation { () -> {}, this::onApiUpdated); } + private static final String[] skills = {"taming","mining","foraging","enchanting","carpentry","farming","combat","fishing","alchemy","runecrafting"}; + private void onApiUpdated(ProfileViewer.Profile profile) { JsonObject skillInfo = profile.getSkillInfo(null); + for(String skill : skills) { + SkillInfo info = new SkillInfo(); + + float level = skillInfo.get("level_skill_"+skill).getAsFloat(); + + info.totalXp = skillInfo.get("experience_skill_"+skill).getAsFloat(); + info.currentXpMax = skillInfo.get("maxxp_skill_"+skill).getAsFloat(); + info.level = (int)level; + info.currentXp = (level%1)*info.currentXpMax; + + skillInfoMap.put(skill.toLowerCase(), info); + } } } |
