From f5b62ec0ad78a87352297413e42a5d5fdce8c290 Mon Sep 17 00:00:00 2001 From: Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> Date: Thu, 7 Jul 2022 11:21:44 +0800 Subject: + sort buttons in spirit leap overlay by class --- features/dungeonMap/index.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'features') diff --git a/features/dungeonMap/index.js b/features/dungeonMap/index.js index 64faabc..7a9b7cb 100644 --- a/features/dungeonMap/index.js +++ b/features/dungeonMap/index.js @@ -842,17 +842,24 @@ class SpiritLeapOverlay { this.items = itemsNew this.buttonsContainer.clearChildren() - Object.keys(this.items).forEach((name, i) => { - - let name2 = ChatLib.removeFormatting(name) - let pClass = (this.players[name2] || "?") + getClass = (name) => { + let pClass = (this.players[name] || "?") if (pClass === "?") { Object.keys(this.players).forEach(n => { - if (name2.startsWith(n)) { + if (name.startsWith(n)) { pClass = this.players[n] } }) } + return pClass + } + + Object.keys(this.items).sort((a, b) => { + return getClass(ChatLib.removeFormatting(a)).codePointAt(0) - getClass(ChatLib.removeFormatting(b)).codePointAt(0) + }).forEach((name, i) => { + + let name2 = ChatLib.removeFormatting(name) + let pClass = getClass(name2) let button = new ButtonWithArrow().setText((name2 === this.parent.lastDoorOpener ? "&4" : "&2") + "[" + pClass + "] " + name2).addEvent(new SoopyMouseClickEvent().setHandler(() => { Player.getContainer().click(itemsNew[name]) -- cgit