aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2021-06-25 23:27:34 -0400
committerbowser0000 <bowser0000@gmail.com>2021-06-25 23:27:34 -0400
commit6e2a26294383a67691d837dbbdd00adffbe70a80 (patch)
treea308b1168a79d2d3f65342bd27a845f917d979ae /src/main/java
parent5c7c3d0f5ca04df48c2b8f054a662300e9f0d14b (diff)
downloadSkyblockMod-6e2a26294383a67691d837dbbdd00adffbe70a80.tar.gz
SkyblockMod-6e2a26294383a67691d837dbbdd00adffbe70a80.tar.bz2
SkyblockMod-6e2a26294383a67691d837dbbdd00adffbe70a80.zip
Fix issues with skill features
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/me/Danker/DankersSkyblockMod.java25
-rw-r--r--src/main/java/me/Danker/features/Skill50Display.java11
-rw-r--r--src/main/java/me/Danker/features/SkillTracker.java10
-rw-r--r--src/main/java/me/Danker/utils/Utils.java21
4 files changed, 48 insertions, 19 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java
index f1c8c1c..92c30e7 100644
--- a/src/main/java/me/Danker/DankersSkyblockMod.java
+++ b/src/main/java/me/Danker/DankersSkyblockMod.java
@@ -379,23 +379,14 @@ public class DankersSkyblockMod {
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);
+ farmingLevel = Utils.initializeSkill(invSlots.get(19).getStack(), "farming");
+ miningLevel = Utils.initializeSkill(invSlots.get(20).getStack(), "mining");
+ combatLevel = Utils.initializeSkill(invSlots.get(21).getStack(), "combat");
+ foragingLevel = Utils.initializeSkill(invSlots.get(22).getStack(), "foraging");
+ fishingLevel = Utils.initializeSkill(invSlots.get(23).getStack(), "fishing");
+ enchantingLevel = Utils.initializeSkill(invSlots.get(24).getStack(), "enchanting");
+ alchemyLevel = Utils.initializeSkill(invSlots.get(25).getStack(), "alchemy");
+ carpentryLevel = Utils.initializeSkill(invSlots.get(29).getStack(), "carpentry");
System.out.println("Updated skill levels.");
}
diff --git a/src/main/java/me/Danker/features/Skill50Display.java b/src/main/java/me/Danker/features/Skill50Display.java
index d7b759e..230189e 100644
--- a/src/main/java/me/Danker/features/Skill50Display.java
+++ b/src/main/java/me/Danker/features/Skill50Display.java
@@ -45,7 +45,16 @@ public class Skill50Display {
limit = 50;
totalXp = 55172425;
}
- int previousXp = Utils.getPastXpEarned(Integer.parseInt(section.substring(section.indexOf("/") + 1, section.indexOf(")")).replaceAll(",", "")), limit);
+
+ int nextLevelXp;
+ String nextLevelXpString = section.substring(section.indexOf("/") + 1, section.indexOf(")")).replaceAll(",", "");
+ if (nextLevelXpString.contains("k")) {
+ nextLevelXp = Integer.parseInt(nextLevelXpString.substring(0, nextLevelXpString.indexOf("k"))) * 1000;
+ } else {
+ nextLevelXp = Integer.parseInt(nextLevelXpString);
+ }
+
+ int previousXp = Utils.getPastXpEarned(nextLevelXp, limit);
double percentage = Math.floor(((currentXp + previousXp) / totalXp) * 10000D) / 100D;
NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
diff --git a/src/main/java/me/Danker/features/SkillTracker.java b/src/main/java/me/Danker/features/SkillTracker.java
index a2f3249..e71e8d2 100644
--- a/src/main/java/me/Danker/features/SkillTracker.java
+++ b/src/main/java/me/Danker/features/SkillTracker.java
@@ -68,7 +68,15 @@ public class SkillTracker {
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(",", ""));
+
+ int xpToLevelUp;
+ String nextLevelXpString = section.substring(section.indexOf("/") + 1, section.indexOf(")")).replaceAll(",", "");
+ if (nextLevelXpString.contains("k")) {
+ xpToLevelUp = Integer.parseInt(nextLevelXpString.substring(0, nextLevelXpString.indexOf("k"))) * 1000;
+ } else {
+ xpToLevelUp = Integer.parseInt(nextLevelXpString);
+ }
+
xpLeft = xpToLevelUp - currentXP;
int previousXP = Utils.getPastXpEarned(xpToLevelUp, limit);
totalXP = currentXP + previousXP;
diff --git a/src/main/java/me/Danker/utils/Utils.java b/src/main/java/me/Danker/utils/Utils.java
index 4acee7f..b828146 100644
--- a/src/main/java/me/Danker/utils/Utils.java
+++ b/src/main/java/me/Danker/utils/Utils.java
@@ -2,6 +2,7 @@ package me.Danker.utils;
import me.Danker.DankersSkyblockMod;
import me.Danker.features.GoldenEnchants;
+import me.Danker.handlers.ConfigHandler;
import me.Danker.handlers.ScoreboardHandler;
import me.Danker.handlers.TextRenderer;
import net.minecraft.block.Block;
@@ -574,6 +575,7 @@ public class Utils {
int number = 0;
for (int i = 0; i < text.length(); i++) {
+ if (!romanNumerals.containsKey(text.charAt(i))) continue;
int roman = romanNumerals.get(text.charAt(i));
if (i != text.length() - 1 && roman < romanNumerals.get(text.charAt(i + 1))) {
@@ -586,6 +588,7 @@ public class Utils {
return number;
}
+
return -1;
}
@@ -593,4 +596,22 @@ public class Utils {
return DankersSkyblockMod.miningLevel != -1;
}
+ public static int initializeSkill(ItemStack skillStack, String configValue) {
+ int level = -1;
+
+ if (skillStack != null) {
+ String display = skillStack.getDisplayName();
+ if (display.startsWith("§a")) {
+ if (display.contains(" ")) {
+ level = Utils.getIntFromString(display.substring(display.indexOf(" ") + 1), true);
+ } else {
+ level = 0;
+ }
+ }
+ }
+
+ ConfigHandler.writeIntConfig("skills", configValue, level);
+ return level;
+ }
+
}