diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-08-04 20:38:05 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-08-04 20:38:05 +0800 |
commit | a5dbdbac4598852fce436a20155616634fc4718f (patch) | |
tree | 9da797a77c4b4336465776319c012000c5d5d4ec /features/globalSettings/index.js | |
parent | c9d34afde5042076b41673f4a3de7aa9e23e7e3b (diff) | |
download | SoopyV2-a5dbdbac4598852fce436a20155616634fc4718f.tar.gz SoopyV2-a5dbdbac4598852fce436a20155616634fc4718f.tar.bz2 SoopyV2-a5dbdbac4598852fce436a20155616634fc4718f.zip |
item worth
Diffstat (limited to 'features/globalSettings/index.js')
-rw-r--r-- | features/globalSettings/index.js | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/features/globalSettings/index.js b/features/globalSettings/index.js index c215ae8..e53c3f9 100644 --- a/features/globalSettings/index.js +++ b/features/globalSettings/index.js @@ -8,13 +8,13 @@ import firstLoadPages from "./firstLoadPages"; import GuiPage from "../soopyGui/GuiPage" import Notification from "../../../guimanager/Notification"; import logger from "../../logger"; -import soopyV2Server from "../../socketConnection"; import { numberWithCommas } from "../../utils/numberUtils"; import { firstLetterCapital } from "../../utils/stringUtils"; import { fetch } from "../../utils/networkUtils"; import socketConnection from "../../socketConnection"; import renderLibs from "../../../guimanager/renderLibs"; import { f } from "../../../mappings/mappings"; +import { addLore, getSBUUID } from "../../utils/utils"; const Files = Java.type("java.nio.file.Files") const Paths = Java.type("java.nio.file.Paths") const JavaString = Java.type("java.lang.String") @@ -48,6 +48,7 @@ class GlobalSettings extends Feature { this.hideFallingBlocks = new ToggleSetting("Hide falling blocks", "NOTE: this may cause more lag because of render entity event", false, "hide_falling_sand", this) this.twitchCommands = new ToggleSetting("Ingame twitch bot commands", "Allows u to use twitch bot commands ingame (eg -sa)", true, "twitch_commands_ingame", this) + this.itemWorth = new ToggleSetting("(Approximate) Item worth in lore", "Accounts for stuff like enchants/recombs ect", false, "item_worth", this) this.privacySettings = [] @@ -85,6 +86,12 @@ class GlobalSettings extends Feature { this.registerEvent("tick", this.fixNEU) } + this.requestingPrices = new Set() + this.registerStep(false, 1, this.updateItemPrices) + this.registerEvent("worldLoad", () => { + this.requestingPrices.clear() + }) + try { //This enables links from soopy.dev to be shown in patcher image preview let hasHost = false @@ -160,6 +167,34 @@ class GlobalSettings extends Feature { }) } + updateItemPrices() { + if (!this.itemWorth.getValue()) return; + + [...Player.getInventory().getItems(), ...Player.getContainer().getItems()].forEach(i => { + let uuid = getSBUUID(i) + if (!uuid) return + + let a = socketConnection.itemPricesCache.get(uuid) + + if (!a && socketConnection.itemPricesCache2.get(uuid)) { + a = socketConnection.itemPricesCache2.get(uuid) + socketConnection.itemPricesCache.set(uuid, a) + } + + if (a) { + addLore(i, "§eWorth: ", "§6$" + numberWithCommas(Math.round(a))) + return + } + + if (this.requestingPrices.has(uuid)) return + + this.requestingPrices.add(uuid) + + let json = i.getNBT().toObject() + socketConnection.requestItemPrice(json, uuid) + }) + } + // renderWebpage() { // let url = this.getField(Client.currentGui.get(), f.linkText) |