diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-04-19 16:46:24 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-04-19 16:46:24 +0800 |
commit | b0d6b24e7b916ff63e1de119eecf153eda45540f (patch) | |
tree | 1cd423e7e2851f552383c379be28cc16d6bd6d05 | |
parent | 70b9ee73274a099cba147e898cd67f26a3944243 (diff) | |
download | SoopyV2-b0d6b24e7b916ff63e1de119eecf153eda45540f.tar.gz SoopyV2-b0d6b24e7b916ff63e1de119eecf153eda45540f.tar.bz2 SoopyV2-b0d6b24e7b916ff63e1de119eecf153eda45540f.zip |
+ Score calculations take into account spirit pet
+ Eman boss lazer phase timer
-rw-r--r-- | CI/utils/walk.js | 64 | ||||
-rw-r--r-- | featureClass/featureManager.js | 37 | ||||
-rw-r--r-- | features/dungeonSolvers/index.js | 68 | ||||
-rw-r--r-- | features/slayers/index.js | 867 | ||||
-rw-r--r-- | index.js | 24 | ||||
-rw-r--r-- | utils/networkUtils.js | 26 | ||||
-rw-r--r-- | utils/nonPooledThread.js | 14 |
7 files changed, 588 insertions, 512 deletions
diff --git a/CI/utils/walk.js b/CI/utils/walk.js index 4e99caa..899128d 100644 --- a/CI/utils/walk.js +++ b/CI/utils/walk.js @@ -1,40 +1,40 @@ var fs = require('fs'); var path = require('path'); -var walk = function(dir, done) { - var results = []; - fs.readdir(dir, function(err, list) { - if (err) return done(err); - var pending = list.length; - if (!pending) return done(null, results); - list.forEach(function(file) { - file = path.resolve(dir, file); - fs.stat(file, function(err, stat) { - if (stat && stat.isDirectory()) { - walk(file, function(err, res) { - results = results.concat(res); - if (!--pending) done(null, results); - }); - } else { - results.push(file); - if (!--pending) done(null, results); - } - }); - }); - }); +var walk = function (dir, done) { + var results = []; + fs.readdir(dir, function (err, list) { + if (err) return done(err); + var pending = list.length; + if (!pending) return done(null, results); + list.forEach(function (file) { + file = path.resolve(dir, file); + fs.stat(file, function (err, stat) { + if (stat && stat.isDirectory()) { + walk(file, function (err, res) { + results = results.concat(res); + if (!--pending) done(null, results); + }); + } else { + results.push(file); + if (!--pending) done(null, results); + } + }); + }); + }); }; -async function walkP(dir){ //walk function but promisified - return new Promise((res, rej)=>{ - walk(dir, (err, resu)=>{ - if(err){ - rej(err) - return - } +async function walkP(dir) { //walk function but promisified + return new Promise((res, rej) => { + walk(dir, (err, resu) => { + if (err) { + rej(err) + return + } - res(resu) - }); - }) + res(resu) + }); + }) } -module.exports = {walk, walkP} //https://stackoverflow.com/questions/5827612/node-js-fs-readdir-recursive-directory-search +module.exports = { walk, walkP } //https://stackoverflow.com/questions/5827612/node-js-fs-readdir-recursive-directory-search //i was just too lazy to code this myself OMEGALUL
\ No newline at end of file diff --git a/featureClass/featureManager.js b/featureClass/featureManager.js index 2c52c7b..cfb7ff1 100644 --- a/featureClass/featureManager.js +++ b/featureClass/featureManager.js @@ -6,6 +6,7 @@ const File = Java.type("java.io.File") import metadata from "../metadata.js" import soopyV2Server from "../socketConnection"; import { fetch } from "../utils/networkUtils"; +import NonPooledThread from "../utils/nonPooledThread"; import { registerForge as registerForgeBase, unregisterForge as unregisterForgeBase } from "./forgeEvents.js" const JSLoader = Java.type("com.chattriggers.ctjs.engine.langs.js.JSLoader") @@ -110,18 +111,6 @@ class FeatureManager { if (this.isDev) { this.registerStep(true, 2, () => { - - key = this.watchService.take(); - let moduleToReload = this.watches[key] - if (this.features[moduleToReload] && !this.reloadingModules.includes(moduleToReload)) { //if enabled && not alr in queue - this.reloadingModules.push(moduleToReload) - this.reloadModuleTime = Date.now() + 5000 - } - key.pollEvents()/*.forEach(event=>{ - console.log(event.context().toString()) - })*/ - key.reset(); - if (this.reloadModuleTime !== 0 && Date.now() - this.reloadModuleTime > 0) { new Thread(() => { this.reloadModuleTime = 0 @@ -131,16 +120,30 @@ class FeatureManager { this.reloadingModules.forEach(m => { this.loadFeature(m) }) - this.reloadingModules = [] + this.reloadingModules.clear() }).start() } }, this) this.watches = {} - this.addedWatches = [] + this.addedWatches = new Set() this.watchService = Java.type("java.nio.file.FileSystems").getDefault().newWatchService(); - this.reloadingModules = [] + this.reloadingModules = new Set() this.reloadModuleTime = 0 + new NonPooledThread(() => { + while (this.enabled) { + key = this.watchService.take(); + let moduleToReload = this.watches[key] + if (this.features[moduleToReload] && !this.reloadingModules.has(moduleToReload)) { //if enabled && not alr in queue + this.reloadingModules.add(moduleToReload) + this.reloadModuleTime = Date.now() + 5000 + } + key.pollEvents()/*.forEach(event=>{ + console.log(event.context().toString()) + })*/ + key.reset(); + } + }).start() } this.registerCommand("soopyunloadfeature", (args) => { @@ -533,8 +536,8 @@ class FeatureManager { logger.logMessage("Loaded feature " + feature, 3) - if (this.isDev && !this.addedWatches.includes(feature)) { - this.addedWatches.push(feature) + if (this.isDev && !this.addedWatches.has(feature)) { + this.addedWatches.add(feature) let path = Java.type("java.nio.file.Paths").get("./config/ChatTriggers/modules/SoopyV2/features/" + feature + "/"); this.watches[path.register(this.watchService, Java.type("java.nio.file.StandardWatchEventKinds").ENTRY_MODIFY)] = feature } diff --git a/features/dungeonSolvers/index.js b/features/dungeonSolvers/index.js index c45df32..bf51bc2 100644 --- a/features/dungeonSolvers/index.js +++ b/features/dungeonSolvers/index.js @@ -8,6 +8,7 @@ import { drawBoxAtBlock } from "../../utils/renderUtils"; import HudTextElement from "../hud/HudTextElement"; import LocationSetting from "../settings/settingThings/location"; import ToggleSetting from "../settings/settingThings/toggle"; +import { fetch } from "../../utils/networkUtils"; const EntityBlaze = Java.type("net.minecraft.entity.monster.EntityBlaze"); let translate; @@ -102,6 +103,12 @@ class DungeonSolvers extends Feature { } }); + this.registerChat("&r&c ☠ ${info} and became a ghost&r&7.&r", (info, e) => { + let player = ChatLib.removeFormatting(info.split(" ")[0]) + + this.scanFirstDeathForSpiritPet(player) + }); + this.spiritBowPickUps = []; this.registerChat("&r&aYou picked up the &r&5Spirit Bow&r&a! Use it to attack &r&cThorn&r&a!&r", () => { this.spiritBowPickUps.push(Date.now()); @@ -114,6 +121,9 @@ class DungeonSolvers extends Feature { this.todoE = []; this.eMovingThing = {}; + this.nameToUuid = { + "you": Player.getUUID().toString() + } this.bloodX = -1; this.bloodY = -1; this.startSpawningTime = 0; @@ -167,7 +177,7 @@ class DungeonSolvers extends Feature { this.goneInBonus = true; }); this.registerChat("&r&c[BOSS] The Watcher&r&f: You have proven yourself. You may pass.&r", () => { - this.bloodOpenedBonus = false; + this.bloodOpenedBonus = false; //TODO: add 5second delay this.goneInBonus = true; }); let enteredBossMessages = ["&r&4[BOSS] Maxor&r&c: &r&cWELL WELL WELL LOOK WHO’S HERE!&r", "&r&c[BOSS] Livid&r&f: Welcome, you arrive right on time. I am Livid, the Master of Shadows.&r", "&r&c[BOSS] Thorn&r&f: Welcome Adventurers! I am Thorn, the Spirit! And host of the Vegan Trials!&r", "&r&c[BOSS] The Professor&r&f: I was burdened with terrible news recently...&r", "&r&c[BOSS] Scarf&r&f: This is where the journey ends for you, Adventurers.&r", "&r&c[BOSS] Bonzo&r&f: Gratz for making it this far, but I’m basically unbeatable.&r", "&r&c[BOSS] Sadan&r&f: So you made it all the way &r&fhere...and&r&f you wish to defy me? Sadan?!&r"] @@ -178,6 +188,14 @@ class DungeonSolvers extends Feature { }); }) + this.registerChat("&r&aDungeon starts in 1 second.&r", () => { + this.goneInBonus = false; + this.bloodOpenedBonus = false; + + this.firstDeath = false + this.firstDeathHadSpirit = false + }) + this.firstDeath = false this.firstDeathHadSpirit = false @@ -307,29 +325,37 @@ class DungeonSolvers extends Feature { if (this.firstDeath) return this.firstDeath = true - username = username.split(" ")[0] + let uuid = this.nameToUuid[username.toLowerCase()].replace(/-/g, "") - if (this.FeatureManager.features["globalSettings"].class.apiKeySetting.getValue()) { - fetch(`https://api.hypixel.net/player?key=${this.FeatureManager.features["globalSettings"].class.apiKeySetting.getValue()}&name=${username}`).json(data => { + if (this.FeatureManager.features["globalSettings"] && this.FeatureManager.features["globalSettings"].class.apiKeySetting.getValue()) { + fetch(`https://api.hypixel.net/skyblock/profiles?key=${this.FeatureManager.features["globalSettings"].class.apiKeySetting.getValue()}&uuid=${uuid}`).json(data => { if (!data.success) return - fetch(`https://api.hypixel.net/skyblock/profiles?key=${this.FeatureManager.features["globalSettings"].class.apiKeySetting.getValue()}&uuid=${data.player.uuid}`).json(data2 => { - if (!data2.success) return - let latestProfile = [0, undefined] + let latestProfile = [0, undefined] - data2.profiles.forEach(p => { - if (p.members[data.player.uuid].last_save > latestProfile[0]) { - latestProfile = [p.members[data.player.uuid].last_save, p.members[data.player.uuid].pets.find(pet => pet.type === "SPIRIT" && pet.tier === "LEGENDARY")] - } - }) - - if (latestProfile[1]) { - this.firstDeathHadSpirit = true - ChatLib.chat(this.FeatureManager.messagePrefix + "First death has spirit pet!") - } else { - ChatLib.chat(this.FeatureManager.messagePrefix + "First death does not have spirit pet!") + data.profiles.forEach(p => { + if (p.members[uuid].last_save > latestProfile[0]) { + latestProfile = [p.members[uuid].last_save, p.members[uuid].pets.some(pet => pet.type === "SPIRIT" && pet.tier === "LEGENDARY")] } }) + + if (latestProfile[1]) { + this.firstDeathHadSpirit = true + ChatLib.chat(this.FeatureManager.messagePrefix + username + " has spirit pet!") + } else { + ChatLib.chat(this.FeatureManager.messagePrefix + username + " does not have spirit pet!") + } + }) + } else { + fetch(`http://soopymc.my.to/api/v2/player_skyblock/${uuid}`).json(data => { + if (!data.success) return + + if (data.data.profiles[data2.data.stats.currentProfileId].members[uuid].pets.some(pet => pet.type === "SPIRIT" && pet.tier === "LEGENDARY")) { + this.firstDeathHadSpirit = true + ChatLib.chat(this.FeatureManager.messagePrefix + username + " has spirit pet!") + } else { + ChatLib.chat(this.FeatureManager.messagePrefix + username + " does not have spirit pet!") + } }) } } @@ -433,6 +459,9 @@ class DungeonSolvers extends Feature { this.lividData.sayLividColors2 = []; this.lividData.correctLividEntity = undefined; this.lividHpElement && this.lividHpElement.setText(""); + this.nameToUuid = { + "you": Player.getUUID().toString() + } this.startSpawningTime = 0; this.spawnIdThing = 0; @@ -650,6 +679,9 @@ class DungeonSolvers extends Feature { } step() { + World.getAllPlayers().forEach((p) => { + this.nameToUuid[p.getName().toLowerCase()] = p.getUUID().toString() + }) this.failedPuzzleCount = 0; this.totalPuzzleCount = 0; this.completedPuzzleCount = 0; diff --git a/features/slayers/index.js b/features/slayers/index.js index 8b0076c..49fc89c 100644 --- a/features/slayers/index.js +++ b/features/slayers/index.js @@ -9,429 +9,452 @@ import LocationSetting from "../settings/settingThings/location"; import ToggleSetting from "../settings/settingThings/toggle"; class Slayers extends Feature { - constructor() { - super(); - } - - onEnable() { - this.initVariables(); - - this.expOnKill = new ToggleSetting("Show slayer exp on boss kill", "Says your slayer exp in chat when you kill a boss, also says time taken to spawn+kill", true, "slayer_xp", this); - this.slainAlert = new ToggleSetting("Show boss slain alert", "This helps you to not kill mobs for ages with an inactive quest", true, "boss_slain_alert", this); - this.spawnAlert = new ToggleSetting("Show boss spawned alert", "This helps you to not miss your boss when you spawn it", true, "boss_spawn_alert", this); - - this.boxAroundEmanBoss = new ToggleSetting("Box around enderman slayer boss", "This helps to know what boss it yours", true, "eman_box", this); - this.boxToEmanBeacon = new ToggleSetting("Box and line to the enderman beacon", "This will help to find the beacon when the boss throws it", true, "eman_beacon", this); - this.emanBeaconDinkDonk = new ToggleSetting("DinkDonk when beacon is spawned", "This will help to notice when the beacon is spawned", true, "eman_beacon_dinkdink", this); - this.emanEyeThings = new ToggleSetting("Put box around the enderman eye things", "This will help to find them", true, "eman_eye_thing", this); - this.emanHpGuiElement = new ToggleSetting("Render the enderman hp on your screen", "This will help you to know what stage u are in ect", true, "eman_hp", this); - - this.emanHpElement = new HudTextElement().setToggleSetting(this.emanHpGuiElement).setLocationSetting(new LocationSetting("Eman Hp Location", "Allows you to edit the location of the enderman hp", "eman_location", this, [10, 50, 1, 1]).requires(this.emanHpGuiElement).editTempText("&6Enderman&7> &f&l30 Hits")); - this.hudElements.push(this.emanHpElement); - - this.slayerSpeedRates = new ToggleSetting("Show slayer speed and exp rates", "(Slayer speed includes downtime inbetween slayers, only shows while doing slayers)", true, "slayer_speed_rates", this); - this.slayerSpeedRatesElement = new HudTextElement() - .setText("&6Slayer speed&7> &fLoading...\n&6Exp/hour&7> &fLoading...\n&6Kills/hour&7> &fLoading...") - .setToggleSetting(this.slayerSpeedRates) - .setLocationSetting(new LocationSetting("Slayer speed and exp rates location", "Allows you to edit the location of the information", "slayer_speed_rates_location", this, [10, 100, 1, 1]).requires(this.slayerSpeedRates).editTempText("&6Slayer speed&7> &f4:30\n&6Exp/hour&7> &f1,234,567\n&6Kills/hour&7> &f17")); - - this.hudElements.push(this.slayerSpeedRatesElement); - - this.lastSlayerFinishes = []; - this.lastSlayerExps = []; - this.slayerExp = {}; - this.slayerExpLoaded = false; - - this.lastSlayerType = ""; - this.lastSlayerExp = 0; - this.lastBossSlain = 0; - this.registerChat("&r &r&a&lSLAYER QUEST COMPLETE!&r", (e) => { - this.lastSlayerExps.push(this.lastSlayerExp); - if (this.lastSlayerExps.length > 5) { - this.lastSlayerExps.shift(); - } - - this.lastSlayerFinishes.push(Date.now()); - if (this.lastSlayerFinishes.length > 5) { - this.lastSlayerFinishes.shift(); - } - - this.slayerExp[this.lastSlayerType] = this.lastSlayerExp + (this.slayerExp[this.lastSlayerType] || 0); - if (this.expOnKill.getValue()) { - cancel(e); - ChatLib.chat("&r &r&a&lSLAYER QUEST COMPLETE!&a&r"); - ChatLib.chat("&r &r&aYou have &d" + numberWithCommas(this.slayerExp[this.lastSlayerType]) + " " + this.lastSlayerType + " XP&r&7!&r"); - ChatLib.chat("&r &r&aYou have &d" + numberWithCommas(Object.values(this.slayerExp).reduce((a, t) => t + a, 0)) + " total XP&r&7!&r"); - if (Date.now() - this.lastBossSlain < 60000 * 5) ChatLib.chat("&r &r&aBoss took &d" + timeNumber(Date.now() - this.lastBossSlain) + " &ato spawn and kill&r&7!" + /* (" + timeNumber(Date.now()-this.lastBossSpawned) + " to kill) */ "&r"); //TODO: Seperate setting for this - } - this.lastBossSlain = Date.now(); - }); - - this.bossSlainMessage = false; - this.bossSpawnedMessage = false; - this.lastBossNotSpawnedTime = 0; - this.lastBossSpawned = 0; - - this.registerEvent("renderOverlay", this.renderOverlay); - - this.registerSoopy("apiLoad", this.apiLoad); - if (this.FeatureManager.features["dataLoader"] && this.FeatureManager.features["dataLoader"].class.lastApiData.skyblock) { - this.apiLoad(this.FeatureManager.features["dataLoader"].class.lastApiData.skyblock, "skyblock", true, true); - } - - this.todoE = []; - this.beaconPoints = {}; - this.beaconE = []; - this.deadE = []; - this.beaconLocations = {}; - this.eyeE = []; - this.todoE2 = []; - this.emanBoss = undefined; - this.nextIsBoss = 0; - this.counter = 0; - - this.entityAttackEventLoaded = false; - this.entityAttackEventE = undefined; - - this.registerForge(net.minecraftforge.event.entity.EntityJoinWorldEvent, this.entityJoinWorldEvent); - this.registerEvent("tick", this.tick); - this.registerEvent("renderWorld", this.renderWorld); - this.registerEvent("worldLoad", this.worldLoad); - this.registerEvent("renderOverlay", this.renderHud); - this.registerStep(true, 2, this.step); - } - - renderHud() { - for (let element of this.hudElements) { - element.render(); - } - } - - worldLoad() { - this.todoE = []; - this.beaconPoints = {}; - this.beaconE = []; - this.deadE = []; - this.todoE2 = []; - this.beaconLocations = {}; - this.eyeE = []; - this.emanBoss = undefined; - } - - entityAttackEvent(event) { - if (event.source.func_76346_g() === Player.getPlayer()) { - if (event.entity instanceof net.minecraft.entity.monster.EntityEnderman) { - World.getAllEntitiesOfType(net.minecraft.entity.item.EntityArmorStand).forEach((e) => { - if (e.getName().includes("Voidgloom Seraph")) { - //if distance from e to event.entity < 5 - if ((e.getX() - event.entity[f.posX.Entity]) ** 2 + (e.getY() - event.entity[f.posY.Entity]) ** 2 + (e.getZ() - event.entity[f.posZ.Entity]) ** 2 < 25) { - this.emanBoss = e; - } - } - }); - } - } - } - - renderWorld(ticks) { - if (this.emanBoss && this.boxAroundEmanBoss.getValue()) drawBoxAtEntity(this.emanBoss, 0, 255, 0, 1, -3, ticks, 4, false); - - if (this.boxToEmanBeacon.getValue()) { - Object.values(this.beaconPoints).forEach((line) => { - let lastPoint = undefined; - line.forEach((p) => { - if (lastPoint) { - drawLine(lastPoint[0], lastPoint[1], lastPoint[2], p[0], p[1], p[2], 0, 0, 255, 3); - } - lastPoint = p; - }); - }); - Object.values(this.beaconLocations).forEach((loc) => { - drawFilledBox(loc[0] + 0.5, loc[1], loc[2] + 0.5, 1.01, 1.01, 0, 0, 1, 1, true); - }); - } - - this.eyeE.forEach((e) => { - let x = e.getX() + (e.getX() - e.getLastX()) * ticks; - let y = e.getY() + (e.getY() - e.getLastY()) * ticks; - let z = e.getZ() + (e.getZ() - e.getLastZ()) * ticks; - - drawBoxAtBlock(x - 0.5, y + 0.7, z - 0.5, 255, 0, 0); - }); - } - - entityJoinWorldEvent(event) { - this.todoE2.push(event.entity); - } - - tick() { - if (this.FeatureManager.features["dataLoader"].class.isInSkyblock) { - if (!this.entityAttackEventLoaded) { - this.entityAttackEventLoaded = true; - this.entityAttackEventE = this.registerForge(net.minecraftforge.event.entity.living.LivingAttackEvent, this.entityAttackEvent); - } - } else { - if (this.entityAttackEventLoaded) { - this.entityAttackEventLoaded = false; - this.unregisterForge(this.entityAttackEventE); - } - } - - this.bossSlainMessage = false; - let dis1 = false; - Scoreboard.getLines().forEach((line, i) => { - if (ChatLib.removeFormatting(line.getName()).includes("Slayer Quest")) { - let slayerInfo = ChatLib.removeFormatting(Scoreboard.getLines()[i - 1].getName().replace(/§/g, "&")); - let levelString = slayerInfo.split(" ").pop().trim(); - let slayerLevelToExp = { - I: 5, - II: 25, - III: 100, - IV: 500, - V: 1500, - }; - this.lastSlayerExp = slayerLevelToExp[levelString]; - let slayerStrToType = { - revenant: "zombie", - tarantula: "spider", - sven: "wolf", - voidgloom: "enderman", - }; - this.lastSlayerType = slayerStrToType[slayerInfo.split(" ")[0].toLowerCase()]; - //slayerExp[lastSlayerType] += lastSlayerExp - } - if (line.getName().includes("Boss slain!")) { - this.bossSlainMessage = true; - } - - if (line.getName().includes("Slay the boss!")) { - if (!this.bossSpawnedMessage && !this.emanBoss) { - this.nextIsBoss = Date.now(); - } - - dis1 = true; - this.bossSpawnedMessage = true; - } - }); - if (!dis1) { - this.lastBossNotSpawnedTime = Date.now(); - this.bossSpawnedMessage = false; - } - - this.todoE.forEach((e) => { - try { - if (e instanceof net.minecraft.entity.item.EntityArmorStand && e[m.getEquipmentInSlot](4)) { - if (e[m.getEquipmentInSlot](4)[m.getDisplayName.ItemStack]() === "Beacon") { - let closestEIsGaming = false; - let closestDist = Infinity; - World.getAllEntitiesOfType(net.minecraft.entity.item.EntityArmorStand).forEach((e2) => { - if (e2.getName().includes("Voidgloom Seraph")) { - if ((e2.getX() - e[f.posX.Entity]) ** 2 + (e2.getY() - e[f.posY.Entity]) ** 2 + (e2.getZ() - e[f.posZ.Entity]) ** 2 < closestDist) { - closestDist = (e2.getX() - e[f.posX.Entity]) ** 2 + (e2.getY() - e[f.posY.Entity]) ** 2 + (e2.getZ() - e[f.posZ.Entity]) ** 2; - closestEIsGaming = this.emanBoss ? e2.getUUID().toString() === this.emanBoss.getUUID().toString() : false; - } - } - }); - if (closestEIsGaming) { - this.beaconE.push(e); - } - } - if (e[m.getEquipmentInSlot](4)[m.getDisplayName.ItemStack]().startsWith("§a")) { - let closestEIsGaming = false; - let closestDist = Infinity; - World.getAllEntitiesOfType(net.minecraft.entity.item.EntityArmorStand).forEach((e2) => { - if (e2.getName().includes("Voidgloom Seraph")) { - if ((e2.getX() - e[f.posX.Entity]) ** 2 + (e2.getY() - e[f.posY.Entity]) ** 2 + (e2.getZ() - e[f.posZ.Entity]) ** 2 < closestDist) { - closestDist = (e2.getX() - e[f.posX.Entity]) ** 2 + (e2.getY() - e[f.posY.Entity]) ** 2 + (e2.getZ() - e[f.posZ.Entity]) ** 2; - closestEIsGaming = this.emanBoss ? e2.getUUID().toString() === this.emanBoss.getUUID().toString() : false; - } - } - }); - - if (closestEIsGaming && new Item(e[m.getEquipmentInSlot](4)).getNBT().getCompoundTag("tag").getCompoundTag("SkullOwner").getCompoundTag("Properties").getRawNBT()[m.getTagList]("textures", 10)[m.getCompoundTagAt](0)[m.getString.NBTTagCompound]("Value") === "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWIwNzU5NGUyZGYyNzM5MjFhNzdjMTAxZDBiZmRmYTExMTVhYmVkNWI5YjIwMjllYjQ5NmNlYmE5YmRiYjRiMyJ9fX0=") { - this.eyeE.push(new Entity(e)); - } - // console.log(":" + new Item(e[m.getEquipmentInSlot](4)).getNBT().getCompoundTag("tag").getCompoundTag("SkullOwner").getCompoundTag("Properties").getRawNBT().func_150295_c("textures", 10).func_150305_b(0).func_74779_i("Value")) - } - } - - if (e[m.getCustomNameTag]() && e[m.getCustomNameTag]().includes("Voidgloom Seraph")) { - if (Date.now() - this.nextIsBoss < 3000) { - this.emanBoss = new Entity(e); - this.nextIsBoss = false; - } - } - } catch (_) { - console.log(JSON.stringify(_, undefined, 2)); - } - }); - this.todoE = this.todoE2; - this.todoE2 = []; - - if (this.emanBoss && this.emanBoss.getEntity()[f.isDead]) this.emanBoss = undefined; - this.eyeE = this.eyeE.filter((e) => !e.getEntity()[f.isDead]); - this.beaconE = this.beaconE.filter((e) => { - if (e[f.isDead]) { - this.deadE.push([Date.now(), e[m.getUniqueID.Entity]().toString()]); - - let pos = [e[f.posX.Entity] + 0.5, e[f.posY.Entity] + 0.7, e[f.posZ.Entity] + 0.5]; - //check for a beacon block within 5 blocks of pos - if (World.getBlockAt(0, 0, 0).getID) { - for (let x = pos[0] - 5; x <= pos[0] + 5; x++) { - for (let y = pos[1] - 5; y <= pos[1] + 5; y++) { - for (let z = pos[2] - 5; z <= pos[2] + 5; z++) { - if (World.getBlockAt(Math.floor(x), Math.floor(y), Math.floor(z)).getID() === 138) { - this.beaconLocations[e[m.getUniqueID.Entity]().toString()] = [Math.floor(x), Math.floor(y), Math.floor(z)]; - } - } - } - } - } else { - //CT 2.0 support - for (let x = pos[0] - 5; x <= pos[0] + 5; x++) { - for (let y = pos[1] - 5; y <= pos[1] + 5; y++) { - for (let z = pos[2] - 5; z <= pos[2] + 5; z++) { - if (World.getBlockAt(Math.floor(x), Math.floor(y), Math.floor(z)).getType().getID() === 138) { - this.beaconLocations[e[m.getUniqueID.Entity]().toString()] = [Math.floor(x), Math.floor(y), Math.floor(z)]; - } - } - } - } - } - - // if(!this.beaconLocations[e[m.getUniqueID.Entity]().toString()]){ - // console.log("Diddnt find beacon wtf?????") - // } - - return false; - } - return true; - }); - - this.beaconE.forEach((e) => { - if (!this.beaconPoints[e[m.getUniqueID.Entity]().toString()]) this.beaconPoints[e[m.getUniqueID.Entity]().toString()] = []; - - this.beaconPoints[e[m.getUniqueID.Entity]().toString()].push([e[f.posX.Entity] + 0.5, e[f.posY.Entity] + 0.7, e[f.posZ.Entity] + 0.5]); //x, y, z - }); - - this.deadE = this.deadE.filter((e) => { - if (Date.now() - e[0] > 5000) { - delete this.beaconPoints[e[1]]; - delete this.beaconLocations[e[1]]; - return false; - } - - let location = this.beaconLocations[e[1]]; - if (!location) { - delete this.beaconPoints[e[1]]; - delete this.beaconLocations[e[1]]; - return false; - } - - if (World.getBlockAt(0, 0, 0).getID) { - if (World.getBlockAt(location[0], location[1], location[2]).getID() === 138) { - Client.showTitle("&cGO TO BEACON!", "&c" + (Math.max(0, 5000 - (Date.now() - e[0])) / 1000).toFixed(1) + "s", 0, 20, 10); - World.playSound("note.pling", 1, 1); - } else { - delete this.beaconPoints[e[1]]; - delete this.beaconLocations[e[1]]; - return false; - } - } else { - //CT 2.0 support - if (World.getBlockAt(location[0], location[1], location[2]).getType().getID() === 138) { - Client.showTitle("&cGO TO BEACON!", "&c" + (Math.max(0, 5000 - (Date.now() - e[0])) / 1000).toFixed(1) + "s", 0, 20, 10); - World.playSound("note.pling", 1, 1); - } else { - delete this.beaconPoints[e[1]]; - delete this.beaconLocations[e[1]]; - return false; - } - } - return true; - }); - - if (this.emanBoss) { - this.emanHpElement.setText("&6Enderman&7> " + (this.emanBoss.getName().split("Voidgloom Seraph")[1] || "").trim()); - } else { - this.emanHpElement.setText(""); - } - } - - apiLoad(data, dataType, isSoopyServer, isLatest) { - if (!isSoopyServer || !isLatest) return; - if (dataType !== "skyblock") return; - - this.slayerExp.zombie = data.data.profiles[data.data.stats.currentProfileId].members[Player.getUUID().replace(/-/g, "")].slayer.zombie.xp; - this.slayerExp.spider = data.data.profiles[data.data.stats.currentProfileId].members[Player.getUUID().replace(/-/g, "")].slayer.spider.xp; - this.slayerExp.wolf = data.data.profiles[data.data.stats.currentProfileId].members[Player.getUUID().replace(/-/g, "")].slayer.wolf.xp; - this.slayerExp.enderman = data.data.profiles[data.data.stats.currentProfileId].members[Player.getUUID().replace(/-/g, "")].slayer.enderman.xp; - } - - renderOverlay() { - if (this.slainAlert.getValue() && this.bossSlainMessage) { - let scale = Renderer.getStringWidth(ChatLib.removeFormatting("BOSS SLAIN")) / (Renderer.screen.getWidth() * 0.75); - - Renderer.scale(1 / scale, 1 / scale); - Renderer.drawString("&4BOSS SLAIN", Renderer.screen.getWidth() * 0.125 * scale, (Renderer.screen.getHeight() / 2 - 9 / scale) * scale); - Renderer.scale(1, 1); - } - if (this.spawnAlert.getValue() && this.bossSpawnedMessage && Date.now() - this.lastBossNotSpawnedTime < 3000) { - let scale = Renderer.getStringWidth(ChatLib.removeFormatting("BOSS SPAWNED")) / (Renderer.screen.getWidth() * 0.75); - - Renderer.scale(1 / scale, 1 / scale); - Renderer.drawString("&4BOSS SPAWNED", Renderer.screen.getWidth() * 0.125 * scale, (Renderer.screen.getHeight() / 2 - 9 / scale) * scale); - Renderer.scale(1, 1); - } - } - - step() { - let averageExp = this.lastSlayerExps.reduce((a, b) => a + b, 0) / this.lastSlayerExps.length; - let averageLength = (this.lastSlayerFinishes[this.lastSlayerFinishes.length - 1] - this.lastSlayerFinishes[0]) / (this.lastSlayerFinishes.length - 1); - let runsperHour = (60000 * 60) / averageLength; - let expPerHour = averageExp * runsperHour; - - if (Date.now() - this.lastSlayerFinishes[this.lastSlayerFinishes.length - 1] < 60000 * 5 || (this.FeatureManager.features["dataLoader"].class.slayerXpToSpawn && this.FeatureManager.features["dataLoader"].class.slayerXpToSpawn[0] !== 0)) { - if (this.lastSlayerFinishes.length > 1) { - this.slayerSpeedRatesElement.setText("&6Slayer speed&7> &f" + Math.floor(averageLength / 60000) + ":" + ((Math.floor(averageLength / 1000) % 60 < 10 ? "0" : "") + (Math.floor(averageLength / 1000) % 60)) + "\n&6Exp/hour&7> &f" + numberWithCommas(Math.round(expPerHour)) + "\n&6Kills/hour&7> &f" + Math.floor(runsperHour)); - } else { - this.slayerSpeedRatesElement.setText("&6Slayer speed&7> &fLoading...\n&6Exp/hour&7> &fLoading...\n&6Kills/hour&7> &fLoading..."); - } - } else { - this.slayerSpeedRatesElement.setText(""); - } - } - - initVariables() { - this.expOnKill = undefined; - this.slainAlert = undefined; - this.spawnAlert = undefined; - this.slayerExp = undefined; - this.slayerExpLoaded = undefined; - this.lastSlayerType = undefined; - this.lastSlayerExp = undefined; - this.bossSpawnedMessage = undefined; - this.lastBossNotSpawnedTime = undefined; - this.bossSlainMessage = undefined; - this.todoE = undefined; - this.beaconPoints = undefined; - this.beaconE = undefined; - this.deadE = undefined; - this.beaconLocations = undefined; - this.emanBoss = undefined; - this.eyeE = undefined; - this.nextIsBoss = undefined; - this.hudElements = []; - this.entityAttackEventLoaded = undefined; - this.todoE2 = undefined; - this.entityAttackEventE = undefined; - } - - onDisable() { - this.initVariables(); - } + constructor() { + super(); + } + + onEnable() { + this.initVariables(); + + this.expOnKill = new ToggleSetting("Show slayer exp on boss kill", "Says your slayer exp in chat when you kill a boss, also says time taken to spawn+kill", true, "slayer_xp", this); + this.slainAlert = new ToggleSetting("Show boss slain alert", "This helps you to not kill mobs for ages with an inactive quest", true, "boss_slain_alert", this); + this.spawnAlert = new ToggleSetting("Show boss spawned alert", "This helps you to not miss your boss when you spawn it", true, "boss_spawn_alert", this); + + this.boxAroundEmanBoss = new ToggleSetting("Box around enderman slayer boss", "This helps to know what boss it yours", true, "eman_box", this); + this.boxToEmanBeacon = new ToggleSetting("Box and line to the enderman beacon", "This will help to find the beacon when the boss throws it", true, "eman_beacon", this); + this.emanBeaconDinkDonk = new ToggleSetting("DinkDonk when beacon is spawned", "This will help to notice when the beacon is spawned", true, "eman_beacon_dinkdink", this); + this.emanEyeThings = new ToggleSetting("Put box around the enderman eye things", "This will help to find them", true, "eman_eye_thing", this); + this.emanHpGuiElement = new ToggleSetting("Render the enderman hp on your screen", "This will help you to know what stage u are in ect", true, "eman_hp", this); + + this.emanHpElement = new HudTextElement().setToggleSetting(this.emanHpGuiElement).setLocationSetting(new LocationSetting("Eman Hp Location", "Allows you to edit the location of the enderman hp", "eman_location", this, [10, 50, 1, 1]).requires(this.emanHpGuiElement).editTempText("&6Enderman&7> &f&l30 Hits")); + this.hudElements.push(this.emanHpElement); + + this.emanLazerTimer = new ToggleSetting("Adds a timer for the boss lazer phase", "The timer will be inside the boss's body during the phase", true, "eman_lazer_timer", this); + + this.slayerSpeedRates = new ToggleSetting("Show slayer speed and exp rates", "(Slayer speed includes downtime inbetween slayers, only shows while doing slayers)", true, "slayer_speed_rates", this); + this.slayerSpeedRatesElement = new HudTextElement() + .setText("&6Slayer speed&7> &fLoading...\n&6Exp/hour&7> &fLoading...\n&6Kills/hour&7> &fLoading...") + .setToggleSetting(this.slayerSpeedRates) + .setLocationSetting(new LocationSetting("Slayer speed and exp rates location", "Allows you to edit the location of the information", "slayer_speed_rates_location", this, [10, 100, 1, 1]).requires(this.slayerSpeedRates).editTempText("&6Slayer speed&7> &f4:30\n&6Exp/hour&7> &f1,234,567\n&6Kills/hour&7> &f17")); + + this.hudElements.push(this.slayerSpeedRatesElement); + + this.lastSlayerFinishes = []; + this.lastSlayerExps = []; + this.slayerExp = {}; + this.slayerExpLoaded = false; + + this.lastSlayerType = ""; + this.lastSlayerExp = 0; + this.lastBossSlain = 0; + this.registerChat("&r &r&a&lSLAYER QUEST COMPLETE!&r", (e) => { + this.lastSlayerExps.push(this.lastSlayerExp); + if (this.lastSlayerExps.length > 5) { + this.lastSlayerExps.shift(); + } + + this.lastSlayerFinishes.push(Date.now()); + if (this.lastSlayerFinishes.length > 5) { + this.lastSlayerFinishes.shift(); + } + + this.slayerExp[this.lastSlayerType] = this.lastSlayerExp + (this.slayerExp[this.lastSlayerType] || 0); + if (this.expOnKill.getValue()) { + cancel(e); + ChatLib.chat("&r &r&a&lSLAYER QUEST COMPLETE!&a&r"); + ChatLib.chat("&r &r&aYou have &d" + numberWithCommas(this.slayerExp[this.lastSlayerType]) + " " + this.lastSlayerType + " XP&r&7!&r"); + ChatLib.chat("&r &r&aYou have &d" + numberWithCommas(Object.values(this.slayerExp).reduce((a, t) => t + a, 0)) + " total XP&r&7!&r"); + if (Date.now() - this.lastBossSlain < 60000 * 5) ChatLib.chat("&r &r&aBoss took &d" + timeNumber(Date.now() - this.lastBossSlain) + " &ato spawn and kill&r&7!" + /* (" + timeNumber(Date.now()-this.lastBossSpawned) + " to kill) */ "&r"); //TODO: Seperate setting for this + } + this.lastBossSlain = Date.now(); + }); + + this.bossSlainMessage = false; + this.bossSpawnedMessage = false; + this.lastBossNotSpawnedTime = 0; + this.lastBossSpawned = 0; + + this.registerEvent("renderOverlay", this.renderOverlay); + + this.registerSoopy("apiLoad", this.apiLoad); + if (this.FeatureManager.features["dataLoader"] && this.FeatureManager.features["dataLoader"].class.lastApiData.skyblock) { + this.apiLoad(this.FeatureManager.features["dataLoader"].class.lastApiData.skyblock, "skyblock", true, true); + } + + this.todoE = []; + this.beaconPoints = {}; + this.beaconE = []; + this.deadE = []; + this.beaconLocations = {}; + this.eyeE = []; + this.todoE2 = []; + this.emanBoss = undefined; + this.actualEmanBoss = undefined + this.nextIsBoss = 0; + this.counter = 0; + this.emanStartedSittingTime = -1 + + this.entityAttackEventLoaded = false; + this.entityAttackEventE = undefined; + + this.registerForge(net.minecraftforge.event.entity.EntityJoinWorldEvent, this.entityJoinWorldEvent); + this.registerEvent("tick", this.tick); + this.registerEvent("renderWorld", this.renderWorld); + this.registerEvent("worldLoad", this.worldLoad); + this.registerEvent("renderOverlay", this.renderHud); + this.registerStep(true, 2, this.step); + } + + renderHud() { + for (let element of this.hudElements) { + element.render(); + } + } + + worldLoad() { + this.todoE = []; + this.beaconPoints = {}; + this.beaconE = []; + this.deadE = []; + this.todoE2 = []; + this.beaconLocations = {}; + this.eyeE = []; + this.emanBoss = undefined; + this.actualEmanBoss = undefined + } + + entityAttackEvent(event) { + if (event.source.func_76346_g() === Player.getPlayer()) { + if (event.entity instanceof net.minecraft.entity.monster.EntityEnderman) { + World.getAllEntitiesOfType(net.minecraft.entity.item.EntityArmorStand).forEach((e) => { + if (e.getName().includes("Voidgloom Seraph")) { + //if distance from e to event.entity < 5 + if ((e.getX() - event.entity[f.posX.Entity]) ** 2 + (e.getY() - event.entity[f.posY.Entity]) ** 2 + (e.getZ() - event.entity[f.posZ.Entity]) ** 2 < 25) { + this.emanBoss = e; + this.actualEmanBoss = event.entity; + } + } + }); + } + } + } + + renderWorld(ticks) { + if (this.emanBoss && this.boxAroundEmanBoss.getValue()) drawBoxAtEntity(this.emanBoss, 0, 255, 0, 1, -3, ticks, 4, false); + + if (this.emanBoss && this.emanStartedSittingTime > 0 && this.emanLazerTimer.getValue()) { + Tessellator.drawString(ChatLib.addColor("&a&lLazer: &c&l" + Math.max(0, 8.2 - (Date.now() - this.emanStartedSittingTime) / 1000).toFixed(1)), this.emanBoss.getX(), this.emanBoss.getY() - 1.2, this.emanBoss.getZ(), 0, true, 0.04, false); + } + + if (this.boxToEmanBeacon.getValue()) { + Object.values(this.beaconPoints).forEach((line) => { + let lastPoint = undefined; + line.forEach((p) => { + if (lastPoint) { + drawLine(lastPoint[0], lastPoint[1], lastPoint[2], p[0], p[1], p[2], 0, 0, 255, 3); + } + lastPoint = p; + }); + }); + Object.values(this.beaconLocations).forEach((loc) => { + drawFilledBox(loc[0] + 0.5, loc[1], loc[2] + 0.5, 1.01, 1.01, 0, 0, 1, 1, true); + }); + } + + this.eyeE.forEach((e) => { + let x = e.getX() + (e.getX() - e.getLastX()) * ticks; + let y = e.getY() + (e.getY() - e.getLastY()) * ticks; + let z = e.getZ() + (e.getZ() - e.getLastZ()) * ticks; + + drawBoxAtBlock(x - 0.5, y + 0.7, z - 0.5, 255, 0, 0); + }); + } + + entityJoinWorldEvent(event) { + this.todoE2.push(event.entity); + } + + tick() { + if (this.FeatureManager.features["dataLoader"].class.isInSkyblock) { + if (!this.entityAttackEventLoaded) { + this.entityAttackEventLoaded = true; + this.entityAttackEventE = this.registerForge(net.minecraftforge.event.entity.living.LivingAttackEvent, this.entityAttackEvent); + } + } else { + if (this.entityAttackEventLoaded) { + this.entityAttackEventLoaded = false; + this.unregisterForge(this.entityAttackEventE); + } + } + + this.bossSlainMessage = false; + let dis1 = false; + Scoreboard.getLines().forEach((line, i) => { + if (ChatLib.removeFormatting(line.getName()).includes("Slayer Quest")) { + let slayerInfo = ChatLib.removeFormatting(Scoreboard.getLines()[i - 1].getName().replace(/§/g, "&")); + let levelString = slayerInfo.split(" ").pop().trim(); + let slayerLevelToExp = { + I: 5, + II: 25, + III: 100, + IV: 500, + V: 1500, + }; + this.lastSlayerExp = slayerLevelToExp[levelString]; + let slayerStrToType = { + revenant: "zombie", + tarantula: "spider", + sven: "wolf", + voidgloom: "enderman", + }; + this.lastSlayerType = slayerStrToType[slayerInfo.split(" ")[0].toLowerCase()]; + //slayerExp[lastSlayerType] += lastSlayerExp + } + if (line.getName().includes("Boss slain!")) { + this.bossSlainMessage = true; + } + + if (line.getName().includes("Slay the boss!")) { + if (!this.bossSpawnedMessage && !this.emanBoss) { + this.nextIsBoss = Date.now(); + } + + dis1 = true; + this.bossSpawnedMessage = true; + } + }); + if (!dis1) { + this.lastBossNotSpawnedTime = Date.now(); + this.bossSpawnedMessage = false; + } + + this.todoE.forEach((e) => { + try { + if (e instanceof net.minecraft.entity.item.EntityArmorStand && e[m.getEquipmentInSlot](4)) { + if (e[m.getEquipmentInSlot](4)[m.getDisplayName.ItemStack]() === "Beacon") { + let closestEIsGaming = false; + let closestDist = Infinity; + World.getAllEntitiesOfType(net.minecraft.entity.item.EntityArmorStand).forEach((e2) => { + if (e2.getName().includes("Voidgloom Seraph")) { + if ((e2.getX() - e[f.posX.Entity]) ** 2 + (e2.getY() - e[f.posY.Entity]) ** 2 + (e2.getZ() - e[f.posZ.Entity]) ** 2 < closestDist) { + closestDist = (e2.getX() - e[f.posX.Entity]) ** 2 + (e2.getY() - e[f.posY.Entity]) ** 2 + (e2.getZ() - e[f.posZ.Entity]) ** 2; + closestEIsGaming = this.emanBoss ? e2.getUUID().toString() === this.emanBoss.getUUID().toString() : false; + } + } + }); + if (closestEIsGaming) { + this.beaconE.push(e); + } + } + if (e[m.getEquipmentInSlot](4)[m.getDisplayName.ItemStack]().startsWith("§a")) { + let closestEIsGaming = false; + let closestDist = Infinity; + World.getAllEntitiesOfType(net.minecraft.entity.item.EntityArmorStand).forEach((e2) => { + if (e2.getName().includes("Voidgloom Seraph")) { + if ((e2.getX() - e[f.posX.Entity]) ** 2 + (e2.getY() - e[f.posY.Entity]) ** 2 + (e2.getZ() - e[f.posZ.Entity]) ** 2 < closestDist) { + closestDist = (e2.getX() - e[f.posX.Entity]) ** 2 + (e2.getY() - e[f.posY.Entity]) ** 2 + (e2.getZ() - e[f.posZ.Entity]) ** 2; + closestEIsGaming = this.emanBoss ? e2.getUUID().toString() === this.emanBoss.getUUID().toString() : false; + } + } + }); + + if (closestEIsGaming && new Item(e[m.getEquipmentInSlot](4)).getNBT().getCompoundTag("tag").getCompoundTag("SkullOwner").getCompoundTag("Properties").getRawNBT()[m.getTagList]("textures", 10)[m.getCompoundTagAt](0)[m.getString.NBTTagCompound]("Value") === "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWIwNzU5NGUyZGYyNzM5MjFhNzdjMTAxZDBiZmRmYTExMTVhYmVkNWI5YjIwMjllYjQ5NmNlYmE5YmRiYjRiMyJ9fX0=") { + this.eyeE.push(new Entity(e)); + } + // console.log(":" + new Item(e[m.getEquipmentInSlot](4)).getNBT().getCompoundTag("tag").getCompoundTag("SkullOwner").getCompoundTag("Properties").getRawNBT().func_150295_c("textures", 10).func_150305_b(0).func_74779_i("Value")) + } + } + + if (e[m.getCustomNameTag]() && e[m.getCustomNameTag]().includes("Voidgloom Seraph")) { + if (Date.now() - this.nextIsBoss < 3000) { + this.emanBoss = new Entity(e); + this.nextIsBoss = false; + } + } + } catch (_) { + console.log(JSON.stringify(_, undefined, 2)); + } + }); + this.todoE = this.todoE2; + this.todoE2 = []; + + if (this.emanBoss && this.emanBoss.getEntity()[f.isDead]) { + this.emanBoss = undefined + this.actualEmanBoss = undefined + } + this.eyeE = this.eyeE.filter((e) => !e.getEntity()[f.isDead]); + this.beaconE = this.beaconE.filter((e) => { + if (e[f.isDead]) { + this.deadE.push([Date.now(), e[m.getUniqueID.Entity]().toString()]); + + let pos = [e[f.posX.Entity] + 0.5, e[f.posY.Entity] + 0.7, e[f.posZ.Entity] + 0.5]; + //check for a beacon block within 5 blocks of pos + if (World.getBlockAt(0, 0, 0).getID) { + for (let x = pos[0] - 5; x <= pos[0] + 5; x++) { + for (let y = pos[1] - 5; y <= pos[1] + 5; y++) { + for (let z = pos[2] - 5; z <= pos[2] + 5; z++) { + if (World.getBlockAt(Math.floor(x), Math.floor(y), Math.floor(z)).getID() === 138) { + this.beaconLocations[e[m.getUniqueID.Entity]().toString()] = [Math.floor(x), Math.floor(y), Math.floor(z)]; + } + } + } + } + } else { + //CT 2.0 support + for (let x = pos[0] - 5; x <= pos[0] + 5; x++) { + for (let y = pos[1] - 5; y <= pos[1] + 5; y++) { + for (let z = pos[2] - 5; z <= pos[2] + 5; z++) { + if (World.getBlockAt(Math.floor(x), Math.floor(y), Math.floor(z)).getType().getID() === 138) { + this.beaconLocations[e[m.getUniqueID.Entity]().toString()] = [Math.floor(x), Math.floor(y), Math.floor(z)]; + } + } + } + } + } + + // if(!this.beaconLocations[e[m.getUniqueID.Entity]().toString()]){ + // console.log("Diddnt find beacon wtf?????") + // } + + return false; + } + return true; + }); + + this.beaconE.forEach((e) => { + if (!this.beaconPoints[e[m.getUniqueID.Entity]().toString()]) this.beaconPoints[e[m.getUniqueID.Entity]().toString()] = []; + + this.beaconPoints[e[m.getUniqueID.Entity]().toString()].push([e[f.posX.Entity] + 0.5, e[f.posY.Entity] + 0.7, e[f.posZ.Entity] + 0.5]); //x, y, z + }); + + this.deadE = this.deadE.filter((e) => { + if (Date.now() - e[0] > 5000) { + delete this.beaconPoints[e[1]]; + delete this.beaconLocations[e[1]]; + return false; + } + + let location = this.beaconLocations[e[1]]; + if (!location) { + delete this.beaconPoints[e[1]]; + delete this.beaconLocations[e[1]]; + return false; + } + + if (World.getBlockAt(0, 0, 0).getID) { + if (World.getBlockAt(location[0], location[1], location[2]).getID() === 138) { + Client.showTitle("&cGO TO BEACON!", "&c" + (Math.max(0, 5000 - (Date.now() - e[0])) / 1000).toFixed(1) + "s", 0, 20, 10); + World.playSound("note.pling", 1, 1); + } else { + delete this.beaconPoints[e[1]]; + delete this.beaconLocations[e[1]]; + return false; + } + } else { + //CT 2.0 support + if (World.getBlockAt(location[0], location[1], location[2]).getType().getID() === 138) { + Client.showTitle("&cGO TO BEACON!", "&c" + (Math.max(0, 5000 - (Date.now() - e[0])) / 1000).toFixed(1) + "s", 0, 20, 10); + World.playSound("note.pling", 1, 1); + } else { + delete this.beaconPoints[e[1]]; + delete this.beaconLocations[e[1]]; + return false; + } + } + return true; + }); + + if (this.emanBoss) { + this.emanHpElement.setText("&6Enderman&7> " + (this.emanBoss.getName().split("Voidgloom Seraph")[1] || "").trim()); + } else { + this.emanHpElement.setText(""); + } + + if (this.emanLazerTimer.getValue() && this.actualEmanBoss && this.actualEmanBoss[m.isRiding]()) { + if (this.emanStartedSittingTime === -1) { + this.emanStartedSittingTime = Date.now() + } + } else { + this.emanStartedSittingTime = -1 + } + } + + apiLoad(data, dataType, isSoopyServer, isLatest) { + if (!isSoopyServer || !isLatest) return; + if (dataType !== "skyblock") return; + + this.slayerExp.zombie = data.data.profiles[data.data.stats.currentProfileId].members[Player.getUUID().replace(/-/g, "")].slayer.zombie.xp; + this.slayerExp.spider = data.data.profiles[data.data.stats.currentProfileId].members[Player.getUUID().replace(/-/g, "")].slayer.spider.xp; + this.slayerExp.wolf = data.data.profiles[data.data.stats.currentProfileId].members[Player.getUUID().replace(/-/g, "")].slayer.wolf.xp; + this.slayerExp.enderman = data.data.profiles[data.data.stats.currentProfileId].members[Player.getUUID().replace(/-/g, "")].slayer.enderman.xp; + } + + renderOverlay() { + if (this.slainAlert.getValue() && this.bossSlainMessage) { + let scale = Renderer.getStringWidth(ChatLib.removeFormatting("BOSS SLAIN")) / (Renderer.screen.getWidth() * 0.75); + + Renderer.scale(1 / scale, 1 / scale); + Renderer.drawString("&4BOSS SLAIN", Renderer.screen.getWidth() * 0.125 * scale, (Renderer.screen.getHeight() / 2 - 9 / scale) * scale); + Renderer.scale(1, 1); + } + if (this.spawnAlert.getValue() && this.bossSpawnedMessage && Date.now() - this.lastBossNotSpawnedTime < 3000) { + let scale = Renderer.getStringWidth(ChatLib.removeFormatting("BOSS SPAWNED")) / (Renderer.screen.getWidth() * 0.75); + + Renderer.scale(1 / scale, 1 / scale); + Renderer.drawString("&4BOSS SPAWNED", Renderer.screen.getWidth() * 0.125 * scale, (Renderer.screen.getHeight() / 2 - 9 / scale) * scale); + Renderer.scale(1, 1); + } + } + + step() { + let averageExp = this.lastSlayerExps.reduce((a, b) => a + b, 0) / this.lastSlayerExps.length; + let averageLength = (this.lastSlayerFinishes[this.lastSlayerFinishes.length - 1] - this.lastSlayerFinishes[0]) / (this.lastSlayerFinishes.length - 1); + let runsperHour = (60000 * 60) / averageLength; + let expPerHour = averageExp * runsperHour; + + if (Date.now() - this.lastSlayerFinishes[this.lastSlayerFinishes.length - 1] < 60000 * 5 || (this.FeatureManager.features["dataLoader"].class.slayerXpToSpawn && this.FeatureManager.features["dataLoader"].class.slayerXpToSpawn[0] !== 0)) { + if (this.lastSlayerFinishes.length > 1) { + this.slayerSpeedRatesElement.setText("&6Slayer speed&7> &f" + Math.floor(averageLength / 60000) + ":" + ((Math.floor(averageLength / 1000) % 60 < 10 ? "0" : "") + (Math.floor(averageLength / 1000) % 60)) + "\n&6Exp/hour&7> &f" + numberWithCommas(Math.round(expPerHour)) + "\n&6Kills/hour&7> &f" + Math.floor(runsperHour)); + } else { + this.slayerSpeedRatesElement.setText("&6Slayer speed&7> &fLoading...\n&6Exp/hour&7> &fLoading...\n&6Kills/hour&7> &fLoading..."); + } + } else { + this.slayerSpeedRatesElement.setText(""); + } + } + + initVariables() { + this.expOnKill = undefined; + this.slainAlert = undefined; + this.spawnAlert = undefined; + this.slayerExp = undefined; + this.slayerExpLoaded = undefined; + this.lastSlayerType = undefined; + this.lastSlayerExp = undefined; + this.bossSpawnedMessage = undefined; + this.lastBossNotSpawnedTime = undefined; + this.bossSlainMessage = undefined; + this.todoE = undefined; + this.beaconPoints = undefined; + this.beaconE = undefined; + this.deadE = undefined; + this.beaconLocations = undefined; + this.emanBoss = undefined; + this.actualEmanBoss = undefined + this.emanStartedSittingTime = undefined + this.eyeE = undefined; + this.nextIsBoss = undefined; + this.hudElements = []; + this.entityAttackEventLoaded = undefined; + this.todoE2 = undefined; + this.entityAttackEventE = undefined; + } + + onDisable() { + this.initVariables(); + } } module.exports = { - class: new Slayers(), + class: new Slayers(), }; @@ -8,30 +8,30 @@ class SoopyAddons { this.FeatureManager.parent = this } } -if(FileLib.read("soopyAddonsData", "deletesoopyv1please.txt") === "true"){ - new Thread(()=>{ +if (FileLib.read("soopyAddonsData", "deletesoopyv1please.txt") === "true") { + new Thread(() => { Thread.sleep(2000) const File = Java.type("java.io.File") FileLib.deleteDirectory(new File("./config/ChatTriggers/modules/soopyAddons")) - + FileLib.write("soopyAddonsData", "deletesoopyv1please.txt", "false") - + ChatLib.command("ct reload", true) }).start() -}else{ - if(FileLib.read("soopyAddonsData", "firstload.txt") !== "true"){ - new Thread(()=>{ +} else { + if (FileLib.read("soopyAddonsData", "firstload.txt") !== "true") { + new Thread(() => { ChatLib.chat("&7Loading SoopyV2 required modules...") //idk what to say to chat, but it requires an extra ct load after starting to load stuff like mappings (maby this should be part of mappings module, but i put it here so it doesent try to load the first load page thingo) FileLib.write("soopyAddonsData", "firstload.txt", "true") Thread.sleep(2000) - - + + ChatLib.command("ct reload", true) }).start() - }else{ - let a = register("worldLoad", ()=>{ + } else { + let a = register("worldLoad", () => { new SoopyAddons() - + a.unregister() }) } diff --git a/utils/networkUtils.js b/utils/networkUtils.js index fa2cec2..4fad0aa 100644 --- a/utils/networkUtils.js +++ b/utils/networkUtils.js @@ -163,9 +163,21 @@ if (!global.networkUtilsThingSoopy) { let pendingRequests = [] let pendingResolves = [] + let runningThread = false register("tick", () => { - if (pendingRequests.length > 0) { + try { + while (pendingResolves.length > 0) { + let [callback, data] = pendingResolves.shift() + + callback(data) + } + } catch (e) { + console.log(JSON.stringify(e, undefined, 2)) + } + + if (pendingRequests.length > 0 && !runningThread) { + runningThread = true new Thread(() => { while (pendingRequests.length > 0) { let req = pendingRequests.shift() @@ -178,17 +190,9 @@ if (!global.networkUtilsThingSoopy) { pendingResolves.push([req.errcallback, e]) } } - }).start() - } - - try { - while (pendingResolves.length > 0) { - let [callback, data] = pendingResolves.shift() - callback(data) - } - } catch (e) { - console.log(JSON.stringify(e, undefined, 2)) + runningThread = false + }).start() } }) diff --git a/utils/nonPooledThread.js b/utils/nonPooledThread.js new file mode 100644 index 0000000..2061db1 --- /dev/null +++ b/utils/nonPooledThread.js @@ -0,0 +1,14 @@ +let Executors = Java.type("java.util.concurrent.Executors") + +class NonPooledThread { + constructor(fun) { + this.fun = fun + this.executor = Executors.newSingleThreadExecutor() + } + + start() { + this.executor.execute(this.fun) + } +} + +export default NonPooledThread
\ No newline at end of file |