blob: da777f0208de86a47c7b4bd1c9faae5d956795db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
package at.hannibal2.skyhanni.features.garden
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.features.garden.farming.CropMoneyDisplay
import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.sorted
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TimeUtils
object GardenCropTimeCommand {
private val config get() = SkyHanniMod.feature.garden
fun onCommand(args: Array<String>) {
if (!config.moneyPerHourDisplay) {
LorenzUtils.chat("§c[SkyHanni] §cshcroptime requires 'Show money per Hour' feature to be enabled to work!")
return
}
if (args.size < 2) {
LorenzUtils.chat("§cUsage: /shcroptime <amount> <item>")
return
}
val rawAmount = args[0]
val amount = try {
rawAmount.toInt()
} catch (e: NumberFormatException) {
LorenzUtils.chat("§cNot a valid number: '$rawAmount'")
return
}
val rawSearchName = args.toMutableList().drop(1).joinToString(" ")
val searchName = rawSearchName.lowercase()
val map = mutableMapOf<String, Long>()
for (entry in CropMoneyDisplay.multipliers) {
val internalName = entry.key
val itemName = NEUItems.getItemStack(internalName).name!!
if (itemName.removeColor().lowercase().contains(searchName)) {
val (baseId, baseAmount) = NEUItems.getMultiplier(internalName)
val baseName = NEUItems.getItemStack(baseId).name!!
val crop = CropType.getByName(baseName.removeColor())
val fullAmount = baseAmount.toLong() * amount.toLong()
val text = if (baseAmount == 1) {
"§e${amount.addSeparators()}x $itemName"
} else {
"§e${amount.addSeparators()}x $itemName §7(§e${fullAmount.addSeparators()}x $baseName§7)"
}
val speed = crop.getSpeed()
if (speed == null) {
map["$text §cNo speed data!"] = -1
} else {
val missingTimeSeconds = fullAmount / speed
val duration = TimeUtils.formatDuration(missingTimeSeconds * 1000)
map["$text §b$duration"] = missingTimeSeconds
}
}
}
if (map.isEmpty()) {
LorenzUtils.chat("§c[SkyHanni] §cNo crop item found for '$rawSearchName'")
return
}
LorenzUtils.chat("§e[SkyHanni] Crop Speed for ${map.size} items:\n" + map.sorted().keys.joinToString("\n"))
}
}
|