diff options
Diffstat (limited to 'features')
-rw-r--r-- | features/friendsGUI/index.js | 90 | ||||
-rw-r--r-- | features/waypoints/index.js | 5 | ||||
-rw-r--r-- | features/waypoints/minewaypoints_socket.js | 1 |
3 files changed, 81 insertions, 15 deletions
diff --git a/features/friendsGUI/index.js b/features/friendsGUI/index.js index 0469efd..189f25d 100644 --- a/features/friendsGUI/index.js +++ b/features/friendsGUI/index.js @@ -8,6 +8,9 @@ import BoxWithLoading from "../../../guimanager/GuiElement/BoxWithLoading"; import Feature from "../../featureClass/class"; import GuiPage from "../soopyGui/GuiPage"; import SoopyMouseClickEvent from "../../../guimanager/EventListener/SoopyMouseClickEvent"; +import ButtonWithArrow from "../../../guimanager/GuiElement/ButtonWithArrow"; +import ProgressBar from "../../../guimanager/GuiElement/ProgressBar"; +import logger from "../../logger"; class FriendsGui extends Feature { constructor() { @@ -22,12 +25,7 @@ class FriendsGui extends Feature { this.registerChat("&9&m-----------------------------------------------------&r&9${*}&r&9 ${*} &6Friends (Page ${pagenum} of ${maxpages})${friendslist}&r&9&m-----------------------------------------------------&r", (...args) => { this.GuiPage.friendListMessageEvent.call(this.GuiPage, ...args) }) this.registerStep(true, 5, () => { this.GuiPage.regenGuiElements.call(this.GuiPage) }) - this.registerCommand("soopyunfriendthing", () => { - this.GuiPage.unfriendMode = !this.GuiPage.unfriendMode - ChatLib.chat("UNFRIEND MODE NOW " + this.GuiPage.unfriendMode) - }) this.registerStep(false, 1, () => { this.GuiPage.runComm.call(this.GuiPage) }) - } initVariables() { @@ -61,8 +59,24 @@ class SettingPage extends GuiPage { this.loadedFriends = {} + this.loadedPages = new Set() + this.pageCount = undefined + this.sidebar = new SoopyGuiElement() + + this.sidebarCustomPage = undefined + + this.sidebarMainPage = new SoopyGuiElement().setLocation(0, 0, 1, 1) + + this.sidebarMainPage.addChild( + new ButtonWithArrow().setText("§0Load all friends").setLocation(0.1, 0.1, 0.8, 0.2) + .addEvent(new SoopyMouseClickEvent().setHandler(() => { + this.loadAllFriends() + + this.updateSidebar() + }))) + this.heightPerFriend = 0.2 this.loadingElement = new BoxWithLoading().setLocation(0, 0, 1, 0.175) this.lastLoadedPage = 0 @@ -78,19 +92,59 @@ class SettingPage extends GuiPage { this.commandQueue = [] + this.updateSidebar() this.finaliseLoading() } + loadAllFriends() { + this.sidebarCustomPage = new SoopyGuiElement().setLocation(0, 0, 1, 1) + + this.sidebarCustomPage.addChild(new SoopyTextElement().setText("§0Loading all friends...").setLocation(0.2, 0.1, 0.6, 0.2).setMaxTextScale(10)) + + + let progressBar = new ProgressBar().setProgress(0).setLocation(0.2, 0.5, 0.6, 0.1) + + this.sidebarCustomPage.addChild(progressBar) + for (let i = this.maxLoadedPage + 1; i < this.pageCount + 1; i++) { + let i2 = i + + this.loadFriendPage(i, () => { + progressBar.setProgress(i2 / (this.pageCount + 1), 1000) + + if (i2 === this.pageCount + 1) { + this.sidebarCustomPage = undefined + + this.updateSidebar() + } + }) + } + } + + updateSidebar() { + this.sidebar.clearChildren() + if (this.sidebarCustomPage) { + this.sidebar.addChild(this.sidebarCustomPage) + return + } + this.sidebar.addChild(this.sidebarMainPage) + } + + runCommand(command, callback) { + this.commandQueue.push([command, callback]) + } + runComm() { - if (this.commandQueue.length > 0) { - let c = this.commandQueue.shift() + if (this.commandQueue.length > 0 && this.isOpen()) { + let [c, callback] = this.commandQueue.shift() ChatLib.say(c) + logger.logMessage("running command " + c, 3) + callback() } } friendListMessageEvent(pagenum, maxpages, friendslist, event) { - if (Date.now() - this.lastRender < 1000) { + if (Date.now() - this.lastLoadedPage < 3000) { cancel(event) // console.log("Canceling") } else { @@ -122,7 +176,7 @@ class SettingPage extends GuiPage { currentGame: location.replace("in ", "").replace("currently offline", "&cCurrently offline"), element: new ButtonWithArrowAndDescription().setLocation(0, this.heightPerFriend * Object.keys(this.loadedFriends).length + 1, 1, this.heightPerFriend * 0.875).setText(name).setDesc("&7" + location.replace("in ", "").replace("currently offline", "&cCurrently offline")).addEvent(new SoopyMouseClickEvent().setHandler(() => { if (this.unfriendMode) { - this.commandQueue.push("/friend remove " + ChatLib.removeFormatting(name)) + // this.commandQueue.push("/friend remove " + ChatLib.removeFormatting(name)) this.loadedFriends[ChatLib.removeFormatting(name)].exists = false @@ -165,9 +219,14 @@ class SettingPage extends GuiPage { } } - loadFriendPage(page) { - ChatLib.command("friends list " + page) - this.lastLoadedPage = Date.now() + loadFriendPage(page, callback) { + if (this.loadedPages.has(page)) return + + this.loadedPages.add(page) + this.runCommand("/friends list " + page, () => { + this.lastLoadedPage = Date.now() + if (callback) callback() + }) } onOpen() { @@ -176,9 +235,16 @@ class SettingPage extends GuiPage { this.lastLoadedPage = 0 this.maxLoadedPage = 0 + this.sidebarCustomPage = undefined + this.commandQueue = [] + + this.loadedPages.clear() + this.regenGuiElements() this.loadFriendPage(1) + this.openSidebarPage(this.sidebar) + this.updateSidebar() } } diff --git a/features/waypoints/index.js b/features/waypoints/index.js index 0760354..2bc4e09 100644 --- a/features/waypoints/index.js +++ b/features/waypoints/index.js @@ -161,7 +161,7 @@ class Waypoints extends Feature { this.locations[area || loc[0].area] = loc; } let lastLoc = [0, 0, 0] - let lastTp = 0 + this.lastTp = 0 this.registerEvent("tick", () => { try { if (Scoreboard.getLines().length < 2) return; @@ -176,9 +176,10 @@ class Waypoints extends Feature { minewaypoints_socket.setServer(server, World.getWorld().func_82737_E()) let loc = [Player.getX(), Player.getY(), Player.getZ()] - if (calculateDistanceQuick(lastLoc, loc) > 25) { + if (calculateDistanceQuick(lastLoc, loc) > 20 ** 2) { this.lastTp = Date.now() } + lastLoc = loc if (Date.now() - this.lastSend > 1000 && Date.now() - this.lastTp > 5000) { Scoreboard.getLines().forEach(line => { diff --git a/features/waypoints/minewaypoints_socket.js b/features/waypoints/minewaypoints_socket.js index 3a6dcd7..0cc31e5 100644 --- a/features/waypoints/minewaypoints_socket.js +++ b/features/waypoints/minewaypoints_socket.js @@ -37,7 +37,6 @@ class MineWayPointsServer extends WebsiteCommunicator { this.lastSend = Date.now() this.hypixelServer = server - this.sendData({ type: "setServer", server: server, |