diff options
-rw-r--r-- | features/globalSettings/index.js | 4 | ||||
-rw-r--r-- | features/hud/index.js | 33 |
2 files changed, 35 insertions, 2 deletions
diff --git a/features/globalSettings/index.js b/features/globalSettings/index.js index 11d8d9a..89adc5c 100644 --- a/features/globalSettings/index.js +++ b/features/globalSettings/index.js @@ -82,10 +82,10 @@ class GlobalSettings extends Feature { this.lastCookies = 0 this.registerEvent("postGuiRender", () => { - if (Player.getContainer().getName() === "Cookie Clicker v0.01" && Player.getContainer().getStackInSlot(13)) this.renderCookie() + if (Player.getContainer() && Player.getContainer().getName() === "Cookie Clicker v0.01" && Player.getContainer().getStackInSlot(13)) this.renderCookie() }) this.registerStep(false, 1, () => { - if (Player.getContainer().getName() === "Cookie Clicker v0.01" && Player.getContainer().getStackInSlot(13)) this.tickCookie() + if (Player.getContainer() && Player.getContainer().getName() === "Cookie Clicker v0.01" && Player.getContainer().getStackInSlot(13)) this.tickCookie() }) this.registerEvent("guiMouseClick", this.guiClicked) diff --git a/features/hud/index.js b/features/hud/index.js index 8609a72..9657f06 100644 --- a/features/hud/index.js +++ b/features/hud/index.js @@ -154,6 +154,8 @@ class Hud extends Feature { "experience_skill_taming": 50, }; + this.spotifyProcessId = -1 + Object.keys(this.skillLevelCaps).forEach(skill => { hudStatTypes[skill] = firstLetterCapital(skill.split("_").pop()) + " level + Exp" }) @@ -573,6 +575,35 @@ class Hud extends Feature { if (!this.showSpotifyPlaying.getValue()) return let currentSong = "&cNot open" + + if (this.spotifyProcessId !== -1) { + let pid = this.spotifyProcessId + + let process = new ProcessBuilder("tasklist.exe", "/FO", "csv", "/V", "/FI", "\"PID eq " + pid + "\"").start(); + let sc = new Scanner(process.getInputStream()); + if (sc.hasNextLine()) sc.nextLine(); + while (sc.hasNextLine()) { + let line = sc.nextLine(); + let parts = line.replace("\"", "").split("\",\""); + let song = parts[parts.length - 1].substr(0, parts[parts.length - 1].length - 1) + if (song === "N/A") continue + + if (song === "Spotify Free" || song === "Spotify Premium" || song === "AngleHiddenWindow") { + currentSong = "&cPaused" + } else { + if (song === "Spotify") song = "Advertisement" + currentSong = "&a" + song.replace(/&/g, "&⭍").replace(" - ", " &7-&b ") + } + + } + process.waitFor(); + + this.spotifyElement2.setText(currentSong.normalize("NFD").replace(/[\u0300-\u036f]/g, "")) + } + + if (currentSong !== "&cNot open") return + + this.spotifyProcessId = -1 let spotifyProcesses = [] let process = new ProcessBuilder("tasklist.exe", "/fo", "csv", "/nh").start(); let sc = new Scanner(process.getInputStream()); @@ -601,6 +632,8 @@ class Hud extends Feature { let song = parts[parts.length - 1].substr(0, parts[parts.length - 1].length - 1) if (song === "N/A") continue + this.spotifyProcessId = pid + if (song === "Spotify Free" || song === "Spotify Premium" || song === "AngleHiddenWindow") { currentSong = "&cPaused" } else { |