diff options
Diffstat (limited to 'src/main/java/at')
7 files changed, 49 insertions, 51 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index a2c927ef1..4ae9ed824 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -510,7 +510,7 @@ class SkyHanniMod { loadModule(EntityData()) loadModule(MobData()) loadModule(MobDetection()) - loadModule(EntityMovementData()) + loadModule(EntityMovementData) loadModule(TestExportTools) loadModule(ItemClickData()) // loadModule(Year300RaffleEvent) @@ -524,7 +524,7 @@ class SkyHanniMod { loadModule(RenderData()) loadModule(GardenCropMilestones) loadModule(GardenCropMilestonesCommunityFix) - loadModule(GardenCropUpgrades()) + loadModule(GardenCropUpgrades) loadModule(VisitorListener()) loadModule(VisitorRewardWarning()) loadModule(OwnInventoryData()) @@ -736,7 +736,7 @@ class SkyHanniMod { loadModule(MinionCraftHelper()) loadModule(TpsCounter()) loadModule(ParticleHider()) - loadModule(MiscFeatures()) + loadModule(MiscFeatures) loadModule(ReplaceRomanNumerals()) loadModule(GardenPlotMenuHighlighting()) loadModule(SkyMartCopperPrice()) 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 24c85e80c..a914e0c59 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -5,7 +5,6 @@ import at.hannibal2.skyhanni.api.SkillAPI import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.config.ConfigGuiManager import at.hannibal2.skyhanni.config.features.About.UpdateStream -import at.hannibal2.skyhanni.utils.chat.ChatClickActionManager import at.hannibal2.skyhanni.data.ChatManager import at.hannibal2.skyhanni.data.GardenCropMilestonesCommunityFix import at.hannibal2.skyhanni.data.GuiEditManager @@ -82,6 +81,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.splitLines import at.hannibal2.skyhanni.utils.TabListData +import at.hannibal2.skyhanni.utils.chat.ChatClickActionManager import at.hannibal2.skyhanni.utils.chat.Text import at.hannibal2.skyhanni.utils.chat.Text.hover import at.hannibal2.skyhanni.utils.chat.Text.suggest @@ -316,7 +316,7 @@ object Commands { registerCommand( "shlimbo", "Warps you to Limbo." - ) { MiscFeatures().goToLimbo() } + ) { MiscFeatures.goToLimbo() } registerCommand( "shlanedetection", "Detect a farming lane in garden" diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt index 97039022a..17bf953c9 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt @@ -15,16 +15,18 @@ import net.minecraft.client.Minecraft import net.minecraft.entity.Entity import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class EntityMovementData { +object EntityMovementData { - companion object { + private val warpingPattern by RepoPattern.pattern( + "data.entity.warping", + "§7(?:Warping|Warping you to your SkyBlock island|Warping using transfer token|Finding player|Sending a visit request)\\.\\.\\." + ) - private val entityLocation = mutableMapOf<Entity, LorenzVec>() + private val entityLocation = mutableMapOf<Entity, LorenzVec>() - fun addToTrack(entity: Entity) { - if (entity !in entityLocation) { - entityLocation[entity] = entity.getLorenzVec() - } + fun addToTrack(entity: Entity) { + if (entity !in entityLocation) { + entityLocation[entity] = entity.getLorenzVec() } } @@ -46,15 +48,6 @@ class EntityMovementData { } } - private val warpingPattern by RepoPattern.pattern( - "warping", - "§7Warping...|" + - "§7Warping you to your SkyBlock island...|" + - "§7Warping using transfer token...|" + - "§7Finding player...|" + - "§7Sending a visit request..." - ) - @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (!LorenzUtils.inSkyBlock) return diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt index e6c810852..5a131ae79 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt @@ -1,52 +1,60 @@ package at.hannibal2.skyhanni.data -import at.hannibal2.skyhanni.events.CropUpgradeUpdateEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.garden.CropType -import at.hannibal2.skyhanni.features.garden.CropType.Companion.getByNameOrNull import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.NumberUtil.formatInt +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class GardenCropUpgrades { +object GardenCropUpgrades { - // TODO USE SH-REPO - private val tierPattern = "§7Current Tier: §[0-9a-e](\\d)§7/§a9".toRegex() - private val chatUpgradePattern = " {2}§r§6§lCROP UPGRADE §e§f([\\w ]+)§7 #(\\d)".toRegex() + private val patternGroup = RepoPattern.group("garden.cropupgrades") + private val tierPattern by patternGroup.pattern( + "tier", + "§7Current Tier: §.(?<level>\\d)§7/§a9" + ) + private val chatUpgradePattern by patternGroup.pattern( + "chatupgrade", + "\\s+§r§6§lCROP UPGRADE §e(?<crop>[\\w ]+)§7 #(?<tier>\\d)" + ) + + private val cropUpgrades: MutableMap<CropType, Int>? get() = GardenAPI.storage?.cropUpgrades @SubscribeEvent fun onChat(event: LorenzChatEvent) { - chatUpgradePattern.matchEntire(event.message)?.groups?.let { matches -> - val crop = getByNameOrNull(matches[1]!!.value) ?: return - val level = matches[2]!!.value.toInt() - crop.setUpgradeLevel(level) + if (!GardenAPI.inGarden()) return + + chatUpgradePattern.matchMatcher(event.message) { + val crop = CropType.getByNameOrNull(group("crop")) + val level = group("tier").formatInt() + crop?.setUpgradeLevel(level) } - CropUpgradeUpdateEvent().postAndCatch() } @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { + if (!GardenAPI.inGarden()) return if (event.inventoryName != "Crop Upgrades") return - event.inventoryItems.forEach { (_, item) -> - val crop = CropType.getByNameOrNull(item.name.removeColor()) ?: return@forEach - val level = item.getLore() - .firstNotNullOfOrNull { tierPattern.matchEntire(it)?.groups?.get(1)?.value?.toIntOrNull() } ?: 0 - crop.setUpgradeLevel(level) + + for (item in event.inventoryItems.values) { + val crop = CropType.getByNameOrNull(item.name.removeColor()) ?: continue + item.getLore().matchFirst(tierPattern) { + val level = group("level").formatInt() + crop.setUpgradeLevel(level) + } } - CropUpgradeUpdateEvent().postAndCatch() } - companion object { + fun CropType.getUpgradeLevel() = cropUpgrades?.get(this) - private val cropUpgrades: MutableMap<CropType, Int>? get() = GardenAPI.storage?.cropUpgrades - - fun CropType.getUpgradeLevel() = cropUpgrades?.get(this) - - fun CropType.setUpgradeLevel(level: Int) { - cropUpgrades?.put(this, level) - } + private fun CropType.setUpgradeLevel(level: Int) { + cropUpgrades?.put(this, level) } } diff --git a/src/main/java/at/hannibal2/skyhanni/events/CropUpgradeUpdateEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/CropUpgradeUpdateEvent.kt deleted file mode 100644 index 3deccc74c..000000000 --- a/src/main/java/at/hannibal2/skyhanni/events/CropUpgradeUpdateEvent.kt +++ /dev/null @@ -1,3 +0,0 @@ -package at.hannibal2.skyhanni.events - -class CropUpgradeUpdateEvent : LorenzEvent()
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt index a23f34c66..c7b38164e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.features.garden.fortuneguide import at.hannibal2.skyhanni.data.CropAccessoryData -import at.hannibal2.skyhanni.data.GardenCropUpgrades.Companion.getUpgradeLevel +import at.hannibal2.skyhanni.data.GardenCropUpgrades.getUpgradeLevel import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MiscFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MiscFeatures.kt index 2dac01bb2..09ee41e8d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/MiscFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MiscFeatures.kt @@ -13,7 +13,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent /** * I need these features in my dev env */ -class MiscFeatures { +object MiscFeatures { @SubscribeEvent fun onEnderTeleport(event: EnderTeleportEvent) { |