aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2021-06-15 20:34:51 -0400
committerbowser0000 <bowser0000@gmail.com>2021-06-15 20:34:51 -0400
commitd52c64ca20fa8df90f0e4496a954328335803725 (patch)
tree2ad18f03a70aa839cb1251419be1739010a7d311 /src/main/java
parent848579b82d0d8edcde3e8e391a86a926a85b5a82 (diff)
downloadSkyblockMod-d52c64ca20fa8df90f0e4496a954328335803725.tar.gz
SkyblockMod-d52c64ca20fa8df90f0e4496a954328335803725.tar.bz2
SkyblockMod-d52c64ca20fa8df90f0e4496a954328335803725.zip
Add support for percentage skill bar
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/me/Danker/DankersSkyblockMod.java80
-rw-r--r--src/main/java/me/Danker/features/AutoDisplay.java1
-rw-r--r--src/main/java/me/Danker/features/ColouredNames.java2
-rw-r--r--src/main/java/me/Danker/features/Skill50Display.java45
-rw-r--r--src/main/java/me/Danker/features/SkillTracker.java169
-rw-r--r--src/main/java/me/Danker/handlers/ConfigHandler.java10
-rw-r--r--src/main/java/me/Danker/utils/Utils.java56
7 files changed, 280 insertions, 83 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java
index c9aaa26..f1c8c1c 100644
--- a/src/main/java/me/Danker/DankersSkyblockMod.java
+++ b/src/main/java/me/Danker/DankersSkyblockMod.java
@@ -60,6 +60,7 @@ import javax.sound.sampled.UnsupportedAudioFileException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;
@@ -79,6 +80,15 @@ public class DankersSkyblockMod {
public static boolean firstLaunch = false;
public static String configDirectory;
public static JsonObject data = null;
+
+ public static int farmingLevel;
+ public static int miningLevel;
+ public static int combatLevel;
+ public static int foragingLevel;
+ public static int fishingLevel;
+ public static int enchantingLevel;
+ public static int alchemyLevel;
+ public static int carpentryLevel;
public static String MAIN_COLOUR;
public static String SECONDARY_COLOUR;
@@ -268,12 +278,47 @@ public class DankersSkyblockMod {
@SubscribeEvent
public void onChat(ClientChatReceivedEvent event) {
- String message = StringUtils.stripControlCodes(event.message.getUnformattedText());
+ String message = StringUtils.stripControlCodes(event.message.getUnformattedText());
if (message.startsWith("Your new API key is ") && Utils.isOnHypixel()) {
String apiKey = event.message.getSiblings().get(0).getChatStyle().getChatClickEvent().getValue();
ConfigHandler.writeStringConfig("api", "APIKey", apiKey);
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Set API key to " + DankersSkyblockMod.SECONDARY_COLOUR + apiKey));
+ } else if (Utils.inSkyblock && !message.contains(":") && message.contains(" SKILL LEVEL UP ")) {
+ // Handle skill level ups
+ String skill = message.substring(message.indexOf("UP") + 3, message.lastIndexOf(" "));
+ int level = Utils.getIntFromString(message.substring(message.indexOf("➜") + 1), true);
+
+ switch (skill) {
+ case "Farming":
+ DankersSkyblockMod.farmingLevel = level;
+ break;
+ case "Mining":
+ DankersSkyblockMod.miningLevel = level;
+ break;
+ case "Combat":
+ DankersSkyblockMod.combatLevel = level;
+ break;
+ case "Foraging":
+ DankersSkyblockMod.foragingLevel = level;
+ break;
+ case "Fishing":
+ DankersSkyblockMod.fishingLevel = level;
+ break;
+ case "Enchanting":
+ DankersSkyblockMod.enchantingLevel = level;
+ break;
+ case "Alchemy":
+ DankersSkyblockMod.alchemyLevel = level;
+ break;
+ case "Carpentry":
+ DankersSkyblockMod.carpentryLevel = level;
+ break;
+ default:
+ System.err.println("Unknown skill leveled up.");
+ }
+
+ ConfigHandler.writeIntConfig("skills", skill.toLowerCase(Locale.US), level);
}
}
@@ -306,7 +351,8 @@ public class DankersSkyblockMod {
public void onTick(TickEvent.ClientTickEvent event) {
if (event.phase != Phase.START) return;
- EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
+ Minecraft mc = Minecraft.getMinecraft();
+ EntityPlayerSP player = mc.thePlayer;
tickAmount++;
if (tickAmount % 20 == 0) {
@@ -324,6 +370,36 @@ public class DankersSkyblockMod {
}
titleTimer--;
}
+
+ // New skill level detection
+ if (mc.currentScreen instanceof GuiChest && tickAmount % 5 == 0 && player != null) {
+ ContainerChest chest = (ContainerChest) player.openContainer;
+ String chestName = chest.getLowerChestInventory().getDisplayName().getUnformattedText().trim();
+
+ if (chestName.equals("Your Skills")) {
+ List<Slot> invSlots = ((GuiChest) mc.currentScreen).inventorySlots.inventorySlots;
+
+ farmingLevel = Utils.getIntFromString(invSlots.get(19).getStack().getDisplayName().substring(invSlots.get(19).getStack().getDisplayName().indexOf(" ") + 1), true);
+ miningLevel = Utils.getIntFromString(invSlots.get(20).getStack().getDisplayName().substring(invSlots.get(20).getStack().getDisplayName().indexOf(" ") + 1), true);
+ combatLevel = Utils.getIntFromString(invSlots.get(21).getStack().getDisplayName().substring(invSlots.get(21).getStack().getDisplayName().indexOf(" ") + 1), true);
+ foragingLevel = Utils.getIntFromString(invSlots.get(22).getStack().getDisplayName().substring(invSlots.get(22).getStack().getDisplayName().indexOf(" ") + 1), true);
+ fishingLevel = Utils.getIntFromString(invSlots.get(23).getStack().getDisplayName().substring(invSlots.get(23).getStack().getDisplayName().indexOf(" ") + 1), true);
+ enchantingLevel = Utils.getIntFromString(invSlots.get(24).getStack().getDisplayName().substring(invSlots.get(24).getStack().getDisplayName().indexOf(" ") + 1), true);
+ alchemyLevel = Utils.getIntFromString(invSlots.get(25).getStack().getDisplayName().substring(invSlots.get(25).getStack().getDisplayName().indexOf(" ") + 1), true);
+ carpentryLevel = Utils.getIntFromString(invSlots.get(29).getStack().getDisplayName().substring(invSlots.get(29).getStack().getDisplayName().indexOf(" ") + 1), true);
+
+ ConfigHandler.writeIntConfig("skills", "farming", farmingLevel);
+ ConfigHandler.writeIntConfig("skills", "mining", miningLevel);
+ ConfigHandler.writeIntConfig("skills", "combat", combatLevel);
+ ConfigHandler.writeIntConfig("skills", "foraging", foragingLevel);
+ ConfigHandler.writeIntConfig("skills", "fishing", fishingLevel);
+ ConfigHandler.writeIntConfig("skills", "enchanting", enchantingLevel);
+ ConfigHandler.writeIntConfig("skills", "alchemy", alchemyLevel);
+ ConfigHandler.writeIntConfig("skills", "carpentry", carpentryLevel);
+
+ System.out.println("Updated skill levels.");
+ }
+ }
}
// Delay GUI by 1 tick
diff --git a/src/main/java/me/Danker/features/AutoDisplay.java b/src/main/java/me/Danker/features/AutoDisplay.java
index 783c428..bead243 100644
--- a/src/main/java/me/Danker/features/AutoDisplay.java
+++ b/src/main/java/me/Danker/features/AutoDisplay.java
@@ -6,7 +6,6 @@ import me.Danker.handlers.ConfigHandler;
import me.Danker.handlers.ScoreboardHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
-import net.minecraft.client.settings.GameSettings;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
diff --git a/src/main/java/me/Danker/features/ColouredNames.java b/src/main/java/me/Danker/features/ColouredNames.java
index eec2d5c..478a47d 100644
--- a/src/main/java/me/Danker/features/ColouredNames.java
+++ b/src/main/java/me/Danker/features/ColouredNames.java
@@ -22,14 +22,12 @@ public class ColouredNames {
@SubscribeEvent
public void onChat(ClientChatReceivedEvent event) {
if (!ToggleCommand.customColouredNames || !Utils.inSkyblock || event.type != 0) return;
- long startTime = System.currentTimeMillis();
for (String user : users) {
if (event.message.getFormattedText().contains(user)) {
event.message = replaceChat(event.message, user);
}
}
- System.out.println("Chat time: " + ((System.currentTimeMillis() - startTime) / 1000D) + "s");
}
@SubscribeEvent
diff --git a/src/main/java/me/Danker/features/Skill50Display.java b/src/main/java/me/Danker/features/Skill50Display.java
index 3b73cf9..d7b759e 100644
--- a/src/main/java/me/Danker/features/Skill50Display.java
+++ b/src/main/java/me/Danker/features/Skill50Display.java
@@ -1,5 +1,6 @@
package me.Danker.features;
+import me.Danker.DankersSkyblockMod;
import me.Danker.commands.MoveCommand;
import me.Danker.commands.ScaleCommand;
import me.Danker.commands.ToggleCommand;
@@ -7,6 +8,7 @@ import me.Danker.events.RenderOverlay;
import me.Danker.handlers.TextRenderer;
import me.Danker.utils.Utils;
import net.minecraft.client.Minecraft;
+import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -30,8 +32,8 @@ public class Skill50Display {
String[] actionBarSections = event.message.getUnformattedText().split(" {3,}");
for (String section : actionBarSections) {
- if (section.contains("+") && section.contains("/") && section.contains("(")) {
- if (ToggleCommand.skill50DisplayToggled && !section.contains("Runecrafting")) {
+ if (ToggleCommand.skill50DisplayToggled && section.contains("+") && section.contains("(") && section.contains(")") && !section.contains("Runecrafting")) {
+ if (section.contains("/")) {
String xpGained = section.substring(section.indexOf("+"), section.indexOf("(") - 1);
double currentXp = Double.parseDouble(section.substring(section.indexOf("(") + 1, section.indexOf("/")).replace(",", ""));
int limit;
@@ -50,6 +52,40 @@ public class Skill50Display {
skillTimer = SKILL_TIME;
showSkill = true;
skillText = SKILL_50_COLOUR + xpGained + " (" + nf.format(currentXp + previousXp) + "/" + nf.format(totalXp) + ") " + percentage + "%";
+ } else {
+ if (!Utils.skillsInitialized()) {
+ return;
+ }
+
+ String xpGained = section.substring(section.indexOf("+"), section.indexOf("(") - 1);
+ double percentage = Double.parseDouble(section.substring(section.indexOf("(") + 1, section.indexOf("%")));
+ int level = 1;
+ if (section.contains("Farming")) {
+ level = DankersSkyblockMod.farmingLevel;
+ } else if (section.contains("Mining")) {
+ level = DankersSkyblockMod.miningLevel;
+ } else if (section.contains("Combat")) {
+ level = DankersSkyblockMod.combatLevel;
+ } else if (section.contains("Foraging")) {
+ level = DankersSkyblockMod.foragingLevel;
+ } else if (section.contains("Fishing")) {
+ level = DankersSkyblockMod.fishingLevel;
+ } else if (section.contains("Enchanting")) {
+ level = DankersSkyblockMod.enchantingLevel;
+ } else if (section.contains("Alchemy")) {
+ level = DankersSkyblockMod.alchemyLevel;
+ } else if (section.contains("Carpentry")) {
+ level = DankersSkyblockMod.carpentryLevel;
+ }
+
+ double currentXp = Utils.getTotalXpEarned(level, percentage);
+ int totalXp = section.contains("Farming") || section.contains("Enchanting") || section.contains("Mining") || section.contains("Combat") ? 111672425 : 55172425;
+ double percentageTo50 = Math.floor((currentXp / totalXp) * 10000D) / 100D;
+
+ NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
+ skillTimer = SKILL_TIME;
+ showSkill = true;
+ skillText = SKILL_50_COLOUR + xpGained + " (" + nf.format(currentXp) + "/" + nf.format(totalXp) + ") " + percentageTo50 + "%";
}
}
}
@@ -69,6 +105,11 @@ public class Skill50Display {
@SubscribeEvent
public void renderPlayerInfo(RenderOverlay event) {
+ if (!Utils.skillsInitialized()) {
+ new TextRenderer(Minecraft.getMinecraft(), EnumChatFormatting.RED + "Please open the skill menu to use skill features.", MoveCommand.skill50XY[0], MoveCommand.skill50XY[0], ScaleCommand.skill50Scale);
+ return;
+ }
+
if (showSkill) {
new TextRenderer(Minecraft.getMinecraft(), skillText, MoveCommand.skill50XY[0], MoveCommand.skill50XY[1], ScaleCommand.skill50Scale);
}
diff --git a/src/main/java/me/Danker/features/SkillTracker.java b/src/main/java/me/Danker/features/SkillTracker.java
index 60eb632..a2f3249 100644
--- a/src/main/java/me/Danker/features/SkillTracker.java
+++ b/src/main/java/me/Danker/features/SkillTracker.java
@@ -52,78 +52,106 @@ public class SkillTracker {
String[] actionBarSections = event.message.getUnformattedText().split(" {3,}");
for (String section : actionBarSections) {
- if (section.contains("+") && section.contains("/") && section.contains("(")) {
- if (!section.contains("Runecrafting") && !section.contains("Carpentry")) {
- if (ToggleCommand.autoSkillTrackerToggled && System.currentTimeMillis() / 1000 - timeSinceGained <= 2) {
- if (skillStopwatch.isStarted() && skillStopwatch.isSuspended()) {
- skillStopwatch.resume();
- } else if (!skillStopwatch.isStarted()) {
- skillStopwatch.start();
- }
+ if (section.contains("+") && section.contains("(") && section.contains(")") && !section.contains("Runecrafting") && !section.contains("Carpentry")) {
+ if (ToggleCommand.autoSkillTrackerToggled && System.currentTimeMillis() / 1000 - timeSinceGained <= 2) {
+ if (skillStopwatch.isStarted() && skillStopwatch.isSuspended()) {
+ skillStopwatch.resume();
+ } else if (!skillStopwatch.isStarted()) {
+ skillStopwatch.start();
}
- timeSinceGained = System.currentTimeMillis() / 1000;
+ }
+ timeSinceGained = System.currentTimeMillis() / 1000;
+
+ String skill = section.substring(section.indexOf(" ") + 1, section.lastIndexOf(" "));
+ double totalXP;
+ if (section.contains("/")) {
int limit = section.contains("Farming") || section.contains("Enchanting") || section.contains("Mining") || section.contains("Combat") ? 60 : 50;
double currentXP = Double.parseDouble(section.substring(section.indexOf("(") + 1, section.indexOf("/")).replace(",", ""));
int xpToLevelUp = Integer.parseInt(section.substring(section.indexOf("/") + 1, section.indexOf(")")).replaceAll(",", ""));
xpLeft = xpToLevelUp - currentXP;
int previousXP = Utils.getPastXpEarned(xpToLevelUp, limit);
- double totalXP = currentXP + previousXP;
-
- String skill = section.substring(section.indexOf(" ") + 1, section.lastIndexOf(" "));
- switch (skill) {
- case "Farming":
- lastSkill = "Farming";
- if (farmingXP != 0) {
- if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) farmingXPGained += totalXP - farmingXP;
- }
- farmingXP = totalXP;
- break;
- case "Mining":
- lastSkill = "Mining";
- if (miningXP != 0) {
- if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) miningXPGained += totalXP - miningXP;
- }
- miningXP = totalXP;
- break;
- case "Combat":
- lastSkill = "Combat";
- if (combatXP != 0) {
- if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) combatXPGained += totalXP - combatXP;
- }
- combatXP = totalXP;
- break;
- case "Foraging":
- lastSkill = "Foraging";
- if (foragingXP != 0) {
- if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) foragingXPGained += totalXP - foragingXP;
- }
- foragingXP = totalXP;
- break;
- case "Fishing":
- lastSkill = "Fishing";
- if (fishingXP != 0) {
- if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) fishingXPGained += totalXP - fishingXP;
- }
- fishingXP = totalXP;
- break;
- case "Enchanting":
- lastSkill = "Enchanting";
- if (enchantingXP != 0) {
- if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) enchantingXPGained += totalXP - enchantingXP;
- }
- enchantingXP = totalXP;
- break;
- case "Alchemy":
- lastSkill = "Alchemy";
- if (alchemyXP != 0) {
- if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) alchemyXPGained += totalXP - alchemyXP;
- }
- alchemyXP = totalXP;
- break;
- default:
- System.err.println("Unknown skill.");
+ totalXP = currentXP + previousXP;
+ } else {
+ if (!Utils.skillsInitialized()) {
+ return;
+ }
+
+ int level = 1;
+ if (section.contains("Farming")) {
+ level = DankersSkyblockMod.farmingLevel;
+ } else if (section.contains("Mining")) {
+ level = DankersSkyblockMod.miningLevel;
+ } else if (section.contains("Combat")) {
+ level = DankersSkyblockMod.combatLevel;
+ } else if (section.contains("Foraging")) {
+ level = DankersSkyblockMod.foragingLevel;
+ } else if (section.contains("Fishing")) {
+ level = DankersSkyblockMod.fishingLevel;
+ } else if (section.contains("Enchanting")) {
+ level = DankersSkyblockMod.enchantingLevel;
+ } else if (section.contains("Alchemy")) {
+ level = DankersSkyblockMod.alchemyLevel;
+ } else if (section.contains("Carpentry")) {
+ level = DankersSkyblockMod.carpentryLevel;
}
+
+ totalXP = Utils.getTotalXpEarned(level, Double.parseDouble(section.substring(section.indexOf("(") + 1, section.indexOf("%"))));
+ xpLeft = Utils.getTotalXpEarned(level + 1, 0) - totalXP;
+ }
+
+ switch (skill) {
+ case "Farming":
+ lastSkill = "Farming";
+ if (farmingXP != 0) {
+ if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) farmingXPGained += totalXP - farmingXP;
+ }
+ farmingXP = totalXP;
+ break;
+ case "Mining":
+ lastSkill = "Mining";
+ if (miningXP != 0) {
+ if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) miningXPGained += totalXP - miningXP;
+ }
+ miningXP = totalXP;
+ break;
+ case "Combat":
+ lastSkill = "Combat";
+ if (combatXP != 0) {
+ if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) combatXPGained += totalXP - combatXP;
+ }
+ combatXP = totalXP;
+ break;
+ case "Foraging":
+ lastSkill = "Foraging";
+ if (foragingXP != 0) {
+ if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) foragingXPGained += totalXP - foragingXP;
+ }
+ foragingXP = totalXP;
+ break;
+ case "Fishing":
+ lastSkill = "Fishing";
+ if (fishingXP != 0) {
+ if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) fishingXPGained += totalXP - fishingXP;
+ }
+ fishingXP = totalXP;
+ break;
+ case "Enchanting":
+ lastSkill = "Enchanting";
+ if (enchantingXP != 0) {
+ if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) enchantingXPGained += totalXP - enchantingXP;
+ }
+ enchantingXP = totalXP;
+ break;
+ case "Alchemy":
+ lastSkill = "Alchemy";
+ if (alchemyXP != 0) {
+ if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) alchemyXPGained += totalXP - alchemyXP;
+ }
+ alchemyXP = totalXP;
+ break;
+ default:
+ System.err.println("Unknown skill.");
}
}
}
@@ -132,6 +160,11 @@ public class SkillTracker {
@SubscribeEvent
public void renderPlayerInfo(RenderOverlay event) {
if (showSkillTracker && Utils.inSkyblock) {
+ if (!Utils.skillsInitialized()) {
+ new TextRenderer(Minecraft.getMinecraft(), EnumChatFormatting.RED + "Please open the skill menu to use skill features.", MoveCommand.skillTrackerXY[0], MoveCommand.skillTrackerXY[0], ScaleCommand.skillTrackerScale);
+ return;
+ }
+
int xpPerHour;
double xpToShow = 0;
switch (lastSkill) {
@@ -196,12 +229,8 @@ public class SkillTracker {
@SubscribeEvent
public void onGuiOpen(GuiOpenEvent event) {
- if (event.gui instanceof GuiChest) {
- if (ToggleCommand.autoSkillTrackerToggled) {
- if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) {
- skillStopwatch.suspend();
- }
- }
+ if (event.gui instanceof GuiChest && ToggleCommand.autoSkillTrackerToggled && skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) {
+ skillStopwatch.suspend();
}
}
diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java
index 250c1f2..c289dac 100644
--- a/src/main/java/me/Danker/handlers/ConfigHandler.java
+++ b/src/main/java/me/Danker/handlers/ConfigHandler.java
@@ -484,6 +484,16 @@ public class ConfigHandler {
ScaleCommand.teammatesInRadiusScale = initDouble("scales", "teammatesInRadiusScale", 1);
ScaleCommand.giantHPScale = initDouble("scales", "giantHPScale", 1);
+ // Skills
+ DankersSkyblockMod.farmingLevel = initInt("skills", "farming", -1);
+ DankersSkyblockMod.miningLevel = initInt("skills", "mining", -1);
+ DankersSkyblockMod.combatLevel = initInt("skills", "combat", -1);
+ DankersSkyblockMod.foragingLevel = initInt("skills", "foraging", -1);
+ DankersSkyblockMod.fishingLevel = initInt("skills", "fishing", -1);
+ DankersSkyblockMod.enchantingLevel = initInt("skills", "enchanting", -1);
+ DankersSkyblockMod.alchemyLevel = initInt("skills", "alchemy", -1);
+ DankersSkyblockMod.carpentryLevel = initInt("skills", "carpentry", -1);
+
// Colours
DankersSkyblockMod.MAIN_COLOUR = initString("colors", "main", EnumChatFormatting.GREEN.toString());
DankersSkyblockMod.SECONDARY_COLOUR = initString("colors", "secondary", EnumChatFormatting.DARK_GREEN.toString());
diff --git a/src/main/java/me/Danker/utils/Utils.java b/src/main/java/me/Danker/utils/Utils.java
index d3d6325..4acee7f 100644
--- a/src/main/java/me/Danker/utils/Utils.java
+++ b/src/main/java/me/Danker/utils/Utils.java
@@ -25,10 +25,8 @@ import net.minecraft.util.*;
import org.lwjgl.opengl.GL11;
import java.awt.*;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
import java.util.List;
+import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -47,6 +45,15 @@ public class Utils {
19000000, 24000000, 30000000, 38000000, 48000000, 60000000, 75000000, 93000000, 116250000};
static int[] expertiseKills = {50, 100, 250, 500, 1000, 2500, 5500, 10000, 15000};
static Pattern boldPattern = Pattern.compile("(?i)\\u00A7L");
+ static Map<Character, Integer> romanNumerals = new HashMap<Character, Integer>(){{
+ put('I', 1);
+ put('V', 5);
+ put('X', 10);
+ put('L', 50);
+ put('C', 100);
+ put('D', 500);
+ put('M', 1000);
+ }};
public static int getItems(String item) {
Minecraft mc = Minecraft.getMinecraft();
@@ -260,7 +267,8 @@ public class Utils {
}
return -1;
}
-
+
+ // Only used when over limit
public static int getPastXpEarned(int currentLevelXp, int limit) {
if (currentLevelXp == 0) {
int xpAdded = 0;
@@ -275,6 +283,16 @@ public class Utils {
}
return 0;
}
+
+ public static double getTotalXpEarned(int currentLevel, double percentage) {
+ double progress = 0;
+ if (currentLevel < 60) progress = skillXPPerLevel[currentLevel + 1] * (percentage / 100D);
+ double xpAdded = 0;
+ for (int i = 1; i <= currentLevel; i++) {
+ xpAdded += skillXPPerLevel[i];
+ }
+ return xpAdded + progress;
+ }
public static String getColouredBoolean(boolean bool) {
return bool ? EnumChatFormatting.GREEN + "On" : EnumChatFormatting.RED + "Off";
@@ -546,7 +564,33 @@ public class Utils {
}
public static String removeBold(String text) {
- return boldPattern.matcher(text).replaceAll("");
+ return boldPattern.matcher(text).replaceAll("");
}
-
+
+ public static int getIntFromString(String text, boolean romanNumeral) {
+ if (text.matches(".*\\d.*")) {
+ return Integer.parseInt(StringUtils.stripControlCodes(text).replaceAll("[^\\d]", ""));
+ } else if (romanNumeral) {
+ int number = 0;
+
+ for (int i = 0; i < text.length(); i++) {
+ int roman = romanNumerals.get(text.charAt(i));
+
+ if (i != text.length() - 1 && roman < romanNumerals.get(text.charAt(i + 1))) {
+ number += romanNumerals.get(text.charAt(i + 1)) - roman;
+ i++;
+ } else {
+ number += roman;
+ }
+ }
+
+ return number;
+ }
+ return -1;
+ }
+
+ public static boolean skillsInitialized() {
+ return DankersSkyblockMod.miningLevel != -1;
+ }
+
}