aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-09-20 14:23:35 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-09-20 14:23:35 +0800
commite08e61e420b520c0442d4302a5db5e9d6f8e9356 (patch)
tree61d14f8336372832184709f6315ece6197844e4b /src
parent627cddaf0aaf22058fd9788870a1b5a63502aeff (diff)
downloadSoopyV2-e08e61e420b520c0442d4302a5db5e9d6f8e9356.tar.gz
SoopyV2-e08e61e420b520c0442d4302a5db5e9d6f8e9356.tar.bz2
SoopyV2-e08e61e420b520c0442d4302a5db5e9d6f8e9356.zip
potion time left
Diffstat (limited to 'src')
-rw-r--r--src/features/dataLoader/index.js1
-rw-r--r--src/features/hud/index.js86
-rw-r--r--src/features/waypoints/index.js6
-rw-r--r--src/metadata.json4
-rw-r--r--src/utils/numberUtils.js3
5 files changed, 94 insertions, 6 deletions
diff --git a/src/features/dataLoader/index.js b/src/features/dataLoader/index.js
index b2a273d..fd72648 100644
--- a/src/features/dataLoader/index.js
+++ b/src/features/dataLoader/index.js
@@ -56,6 +56,7 @@ class DataLoader extends Feature {
this.currentMayorPerks = new Set()
this.loadedApiDatas = {}
+ this.isInDungeon = false
this.partyMembers = new Set()
this.partyMembers.add(Player.getName())
diff --git a/src/features/hud/index.js b/src/features/hud/index.js
index 8805dac..cb94cbe 100644
--- a/src/features/hud/index.js
+++ b/src/features/hud/index.js
@@ -10,7 +10,7 @@ import DropdownSetting from "../settings/settingThings/dropdownSetting";
import { getLevelByXp } from "../../utils/statUtils";
import { firstLetterCapital } from "../../utils/stringUtils";
import renderLibs from "../../../guimanager/renderLibs";
-import { addNotation, numberWithCommas } from "../../utils/numberUtils.js";
+import { addNotation, basiclyEqual, numberWithCommas, timeNumber, timeNumber2 } from "../../utils/numberUtils.js";
const ProcessBuilder = Java.type("java.lang.ProcessBuilder")
const Scanner = Java.type("java.util.Scanner")
@@ -201,6 +201,21 @@ class Hud extends Feature {
hudStatTypes["mythril_powder"] = "Mithril Powder"
hudStatTypes["gemstone_powder"] = "Gemstone Powder"
+ this.potsExpireAt = {}
+
+ this.potsOutAlert = new ToggleSetting("Alert when pots are about to run out", "Will show in chat", true, "pots_out_alert", this)
+ this.showPotsHud = new ToggleSetting("Show Pots On Hud", "", false, "pots_hud", this)
+ this.potsHudElement = new HudTextElement()
+ .setText("&6Potions&7> &fLoading...")
+ .setToggleSetting(this.showPotsHud)
+ .setLocationSetting(new LocationSetting("Pots Hud Location", "Allows you to edit the location of the pots hud", "pots_hud_location", this, [10, 100, 1, 1])
+ .requires(this.showPotsHud)
+ .editTempText("&6God potion&7> &f28h 32m"))
+ this.hudElements.push(this.potsHudElement)
+
+ this.lastPotAlerts = {}
+ this.registerStep(false, 1, this.updatePotsTime)
+
this.extendLevelCap = new ToggleSetting("Hud Stat Ignore Skill Level Cap", "level cap goes over 60 requiring 50m xp per level", false, "hud_ignore_level_cap", this).contributor("EmeraldMerchant")
this.showLevelUpMessage = new ToggleSetting("Show level-up message", "Shows skyblock skills level-up message over level 60 in chat", true, "skill_o60_level_message", this).requires(this.extendLevelCap).contributor("EmeraldMerchant")
@@ -218,6 +233,7 @@ class Hud extends Feature {
if (this.hudStat[i - 1]) {
this.hudStat[i].enabled.requires(this.hudStat[i - 1].enabled)
}
+ this.hudElements.push(this.hudStat[i].textElement)
}
@@ -600,6 +616,73 @@ class Hud extends Feature {
this.soulflowElement.setText("&6Soulflow&7> &f" + this.numberUtils.numberWithCommas(this.lastStatData.soulflow))
}
+ updatePotsTime() {
+ if (!this.showPotsHud.getValue()) return
+ if (!this.FeatureManager.features["dataLoader"] || !this.FeatureManager.features["dataLoader"].class.isInSkyblock || this.FeatureManager.features["dataLoader"].class.isInDungeon) {
+ this.potsHudElement.setText("")
+ return
+ }
+
+ let text = ""
+
+ let godPotTime = -1
+ if (this.potsExpireAt["water_breathing"]?.level === 6
+ && this.potsExpireAt["resistance"]?.level === 8
+ && basiclyEqual(this.potsExpireAt["water_breathing"]?.time, this.potsExpireAt["resistance"]?.time, 1000)) {
+ godPotTime = this.potsExpireAt["water_breathing"].time
+ }
+
+ if (godPotTime > 0) {
+ let timeLeft = ""
+ if (godPotTime - Date.now() > 60000 * 60) {
+ timeLeft = timeNumber2(godPotTime - Date.now())
+ } else {
+ timeLeft = timeNumber(godPotTime - Date.now())
+ }
+ text += `&6God potion&7>&f ${timeLeft}\n`
+
+ if (this.potsOutAlert.getValue() && godPotTime - Date.now() > 60000 && Date.now() - (this.lastPotAlerts["godpot"] || 0) > 2 * 60000) {
+ this.lastPotAlerts["godpot"] = Date.now()
+ ChatLib.chat(this.FeatureManager.messagePrefix + "Your God potion is about to run out!")
+ }
+ }
+
+ Object.keys(this.potsExpireAt).forEach(k => {
+ let potData = this.potsExpireAt[k]
+ if (potData.infinite) return
+ if (basiclyEqual(potData.time, godPotTime, 1000)) return
+
+ let potName = firstLetterCapital(k.replace(/_/g, " "))
+
+ if (this.potsOutAlert.getValue() && potData.time - Date.now() > 60000 && Date.now() - (this.lastPotAlerts[k] || 0) > 2 * 60000) {
+ this.lastPotAlerts[k] = Date.now()
+ ChatLib.chat(this.FeatureManager.messagePrefix + "Your " + potName + " is about to run out!")
+ }
+
+ let timeLeft = ""
+ if (potData.time - Date.now() > 60000 * 60) {
+ timeLeft = timeNumber2(potData.time - Date.now())
+ } else {
+ timeLeft = timeNumber(potData.time - Date.now())
+ }
+
+ text += `&6${potName} ${potData.level}&7> &f${timeLeft}\n`
+ })
+ this.potsHudElement.setText(text)
+ }
+
+ updatePotsData(data) {
+ this.potsExpireAt = {}
+ let now = Date.now()
+ data.active_effects.forEach(e => {
+ this.potsExpireAt[e.effect] = {
+ level: e.level,
+ time: now + e.ticks_remaining * 50,
+ infinite: e.infinite
+ }
+ })
+ }
+
statApiLoadThingo(data) {
data.profiles.forEach(p => {
if (!this.lastStatData || (p.members[Player.getUUID().toString().replace(/-/g, "")] && p.members[Player.getUUID().toString().replace(/-/g, "")].last_save > this.lastStatData.last_save)) {
@@ -608,6 +691,7 @@ class Hud extends Feature {
})
if (this.lastStatData) {
+ this.updatePotsData(this.lastStatData)
if (this.lastStatData.soulflow) this.apiSoulflow = true
if (this.apiSoulflow) this.soulflowElement.setText("&6Soulflow&7> &f" + this.numberUtils.numberWithCommas(this.lastStatData.soulflow))
diff --git a/src/features/waypoints/index.js b/src/features/waypoints/index.js
index 41b83d1..ef5a5b8 100644
--- a/src/features/waypoints/index.js
+++ b/src/features/waypoints/index.js
@@ -38,7 +38,7 @@ class Waypoints extends Feature {
this.loadWaypointsFromSendCoords = new ToggleSetting("Load waypoints from /patcher sendcoords messages", "Will dissapear after 1min", true, "load_waypoints_from_sendcoords", this)
this.mineWaypointsSetting = new ToggleSetting("CH waypoints", "Will sync between users", true, "minwaypoints", this)
- this.orderedWaypointsLine = new ToggleSetting("CH waypoints", "Draw a line from current to next ordered waypoint", false, "order_waypoints_line", this)
+ this.orderedWaypointsLine = new ToggleSetting("Ordered waypoints line", "Draw a line from you to next ordered waypoint", false, "order_waypoints_line", this)
try {
this.userWaypoints = JSON.parse(FileLib.read("soopyAddonsData", "soopyv2userwaypoints.json") || "{}")
@@ -206,8 +206,8 @@ class Waypoints extends Feature {
drawCoolWaypoint(nextWaypoint[0], nextWaypoint[1], nextWaypoint[2], 0, 255, 0, { name: nextWaypoint[3] })
}
- if (this.orderedWaypointsLine.getValue() && currentWaypoint && nextWaypoint) {
- drawLine(currentWaypoint[0] + 0.5, currentWaypoint[1], currentWaypoint[2] + 0.5, nextWaypoint[0] + 0.5, nextWaypoint[1], nextWaypoint[2] + 0.5, 0, 255, 0)
+ if (this.orderedWaypointsLine.getValue() && nextWaypoint) {
+ drawLine(Player.getX(), Player.getY(), Player.getZ(), nextWaypoint[0] + 0.5, nextWaypoint[1], nextWaypoint[2] + 0.5, 0, 255, 0)
}
if (this.lastCloser === this.currentOrderedWaypointIndex && distanceTo1 > distanceTo2 && distanceTo2 < 15) {
diff --git a/src/metadata.json b/src/metadata.json
index 0fee5ab..232a9d6 100644
--- a/src/metadata.json
+++ b/src/metadata.json
@@ -5,8 +5,8 @@
"entry": "index.js",
"description": "SoopyV2",
"name": "SoopyV2",
- "version": "2.1.159",
- "versionId": 286,
+ "version": "2.1.160",
+ "versionId": 287,
"requires": [
"soopyApis",
"soopyAddonsData",
diff --git a/src/utils/numberUtils.js b/src/utils/numberUtils.js
index 8d5e7c3..60a4592 100644
--- a/src/utils/numberUtils.js
+++ b/src/utils/numberUtils.js
@@ -97,6 +97,9 @@ let utils = {
if (hours === 0) return mins + "m"
return `${hours}h ${mins}m`
+ },
+ basiclyEqual: (num1, num2, dist = 0.01) => {
+ return Math.abs(num1 - num2) < dist
}
}
module.exports = utils