aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/garden
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt22
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/DicerRngDropCounter.kt56
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt46
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt83
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt20
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt30
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenCustomKeybinds.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt28
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt5
12 files changed, 167 insertions, 169 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt
index 893c65645..d0d1f7f8d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt
@@ -23,7 +23,7 @@ class CropMoneyDisplay {
private var loaded = false
private var ready = false
private val multipliers = mutableMapOf<String, Int>()
- private val cropNames = mutableMapOf<String, String>() // internalName -> cropName
+ private val cropNames = mutableMapOf<String, CropType>() // internalName -> cropName
private var hasCropInHand = false
@SubscribeEvent
@@ -35,8 +35,7 @@ class CropMoneyDisplay {
@SubscribeEvent
fun onGardenToolChange(event: GardenToolChangeEvent) {
- val crop = if (event.isRealCrop) event.crop else null
- hasCropInHand = crop != null
+ hasCropInHand = event.crop != null
update()
}
@@ -109,12 +108,6 @@ class CropMoneyDisplay {
val price = NEUItems.getPrice(internalName)
val cropName = cropNames[internalName]!!
val speed = GardenAPI.getCropsPerSecond(cropName)
- if (speed == null) {
- println("calculateMoneyPerHour: Speed is null for crop name '$cropName' ($internalName)")
- LorenzUtils.debug("calculateMoneyPerHour: Speed is null!")
- continue
- }
-
// No speed data for item in hand
if (speed == -1) continue
@@ -160,10 +153,10 @@ class CropMoneyDisplay {
val (newId, amount) = NEUItems.getMultiplier(internalName)
if (amount < 10) continue
val itemName = NEUItems.getItemStack(newId).name?.removeColor() ?: continue
- val cropName = GardenAPI.itemNameToCropName(itemName)
- if (crops.contains(cropName)) {
+ val crop = GardenAPI.itemNameToCropName(itemName)
+ crop?.let {
multipliers[internalName] = amount
- cropNames[internalName] = cropName
+ cropNames[internalName] = it
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt
new file mode 100644
index 000000000..769d3b4dd
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt
@@ -0,0 +1,22 @@
+package at.hannibal2.skyhanni.features.garden
+
+enum class CropType(val cropName: String, val toolName: String) {
+ WHEAT("Wheat", "THEORETICAL_HOE_WHEAT"),
+ CARROT("Carrot", "THEORETICAL_HOE_CARROT"),
+ POTATO("Potato", "THEORETICAL_HOE_POTATO"),
+ PUMPKIN("Pumpkin", "PUMPKIN_DICER"),
+ SUGAR_CANE("Sugar Cane", "THEORETICAL_HOE_CANE"),
+ MELON("Melon", "MELON_DICER"),
+ CACTUS("Cactus", "CACTUS_KNIFE"),
+ COCOA_BEANS("Cocoa Beans", "COCO_CHOPPER"),
+ MUSHROOM("Mushroom", "FUNGI_CUTTER"),
+ NETHER_WART("Nether Wart", "THEORETICAL_HOE_WARTS"),
+ ;
+
+ companion object {
+ fun getByName(name: String) = values().firstOrNull { it.cropName == name }
+
+ // TODO find better name for this method
+ fun getByNameNoNull(name: String) = getByName(name) ?: throw RuntimeException("No valid crop type '$name'")
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/DicerRngDropCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/DicerRngDropCounter.kt
index 8547f4d51..ef1ee8a82 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/DicerRngDropCounter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/DicerRngDropCounter.kt
@@ -13,22 +13,22 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class DicerRngDropCounter {
private val display = mutableListOf<String>()
- private val drops = mutableMapOf<String, MutableMap<DropRarity, Int>>()
+ private val drops = mutableMapOf<CropType, MutableMap<DropRarity, Int>>()
private val itemDrops = mutableListOf<ItemDrop>()
init {
- drops["Melon"] = mutableMapOf()
- drops["Pumpkin"] = mutableMapOf()
-
- itemDrops.add(ItemDrop("Melon", DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a1x §r§aEnchanted Melon§r§e!"))
- itemDrops.add(ItemDrop("Melon", DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a5x §r§aEnchanted Melon§r§e!"))
- itemDrops.add(ItemDrop("Melon", DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a50x §r§aEnchanted Melon§r§e!"))
- itemDrops.add(ItemDrop("Melon", DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§92x §r§9Enchanted Melon Block§r§e!"))
-
- itemDrops.add(ItemDrop("Pumpkin", DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§f64x §r§fPumpkin§r§e!"))
- itemDrops.add(ItemDrop("Pumpkin", DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a1x §r§aEnchanted Pumpkin§r§e!"))
- itemDrops.add(ItemDrop("Pumpkin", DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a10x §r§aEnchanted Pumpkin§r§e!"))
- itemDrops.add(ItemDrop("Pumpkin", DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§a64x §r§aEnchanted Pumpkin§r§e!"))
+ drops[CropType.MELON] = mutableMapOf()
+ drops[CropType.PUMPKIN] = mutableMapOf()
+
+ itemDrops.add(ItemDrop(CropType.MELON, DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a1x §r§aEnchanted Melon§r§e!"))
+ itemDrops.add(ItemDrop(CropType.MELON, DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a5x §r§aEnchanted Melon§r§e!"))
+ itemDrops.add(ItemDrop(CropType.MELON, DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a50x §r§aEnchanted Melon§r§e!"))
+ itemDrops.add(ItemDrop(CropType.MELON, DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§92x §r§9Enchanted Melon Block§r§e!"))
+
+ itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§f64x §r§fPumpkin§r§e!"))
+ itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a1x §r§aEnchanted Pumpkin§r§e!"))
+ itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.CRAZY_RARE, "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a10x §r§aEnchanted Pumpkin§r§e!"))
+ itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§a64x §r§aEnchanted Pumpkin§r§e!"))
}
enum class DropRarity(val displayName: String) {
@@ -45,7 +45,7 @@ class DicerRngDropCounter {
val message = event.message
for (drop in itemDrops) {
if (message == drop.message) {
- addDrop(drop.itemName, drop.rarity)
+ addDrop(drop.crop, drop.rarity)
saveConfig()
update()
return
@@ -66,8 +66,8 @@ class DicerRngDropCounter {
private fun drawDisplay(): List<String> {
val help = mutableListOf<String>()
- val items = drops[itemInHand] ?: return help
- help.add("§7RNG Drops for $toolname§7:")
+ val items = drops[cropInHand] ?: return help
+ help.add("§7RNG Drops for $toolName§7:")
for ((rarity, amount) in items.sortedDesc()) {
val displayName = rarity.displayName
help.add(" §7- §e${amount}x $displayName")
@@ -76,21 +76,21 @@ class DicerRngDropCounter {
return help
}
- private var itemInHand = ""
- private var toolname = ""
+ private var cropInHand: CropType? = null
+ private var toolName = ""
@SubscribeEvent
fun onGardenToolChange(event: GardenToolChangeEvent) {
val crop = event.crop
- itemInHand = if (crop == "Melon" || crop == "Pumpkin") crop else ""
- if (itemInHand != "") {
- toolname = event.heldItem!!.name!!
+ cropInHand = if (crop == CropType.MELON || crop == CropType.PUMPKIN) crop else null
+ if (cropInHand != null) {
+ toolName = event.toolItem!!.name!!
}
update()
}
- private fun addDrop(item: String, rarity: DropRarity) {
- val map = drops[item]!!
+ private fun addDrop(crop: CropType, rarity: DropRarity) {
+ val map = drops[crop]!!
val old = map[rarity] ?: 0
map[rarity] = old + 1
}
@@ -102,15 +102,15 @@ class DicerRngDropCounter {
}
}
- class ItemDrop(val itemName: String, val rarity: DropRarity, val message: String)
+ class ItemDrop(val crop: CropType, val rarity: DropRarity, val message: String)
private fun saveConfig() {
val list = SkyHanniMod.feature.hidden.gardenDicerRngDrops
list.clear()
for (drop in drops) {
- val itemName = drop.key
+ val crop = drop.key
for ((rarity, amount) in drop.value) {
- list[itemName + "." + rarity.name] = amount
+ list[crop.cropName + "." + rarity.name] = amount
}
}
}
@@ -119,10 +119,10 @@ class DicerRngDropCounter {
fun onConfigLoad(event: ConfigLoadEvent) {
for ((internalName, amount) in SkyHanniMod.feature.hidden.gardenDicerRngDrops) {
val split = internalName.split(".")
- val itemName = split[0]
+ val crop = CropType.getByNameNoNull(split[0])
val rarityName = split[1]
val rarity = DropRarity.valueOf(rarityName)
- drops[itemName]!![rarity] = amount
+ drops[crop]!![rarity] = amount
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt
index ebfa0ff8a..29bfd84b1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt
@@ -59,7 +59,7 @@ class EliteFarmingWeight {
companion object {
private val config get() = SkyHanniMod.feature.garden
- private val localCollection = mutableMapOf<String, Long>()
+ private val localCollection = mutableMapOf<CropType, Long>()
private var display = mutableListOf<String>()
private var profileId = ""
@@ -181,7 +181,7 @@ class EliteFarmingWeight {
private fun isEnabled() = GardenAPI.inGarden() && config.eliteFarmingWeightDisplay
private fun isEtaEnabled() = config.eliteFarmingWeightOvertakeETA
- fun addCrop(crop: String, diff: Int) {
+ fun addCrop(crop: CropType, diff: Int) {
val old = localCollection[crop] ?: 0L
val before = calculateExactWeight()
@@ -193,7 +193,7 @@ class EliteFarmingWeight {
dirtyCropWeight = true
}
- private fun updateWeightPerSecond(crop: String, before: Double, after: Double, diff: Int) {
+ private fun updateWeightPerSecond(crop: CropType, before: Double, after: Double, diff: Int) {
val speed = GardenAPI.cropsPerSecond[crop]!!
if (speed != -1) {
val weightDiff = (after - before) * 1000
@@ -266,8 +266,8 @@ class EliteFarmingWeight {
LorenzUtils.error("[SkyHanni] Failed to load farming weight data from elitebot.dev! please report this on discord!")
}
- private fun calculateCollectionWeight(round: Boolean = true): MutableMap<String, Double> {
- val weightPerCrop = mutableMapOf<String, Double>()
+ private fun calculateCollectionWeight(round: Boolean = true): MutableMap<CropType, Double> {
+ val weightPerCrop = mutableMapOf<CropType, Double>()
var totalWeight = 0.0
for ((cropName, factor) in factorPerCrop) {
val collection = getLocalCollection(cropName)
@@ -276,38 +276,38 @@ class EliteFarmingWeight {
totalWeight += weight
}
if (totalWeight > 0) {
- weightPerCrop["Mushroom"] = specialMushroomWeight(weightPerCrop, totalWeight)
+ weightPerCrop[CropType.MUSHROOM] = specialMushroomWeight(weightPerCrop, totalWeight)
}
return weightPerCrop
}
- private fun specialMushroomWeight(weightPerCrop: MutableMap<String, Double>, totalWeight: Double): Double {
- val cactusWeight = weightPerCrop["Cactus"]!!
- val sugarCaneWeight = weightPerCrop["Sugar Cane"]!!
+ private fun specialMushroomWeight(weightPerCrop: MutableMap<CropType, Double>, totalWeight: Double): Double {
+ val cactusWeight = weightPerCrop[CropType.CACTUS]!!
+ val sugarCaneWeight = weightPerCrop[CropType.SUGAR_CANE]!!
val doubleBreakRatio = (cactusWeight + sugarCaneWeight) / totalWeight;
val normalRatio = (totalWeight - cactusWeight - sugarCaneWeight) / totalWeight;
- val mushroomFactor = factorPerCrop["Mushroom"]!!
- val mushroomCollection = getLocalCollection("Mushroom")
+ val mushroomFactor = factorPerCrop[CropType.MUSHROOM]!!
+ val mushroomCollection = getLocalCollection(CropType.MUSHROOM)
return doubleBreakRatio * (mushroomCollection / (2 * mushroomFactor)) + normalRatio * (mushroomCollection / mushroomFactor)
}
- private fun getLocalCollection(cropName: String): Long {
- return localCollection[cropName] ?: 0L
+ private fun getLocalCollection(crop: CropType): Long {
+ return localCollection[crop] ?: 0L
}
private val factorPerCrop by lazy {
mapOf(
- "Wheat" to 100_000.0,
- "Carrot" to 300_000.0,
- "Potato" to 300_000.0,
- "Sugar Cane" to 200_000.0,
- "Nether Wart" to 250_000.0,
- "Pumpkin" to 87_095.11,
- "Melon" to 435_466.47,
- "Mushroom" to 168_925.53,
- "Cocoa Beans" to 257_214.64,
- "Cactus" to 169_389.33,
+ CropType.WHEAT to 100_000.0,
+ CropType.CARROT to 300_000.0,
+ CropType.POTATO to 300_000.0,
+ CropType.SUGAR_CANE to 200_000.0,
+ CropType.NETHER_WART to 250_000.0,
+ CropType.PUMPKIN to 87_095.11,
+ CropType.MELON to 435_466.47,
+ CropType.MUSHROOM to 168_925.53,
+ CropType.COCOA_BEANS to 257_214.64,
+ CropType.CACTUS to 169_389.33,
)
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
index 976edfb63..b23387010 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
@@ -1,7 +1,6 @@
package at.hannibal2.skyhanni.features.garden
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.data.GardenCropMilestones
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.events.GardenToolChangeEvent
import at.hannibal2.skyhanni.events.GuiContainerEvent
@@ -37,62 +36,51 @@ class GardenAPI {
fun onTick(event: TickEvent.ClientTickEvent) {
if (event.phase != TickEvent.Phase.START) return
if (!inGarden()) return
- if (tick++ % 10 != 0) return
-
- // We ignore random hypixel moments
- Minecraft.getMinecraft().currentScreen ?: return
- checkItemInHand()
+ tick++
+ if (tick % 10 == 0) {
+ // We ignore random hypixel moments
+ Minecraft.getMinecraft().currentScreen ?: return
+ checkItemInHand()
+ }
}
private fun checkItemInHand() {
- val heldItem = Minecraft.getMinecraft().thePlayer.heldItem
- val crop = loadCropInHand(heldItem)
- if (cropInHand != crop) {
+ val toolItem = Minecraft.getMinecraft().thePlayer.heldItem
+ val crop = getCropTypeFromItem(toolItem)
+ val newTool = getToolInHand(toolItem, crop)
+ if (toolInHand != newTool) {
+ toolInHand = newTool
cropInHand = crop
- GardenToolChangeEvent(crop, heldItem).postAndCatch()
+ GardenToolChangeEvent(crop, toolItem).postAndCatch()
}
}
+ private fun getToolInHand(toolItem: ItemStack?, crop: CropType?): String? {
+ if (crop != null) return crop.cropName
+
+ val internalName = toolItem?.getInternalName() ?: return null
+ return if (internalName.startsWith("DAEDALUS_AXE")) "Other Tool" else null
+ }
+
@SubscribeEvent(priority = EventPriority.LOW)
fun onProfileJoin(event: ProfileJoinEvent) {
if (cropsPerSecond.isEmpty()) {
- // TODO use enum
- for (key in GardenCropMilestones.cropCounter.keys) {
- cropsPerSecond[key] = -1
+ for (cropType in CropType.values()) {
+ cropsPerSecond[cropType] = -1
}
}
}
- private fun loadCropInHand(heldItem: ItemStack?): String? {
- if (heldItem == null) return null
- return getCropTypeFromItem(heldItem, true)
- }
-
companion object {
fun inGarden() = LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.GARDEN
- var cropInHand: String? = null
- val cropsPerSecond: MutableMap<String, Int> get() = SkyHanniMod.feature.hidden.gardenCropsPerSecond
-
- fun getCropTypeFromItem(item: ItemStack, withDaedalus: Boolean = false): String? {
- val internalName = item.getInternalName()
+ var toolInHand: String? = null
+ val cropsPerSecond: MutableMap<CropType, Int> get() = SkyHanniMod.feature.hidden.gardenCropsPerSecond
+ var cropInHand: CropType? = null
- return when {
- internalName.startsWith("THEORETICAL_HOE_WHEAT") -> "Wheat"
- internalName.startsWith("THEORETICAL_HOE_CARROT") -> "Carrot"
- internalName.startsWith("THEORETICAL_HOE_POTATO") -> "Potato"
- internalName.startsWith("PUMPKIN_DICER") -> "Pumpkin"
- internalName.startsWith("THEORETICAL_HOE_CANE") -> "Sugar Cane"
- internalName.startsWith("MELON_DICER") -> "Melon"
- internalName == "CACTUS_KNIFE" -> "Cactus"
- internalName == "COCO_CHOPPER" -> "Cocoa Beans"
- internalName == "FUNGI_CUTTER" -> "Mushroom"
- internalName.startsWith("THEORETICAL_HOE_WARTS") -> "Nether Wart"
-
- internalName.startsWith("DAEDALUS_AXE") && withDaedalus -> "Daedalus Axe"
-
- else -> null
- }
+ fun getCropTypeFromItem(item: ItemStack?): CropType? {
+ val internalName = item?.getInternalName() ?: return null
+ return CropType.values().firstOrNull { internalName.startsWith(it.toolName) }
}
fun readCounter(itemStack: ItemStack): Int {
@@ -113,23 +101,24 @@ class GardenAPI {
return -1
}
- fun getCropsPerSecond(itemName: String): Int? {
- return cropsPerSecond[itemNameToCropName(itemName)]
+ fun getCropsPerSecond(crop: CropType): Int {
+ return cropsPerSecond[crop]!!
}
- fun itemNameToCropName(itemName: String): String {
+ fun itemNameToCropName(itemName: String): CropType? {
if (itemName == "Red Mushroom" || itemName == "Brown Mushroom") {
- return "Mushroom"
+ return CropType.MUSHROOM
}
- return itemName
+ return CropType.getByName(itemName)
}
- private fun getItemStackForCrop(crop: String): ItemStack {
- val internalName = NEUItems.getInternalName(if (crop == "Mushroom") "Red Mushroom Block" else crop)
+ private fun getItemStackForCrop(crop: CropType): ItemStack {
+ val cropName = if (crop == CropType.MUSHROOM) "Red Mushroom Block" else crop.cropName
+ val internalName = NEUItems.getInternalName(cropName)
return NEUItems.getItemStack(internalName)
}
- fun addGardenCropToList(crop: String, list: MutableList<Any>) {
+ fun addGardenCropToList(crop: CropType, list: MutableList<Any>) {
try {
list.add(getItemStackForCrop(crop))
} catch (e: NullPointerException) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt
index f8c602a5e..949c00204 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt
@@ -8,17 +8,17 @@ import java.util.*
class GardenBestCropTime {
val display = mutableListOf<List<Any>>()
- val timeTillNextCrop = mutableMapOf<String, Long>()
+ val timeTillNextCrop = mutableMapOf<CropType, Long>()
private val config get() = SkyHanniMod.feature.garden
- fun drawBestDisplay(currentCrop: String?) {
+ fun drawBestDisplay(currentCrop: CropType?) {
if (timeTillNextCrop.size < GardenAPI.cropsPerSecond.size) {
updateTimeTillNextCrop()
}
val gardenExp = config.cropMilestoneBestType == 0
val sorted = if (gardenExp) {
- val helpMap = mutableMapOf<String, Long>()
+ val helpMap = mutableMapOf<CropType, Long>()
for ((cropName, time) in timeTillNextCrop) {
val crops = GardenCropMilestones.cropCounter[cropName]!!
val currentTier = GardenCropMilestones.getTierForCrops(crops)
@@ -39,24 +39,24 @@ class GardenBestCropTime {
}
var number = 0
- for (cropName in sorted.keys) {
- val millis = timeTillNextCrop[cropName]!!
+ for (crop in sorted.keys) {
+ val millis = timeTillNextCrop[crop]!!
val duration = TimeUtils.formatDuration(millis)
- val isCurrent = cropName == currentCrop
+ val isCurrent = crop == currentCrop
number++
if (number > config.cropMilestoneShowOnlyBest && !isCurrent) continue
val list = mutableListOf<Any>()
list.add("§7$number# ")
- GardenAPI.addGardenCropToList(cropName, list)
+ GardenAPI.addGardenCropToList(crop, list)
val color = if (isCurrent) "§e" else "§7"
- val contestFormat = if (GardenNextJacobContest.isNextCrop(cropName)) "§n" else ""
- val cropNameDisplay = "$color$contestFormat$cropName§r"
+ val contestFormat = if (GardenNextJacobContest.isNextCrop(crop)) "§n" else ""
+ val cropNameDisplay = "$color$contestFormat${crop.cropName}§r"
list.add("$cropNameDisplay §b$duration")
if (gardenExp) {
- val crops = GardenCropMilestones.cropCounter[cropName]!!
+ val crops = GardenCropMilestones.cropCounter[crop]!!
val currentTier = GardenCropMilestones.getTierForCrops(crops)
val gardenExpForTier = getGardenExpForTier(currentTier + 1)
list.add(" §7(§2$gardenExpForTier §7Exp)")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt
index c3c1f724d..cd23fc64b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt
@@ -18,7 +18,7 @@ import java.util.*
class GardenCropMilestoneDisplay {
private val progressDisplay = mutableListOf<List<Any>>()
- private val cultivatingData = mutableMapOf<String, Int>()
+ private val cultivatingData = mutableMapOf<CropType, Int>()
private val config get() = SkyHanniMod.feature.garden
private val bestCropTime = GardenBestCropTime()
// val cropMilestoneLevelUpPattern = Pattern.compile(" §r§b§lGARDEN MILESTONE §3(.*) §8XXIII➜§3(.*)")
@@ -76,10 +76,10 @@ class GardenCropMilestoneDisplay {
@SubscribeEvent
fun onOwnInventoryItemUpdate(event: OwnInventorItemUpdateEvent) {
- val itemStack = event.itemStack
- val counter = GardenAPI.readCounter(itemStack)
+ val item = event.itemStack
+ val counter = GardenAPI.readCounter(item)
if (counter == -1) return
- val crop = GardenAPI.getCropTypeFromItem(itemStack) ?: return
+ val crop = GardenAPI.getCropTypeFromItem(item) ?: return
if (cultivatingData.containsKey(crop)) {
val old = cultivatingData[crop]!!
val diff = counter - old
@@ -106,7 +106,7 @@ class GardenCropMilestoneDisplay {
private var countInLastSecond = 0
private val allCounters = mutableListOf<Int>()
private var lastItemInHand: ItemStack? = null
- private var currentCrop: String? = null
+ private var currentCrop: CropType? = null
private fun resetSpeed() {
lastSecondStart = 0
@@ -135,8 +135,8 @@ class GardenCropMilestoneDisplay {
@SubscribeEvent
fun onGardenToolChange(event: GardenToolChangeEvent) {
- lastItemInHand = if (event.isRealCrop) event.heldItem else null
- currentCrop = if (event.isRealCrop) event.crop else null
+ lastItemInHand = event.toolItem
+ currentCrop = event.crop
if (isEnabled()) {
resetSpeed()
@@ -166,21 +166,21 @@ class GardenCropMilestoneDisplay {
}
}
- private fun drawProgressDisplay(it: String, crops: Long) {
+ private fun drawProgressDisplay(crop: CropType, counter: Long) {
progressDisplay.add(Collections.singletonList("§6Crop Milestones"))
val list = mutableListOf<Any>()
- GardenAPI.addGardenCropToList(it, list)
- list.add(it)
+ GardenAPI.addGardenCropToList(crop, list)
+ list.add(crop.cropName)
progressDisplay.add(list)
- val currentTier = GardenCropMilestones.getTierForCrops(crops)
+ val currentTier = GardenCropMilestones.getTierForCrops(counter)
val cropsForCurrentTier = GardenCropMilestones.getCropsForTier(currentTier)
val nextTier = currentTier + 1
val cropsForNextTier = GardenCropMilestones.getCropsForTier(nextTier)
- val have = crops - cropsForCurrentTier
+ val have = counter - cropsForCurrentTier
val need = cropsForNextTier - cropsForCurrentTier
val haveFormat = LorenzUtils.formatInteger(have)
@@ -196,11 +196,11 @@ class GardenCropMilestoneDisplay {
}
if (averageSpeedPerSecond != 0) {
- GardenAPI.cropsPerSecond[it] = averageSpeedPerSecond
+ GardenAPI.cropsPerSecond[crop] = averageSpeedPerSecond
val missing = need - have
val missingTimeSeconds = missing / averageSpeedPerSecond
val millis = missingTimeSeconds * 1000
- bestCropTime.timeTillNextCrop[it] = millis
+ bestCropTime.timeTillNextCrop[crop] = millis
val duration = TimeUtils.formatDuration(millis)
if (config.cropMilestoneWarnClose) {
if (millis < 5_900) {
@@ -208,7 +208,7 @@ class GardenCropMilestoneDisplay {
lastPlaySoundTime = System.currentTimeMillis()
sound.playSound()
}
- SendTitleHelper.sendTitle("§b$it $nextTier in $duration", 1_500)
+ SendTitleHelper.sendTitle("§b$crop $nextTier in $duration", 1_500)
}
}
progressDisplay.add(Collections.singletonList("§7in §b$duration"))
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCustomKeybinds.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCustomKeybinds.kt
index b0c6aed8c..26b3c7abf 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCustomKeybinds.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCustomKeybinds.kt
@@ -29,16 +29,13 @@ class GardenCustomKeybinds {
Runtime.getRuntime().addShutdownHook(Thread { reset() })
}
- private var itemInHand = ""
-
@SubscribeEvent
fun onGardenToolChange(event: GardenToolChangeEvent) {
- itemInHand = event.crop ?: ""
update()
}
private fun update() {
- if (isEnabled() && itemInHand != "") {
+ if (isEnabled() && GardenAPI.toolInHand != null) {
applyCustomKeybinds()
} else {
reset()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
index 39d6927bb..d01716ea0 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
@@ -88,11 +88,11 @@ class GardenNextJacobContest {
val day = matcherDay.group(1).toInt()
val startTime = SkyBlockTime(year, month, day).toMillis()
- val crops = mutableListOf<String>()
+ val crops = mutableListOf<CropType>()
for (line in lore) {
val matcherCrop = patternCrop.matcher(line)
if (!matcherCrop.matches()) continue
- crops.add(matcherCrop.group(1))
+ crops.add(CropType.getByNameNoNull(matcherCrop.group(1)))
}
val contest = FarmingContest(startTime + contestDuration, crops)
contests[startTime] = contest
@@ -117,7 +117,7 @@ class GardenNextJacobContest {
}
}
- class FarmingContest(val endTime: Long, val crops: List<String>)
+ class FarmingContest(val endTime: Long, val crops: List<CropType>)
private fun update() {
nextContestCrops.clear()
@@ -200,8 +200,8 @@ class GardenNextJacobContest {
companion object {
private val config get() = SkyHanniMod.feature.garden
- private val nextContestCrops = mutableListOf<String>()
+ private val nextContestCrops = mutableListOf<CropType>()
- fun isNextCrop(cropName: String) = nextContestCrops.contains(cropName) && config.nextJacobContestOtherGuis
+ fun isNextCrop(cropName: CropType) = nextContestCrops.contains(cropName) && config.nextJacobContestOtherGuis
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt
index 26e0e5876..cad800cbe 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt
@@ -17,7 +17,7 @@ class GardenOptimalSpeed {
private var optimalSpeed = -1
private val currentSpeedPattern = Pattern.compile(" Speed: §r§f✦(.*)")
private var lastWarnTime = 0L
- private var cropInHand: String? = null
+ private var cropInHand: CropType? = null
@SubscribeEvent
fun onTabListUpdate(event: TabListUpdateEvent) {
@@ -31,25 +31,23 @@ class GardenOptimalSpeed {
@SubscribeEvent
fun onGardenToolChange(event: GardenToolChangeEvent) {
- cropInHand = if (event.isRealCrop) event.crop else null
+ cropInHand = event.crop
if (isEnabled()) {
optimalSpeed = cropInHand.let { if (it != null) speedForCrop(it) else -1 }
}
}
- private fun speedForCrop(crop: String) = when (crop) {
- "Wheat" -> 93
- "Carrot" -> 93
- "Potato" -> 93
- "Pumpkin" -> 155
- "Sugar Cane" -> 328
- "Melon" -> 155
- "Cactus" -> 400 // 500 with racing helmet
- "Cocoa Beans" -> 155
- "Mushroom" -> 233
- "Nether Wart" -> 93
-
- else -> -1
+ private fun speedForCrop(crop: CropType) = when (crop) {
+ CropType.WHEAT -> 93
+ CropType.CARROT -> 93
+ CropType.POTATO -> 93
+ CropType.PUMPKIN -> 155
+ CropType.SUGAR_CANE -> 328
+ CropType.MELON -> 155
+ CropType.CACTUS -> 400 // 500 with racing helmet
+ CropType.COCOA_BEANS -> 155
+ CropType.MUSHROOM -> 233
+ CropType.NETHER_WART -> 93
}
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt
index b14b431b9..989186679 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt
@@ -232,14 +232,14 @@ class GardenVisitorFeatures {
if (config.visitorExactAmountAndTime) {
val multiplier = NEUItems.getMultiplier(internalName)
- val rawName = NEUItems.getItemStack(multiplier.first).name ?: continue
- val crop = rawName.removeColor()
- val cropAmount = multiplier.second.toLong() * amount
- GardenAPI.getCropsPerSecond(crop)?.let {
+ val rawName = NEUItems.getItemStack(multiplier.first).name?.removeColor() ?: continue
+ CropType.getByName(rawName)?.let {
+ val speed = GardenAPI.getCropsPerSecond(it)
+ val cropAmount = multiplier.second.toLong() * amount
val formatAmount = LorenzUtils.formatInteger(cropAmount)
- val formatName = "§e${formatAmount}§7x $crop "
- val formatSpeed = if (it != -1) {
- val missingTimeSeconds = cropAmount / it
+ val formatName = "§e$formatAmount§7x ${it.cropName} "
+ val formatSpeed = if (speed != -1) {
+ val missingTimeSeconds = cropAmount / speed
val duration = TimeUtils.formatDuration(missingTimeSeconds * 1000)
"in §b$duration"
} else {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt
index e012b60c3..66042304d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt
@@ -68,9 +68,8 @@ class WrongFungiCutterWarning {
@SubscribeEvent
fun onGardenToolChange(event: GardenToolChangeEvent) {
- val crop = event.crop ?: ""
- if (crop == "Mushroom") {
- readItem(event.heldItem!!)
+ if (event.crop == CropType.MUSHROOM) {
+ readItem(event.toolItem!!)
} else {
mode = FungiMode.UNKNOWN
}