diff options
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java index 73d61a1e..df981359 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java @@ -2,7 +2,6 @@ package io.github.moulberry.notenoughupdates.util; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.network.NetworkPlayerInfo; @@ -17,7 +16,6 @@ import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -115,7 +113,14 @@ public class SBInfo { return mode; } + private static final String profilePrefix = "\u00a7r\u00a7e\u00a7lProfile: \u00a7r\u00a7a"; + private static final String skillsPrefix = "\u00a7r\u00a7e\u00a7lSkills: \u00a7r\u00a7a"; + + private static final Pattern SKILL_LEVEL_PATTERN = Pattern.compile("([^0-9:]+) (\\d{1,2})"); + public void tick() { + isInDungeon = false; + long currentTime = System.currentTimeMillis(); if(Minecraft.getMinecraft().thePlayer != null && @@ -130,9 +135,17 @@ public class SBInfo { try { for(NetworkPlayerInfo info : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info); - final String profilePrefix = "\u00a7r\u00a7e\u00a7lProfile: \u00a7r\u00a7a"; if(name.startsWith(profilePrefix)) { currentProfile = Utils.cleanColour(name.substring(profilePrefix.length())); + } else if(name.startsWith(skillsPrefix)) { + String levelInfo = name.substring(skillsPrefix.length()).trim(); + Matcher matcher = SKILL_LEVEL_PATTERN.matcher(Utils.cleanColour(levelInfo).split(":")[0]); + if(matcher.find()) { + try { + int level = Integer.parseInt(matcher.group(2).trim()); + XPInformation.getInstance().updateLevel(matcher.group(1).toLowerCase().trim(), level); + } catch(Exception ignored) {} + } } } } catch(Exception e) { |
