Skip to content

Commit

Permalink
add remove people to carry tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsEmpa committed Oct 26, 2024
1 parent 742d175 commit cf7c7f4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,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) }
Expand Down
33 changes: 30 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/features/misc/CarryTracker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*/

Expand Down Expand Up @@ -119,12 +120,38 @@ object CarryTracker {
config.carryPosition.renderRenderables(display, posLabel = "Carry Tracker")
}

@HandleEvent
fun onCommandRegister(event: CommandRegistrationEvent) {
event.register("shcarry") {
description = "Keep track of carries you do."
callback { onCommand(it) }
}
}

fun onCommand(args: Array<String>) {

Check warning on line 131 in src/main/java/at/hannibal2/skyhanni/features/misc/CarryTracker.kt

View workflow job for this annotation

GitHub Actions / Run detekt

detekt.style.ReturnCount

Function onCommand has 8 return statements which exceeds the limit of 5.
if (args.size < 2 || args.size > 3) {
ChatUtils.userError("Usage:\n§c/shcarry <customer name> <type> <amount requested>\n§c/shcarry <type> <price per>")
ChatUtils.userError(
"Usage:\n" +
"§c/shcarry <customer name> <type> <amount requested>\n" +
"§c/shcarry <type> <price per>\n" +
"§c/shcarry remove <costumer name>",
)
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
}
Expand Down

0 comments on commit cf7c7f4

Please sign in to comment.