From 5cd6e989c72c83a2a3c44c547901aff8f6cc90e4 Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Mon, 11 Nov 2024 20:31:38 +0100 Subject: [PATCH] Improvement: Carry Tracker Remove (#2829) Co-authored-by: Empa Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../skyhanni/config/commands/Commands.kt | 5 --- .../skyhanni/features/misc/CarryTracker.kt | 40 ++++++++++++++++--- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index cca72f2c5749..4eb3605749b0 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -63,7 +63,6 @@ import at.hannibal2.skyhanni.features.mining.fossilexcavator.ExcavatorProfitTrac import at.hannibal2.skyhanni.features.mining.glacitemineshaft.CorpseTracker import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker import at.hannibal2.skyhanni.features.minion.MinionFeatures -import at.hannibal2.skyhanni.features.misc.CarryTracker import at.hannibal2.skyhanni.features.misc.CollectionTracker import at.hannibal2.skyhanni.features.misc.LockMouseLook import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager @@ -151,10 +150,6 @@ object Commands { description = "Using path finder to go to locations" callback { NavigationHelper.onCommand(it) } } - event.register("shcarry") { - description = "Keep track of carries you do." - callback { CarryTracker.onCommand(it) } - } event.register("shmarkplayer") { description = "Add a highlight effect to a player for better visibility" callback { MarkedPlayerManager.command(it) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CarryTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CarryTracker.kt index b43625ed2769..ca4c71d7ffd0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CarryTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CarryTracker.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.config.commands.CommandRegistrationEvent import at.hannibal2.skyhanni.data.jsonobjects.repo.CarryTrackerJson import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -32,10 +33,10 @@ import kotlin.time.Duration.Companion.seconds * save on restart * support for Dungeon, Kuudra, crimson minibosses * average spawn time per slayer customer - * change customer name color if offline, onlilne, on your island + * change customer name color if offline, online, on your island * show time since last boss died next to slayer customer name * highlight slayer bosses for slayer customers - * automatically mark customers with /shmarkplaayers + * automatically mark customers with /shmarkplayers * show a line behind them */ @@ -119,12 +120,39 @@ object CarryTracker { config.carryPosition.renderRenderables(display, posLabel = "Carry Tracker") } - fun onCommand(args: Array) { + @HandleEvent + fun onCommandRegister(event: CommandRegistrationEvent) { + event.register("shcarry") { + description = "Keep track of carries you do." + callback { onCommand(it) } + } + } + + @Suppress("ReturnCount") + private fun onCommand(args: Array) { if (args.size < 2 || args.size > 3) { - ChatUtils.userError("Usage:\n§c/shcarry \n§c/shcarry ") + ChatUtils.userError( + "Usage:\n" + + "§c/shcarry \n" + + "§c/shcarry \n" + + "§c/shcarry remove ", + ) return } if (args.size == 2) { + if (args[0] == "remove") { + val customerName = args[1] + for (customer in customers) { + if (customer.name.equals(customerName, ignoreCase = true)) { + customers.remove(customer) + update() + ChatUtils.chat("Removed customer: §b$customerName") + return + } + } + ChatUtils.userError("Customer not found: §b$customerName") + return + } setPrice(args[0], args[1]) return } @@ -235,6 +263,7 @@ object CarryTracker { add("§7Set a price with §e/shcarry ") } add("") + add("§7Run §e/shcarry remove ${customer.name} §7to remove the whole customer!") add("§eClick to send current progress in the party chat!") add("§eControl-click to remove this carry!") }, @@ -276,8 +305,7 @@ object CarryTracker { ), onClick = { HypixelCommands.partyChat( - "$customerName Carry: already paid: ${paidFormat.removeColor()}, " + - "still missing: ${missingFormat.removeColor()}", + "$customerName Carry: already paid: ${paidFormat.removeColor()}, still missing: ${missingFormat.removeColor()}", ) }, ),