diff options
author | Linnea Gräf <nea@nea.moe> | 2024-02-09 12:00:50 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-02-09 12:00:50 +0100 |
commit | efbef712130048e1bf39e66b15271bf663586eee (patch) | |
tree | 5260c953cdb3825128d43323a7de6557561cb7af /src/main | |
parent | 0cb6e308acc313a22f9fd796cc47301272485120 (diff) | |
download | firmament-efbef712130048e1bf39e66b15271bf663586eee.tar.gz firmament-efbef712130048e1bf39e66b15271bf663586eee.tar.bz2 firmament-efbef712130048e1bf39e66b15271bf663586eee.zip |
Fix crash when rendering SkyBlock id in a string
Diffstat (limited to 'src/main')
14 files changed, 55 insertions, 87 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/commands/rome.kt b/src/main/kotlin/moe/nea/firmament/commands/rome.kt index eeb5f3e..91bdf47 100644 --- a/src/main/kotlin/moe/nea/firmament/commands/rome.kt +++ b/src/main/kotlin/moe/nea/firmament/commands/rome.kt @@ -52,25 +52,19 @@ fun firmamentCommand() = literal("firmament") { val configObj = AllConfigsGui.allConfigs.find { it.name == config } if (configObj == null) { - source.sendFeedback(Text.translatable("firmament.command.toggle.no-config-found", config)) + source.sendFeedback(Text.stringifiedTranslatable("firmament.command.toggle.no-config-found", config)) return@thenExecute } val propertyObj = configObj.allOptions[property] if (propertyObj == null) { source.sendFeedback( - Text.translatable( - "firmament.command.toggle.no-property-found", - property - ) + Text.stringifiedTranslatable("firmament.command.toggle.no-property-found", property) ) return@thenExecute } if (propertyObj.handler !is BooleanHandler) { source.sendFeedback( - Text.translatable( - "firmament.command.toggle.not-a-toggle", - property - ) + Text.stringifiedTranslatable("firmament.command.toggle.not-a-toggle", property) ) return@thenExecute } @@ -78,12 +72,9 @@ fun firmamentCommand() = literal("firmament") { propertyObj.value = !propertyObj.value configObj.save() source.sendFeedback( - Text.translatable( - "firmament.command.toggle.toggled", - configObj.labelText, - propertyObj.labelText, - Text.translatable("firmament.toggle.${propertyObj.value}") - ) + Text.stringifiedTranslatable("firmament.command.toggle.toggled",configObj.labelText, + propertyObj.labelText, + Text.translatable("firmament.toggle.${propertyObj.value}")) ) } } @@ -145,48 +136,30 @@ fun firmamentCommand() = literal("firmament") { suggestsList { RepoManager.neuRepo.items.items.keys } thenExecute { val itemName = SkyblockId(get(item)) - source.sendFeedback(Text.translatable("firmament.price", itemName.neuItem)) + source.sendFeedback(Text.stringifiedTranslatable("firmament.price", itemName.neuItem)) val bazaarData = HypixelStaticData.bazaarData[itemName] if (bazaarData != null) { source.sendFeedback(Text.translatable("firmament.price.bazaar")) source.sendFeedback( - Text.translatable( - "firmament.price.bazaar.productid", - bazaarData.productId.bazaarId - ) + Text.stringifiedTranslatable("firmament.price.bazaar.productid", bazaarData.productId.bazaarId) ) source.sendFeedback( - Text.translatable( - "firmament.price.bazaar.buy.price", - FirmFormatters.formatCurrency(bazaarData.quickStatus.buyPrice, 1) - ) + Text.stringifiedTranslatable("firmament.price.bazaar.buy.price", FirmFormatters.formatCurrency(bazaarData.quickStatus.buyPrice, 1)) ) source.sendFeedback( - Text.translatable( - "firmament.price.bazaar.buy.order", - bazaarData.quickStatus.buyOrders - ) + Text.stringifiedTranslatable("firmament.price.bazaar.buy.order", bazaarData.quickStatus.buyOrders) ) source.sendFeedback( - Text.translatable( - "firmament.price.bazaar.sell.price", - FirmFormatters.formatCurrency(bazaarData.quickStatus.sellPrice, 1) - ) + Text.stringifiedTranslatable("firmament.price.bazaar.sell.price", FirmFormatters.formatCurrency(bazaarData.quickStatus.sellPrice, 1)) ) source.sendFeedback( - Text.translatable( - "firmament.price.bazaar.sell.order", - bazaarData.quickStatus.sellOrders - ) + Text.stringifiedTranslatable("firmament.price.bazaar.sell.order", bazaarData.quickStatus.sellOrders) ) } val lowestBin = HypixelStaticData.lowestBin[itemName] if (lowestBin != null) { source.sendFeedback( - Text.translatable( - "firmament.price.lowestbin", - FirmFormatters.formatCurrency(lowestBin, 1) - ) + Text.stringifiedTranslatable("firmament.price.lowestbin", FirmFormatters.formatCurrency(lowestBin, 1)) ) } } @@ -200,15 +173,15 @@ fun firmamentCommand() = literal("firmament") { } thenLiteral("sbdata") { thenExecute { - source.sendFeedback(Text.translatable("firmament.sbinfo.profile", SBData.profileId)) + source.sendFeedback(Text.stringifiedTranslatable("firmament.sbinfo.profile", SBData.profileId)) val locrawInfo = SBData.locraw if (locrawInfo == null) { source.sendFeedback(Text.translatable("firmament.sbinfo.nolocraw")) } else { - source.sendFeedback(Text.translatable("firmament.sbinfo.server", locrawInfo.server)) - source.sendFeedback(Text.translatable("firmament.sbinfo.gametype", locrawInfo.gametype)) - source.sendFeedback(Text.translatable("firmament.sbinfo.mode", locrawInfo.mode)) - source.sendFeedback(Text.translatable("firmament.sbinfo.map", locrawInfo.map)) + source.sendFeedback(Text.stringifiedTranslatable("firmament.sbinfo.server", locrawInfo.server)) + source.sendFeedback(Text.stringifiedTranslatable("firmament.sbinfo.gametype", locrawInfo.gametype)) + source.sendFeedback(Text.stringifiedTranslatable("firmament.sbinfo.mode", locrawInfo.mode)) + source.sendFeedback(Text.stringifiedTranslatable("firmament.sbinfo.map", locrawInfo.map)) } } } @@ -217,7 +190,7 @@ fun firmamentCommand() = literal("firmament") { thenExecute { source.sendFeedback(Text.translatable("firmament.ursa.debugrequest.start")) val text = UrsaManager.request(this[path].split("/")).bodyAsText() - source.sendFeedback(Text.translatable("firmament.ursa.debugrequest.result", text)) + source.sendFeedback(Text.stringifiedTranslatable("firmament.ursa.debugrequest.result", text)) } } } diff --git a/src/main/kotlin/moe/nea/firmament/features/chat/QuickCommands.kt b/src/main/kotlin/moe/nea/firmament/features/chat/QuickCommands.kt index c4a9037..47be3c1 100644 --- a/src/main/kotlin/moe/nea/firmament/features/chat/QuickCommands.kt +++ b/src/main/kotlin/moe/nea/firmament/features/chat/QuickCommands.kt @@ -46,9 +46,9 @@ object QuickCommands : FirmamentFeature { } val joinName = getNameForFloor(what.replace(" ", "").lowercase()) if (joinName == null) { - source.sendFeedback(Text.translatable("firmament.quick-commands.join.unknown",what)) + source.sendFeedback(Text.stringifiedTranslatable("firmament.quick-commands.join.unknown", what)) } else { - source.sendFeedback(Text.translatable("firmament.quick-commands.join.success", joinName)) + source.sendFeedback(Text.stringifiedTranslatable("firmament.quick-commands.join.success", joinName)) MC.sendCommand("joininstance $joinName") } } @@ -70,7 +70,7 @@ object QuickCommands : FirmamentFeature { ) } if (l !in kuudraLevelNames.indices) { - source.sendFeedback(Text.translatable("firmament.quick-commands.join.unknown-kuudra", kuudraLevel)) + source.sendFeedback(Text.stringifiedTranslatable("firmament.quick-commands.join.unknown-kuudra", kuudraLevel)) return null } return "KUUDRA_${kuudraLevelNames[l]}" @@ -90,7 +90,7 @@ object QuickCommands : FirmamentFeature { return "CATACOMBS_ENTRANCE" } if (l !in dungeonLevelNames.indices) { - source.sendFeedback(Text.translatable("firmament.quick-commands.join.unknown-catacombs", kuudraLevel)) + source.sendFeedback(Text.stringifiedTranslatable("firmament.quick-commands.join.unknown-catacombs", kuudraLevel)) return null } return "${if (masterLevel != null) "MASTER_" else ""}CATACOMBS_FLOOR_${dungeonLevelNames[l]}" diff --git a/src/main/kotlin/moe/nea/firmament/features/debug/DeveloperFeatures.kt b/src/main/kotlin/moe/nea/firmament/features/debug/DeveloperFeatures.kt index 6bf299f..6bbbdf0 100644 --- a/src/main/kotlin/moe/nea/firmament/features/debug/DeveloperFeatures.kt +++ b/src/main/kotlin/moe/nea/firmament/features/debug/DeveloperFeatures.kt @@ -47,7 +47,7 @@ object DeveloperFeatures : FirmamentFeature { MC.player?.sendMessage(Text.translatable("firmament.dev.resourcerebuild.start")) val startTime = TimeMark.now() process.toHandle().onExit().thenApply { - MC.player?.sendMessage(Text.translatable("firmament.dev.resourcerebuild.done", startTime.passedTime())) + MC.player?.sendMessage(Text.stringifiedTranslatable("firmament.dev.resourcerebuild.done", startTime.passedTime())) Unit } } else { diff --git a/src/main/kotlin/moe/nea/firmament/features/debug/PowerUserTools.kt b/src/main/kotlin/moe/nea/firmament/features/debug/PowerUserTools.kt index 4140490..3545f21 100644 --- a/src/main/kotlin/moe/nea/firmament/features/debug/PowerUserTools.kt +++ b/src/main/kotlin/moe/nea/firmament/features/debug/PowerUserTools.kt @@ -54,7 +54,7 @@ object PowerUserTools : FirmamentFeature { ItemTooltipEvent.subscribe { if (TConfig.showItemIds) { val id = it.stack.skyBlockId ?: return@subscribe - it.lines.add(Text.translatable("firmament.tooltip.skyblockid", id.neuItem)) + it.lines.add(Text.stringifiedTranslatable("firmament.tooltip.skyblockid", id.neuItem)) } val (item, text) = lastCopiedStack ?: return@subscribe if (!ItemStack.areEqual(item, it.stack)) { @@ -83,7 +83,7 @@ object PowerUserTools : FirmamentFeature { MC.sendChat(Text.translatable("firmament.tooltip.copied.skull.fail")) } else { ClipboardUtils.setTextContent(id.toString()) - MC.sendChat(Text.translatable("firmament.tooltip.copied.skull", id.toString())) + MC.sendChat(Text.stringifiedTranslatable("firmament.tooltip.copied.skull", id.toString())) } } } @@ -105,7 +105,7 @@ object PowerUserTools : FirmamentFeature { return@subscribe } ClipboardUtils.setTextContent(sbId.neuItem) - lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.skyblockid", sbId.neuItem)) + lastCopiedStack = Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.skyblockid", sbId.neuItem)) } else if (it.matches(TConfig.copyTexturePackId)) { val model = CustomItemModelEvent.getModelIdentifier(item) if (model == null) { @@ -113,7 +113,7 @@ object PowerUserTools : FirmamentFeature { return@subscribe } ClipboardUtils.setTextContent(model.toString()) - lastCopiedStack = Pair(item, Text.translatable("firmament.tooltip.copied.modelid", model.toString())) + lastCopiedStack = Pair(item, Text.stringifiedTranslatable("firmament.tooltip.copied.modelid", model.toString())) } else if (it.matches(TConfig.copyNbtData)) { val nbt = item.orCreateNbt.toString() ClipboardUtils.setTextContent(nbt) diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/PriceData.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/PriceData.kt index 8062357..aa8982d 100644 --- a/src/main/kotlin/moe/nea/firmament/features/inventory/PriceData.kt +++ b/src/main/kotlin/moe/nea/firmament/features/inventory/PriceData.kt @@ -36,24 +36,15 @@ object PriceData : FirmamentFeature { if (bazaarData != null) { it.lines.add(Text.literal("")) it.lines.add( - Text.translatable( - "firmament.tooltip.bazaar.sell-order", - FirmFormatters.formatCurrency(bazaarData.quickStatus.sellPrice, 1) - ) + Text.stringifiedTranslatable("firmament.tooltip.bazaar.sell-order", FirmFormatters.formatCurrency(bazaarData.quickStatus.sellPrice, 1)) ) it.lines.add( - Text.translatable( - "firmament.tooltip.bazaar.buy-order", - FirmFormatters.formatCurrency(bazaarData.quickStatus.buyPrice, 1) - ) + Text.stringifiedTranslatable("firmament.tooltip.bazaar.buy-order", FirmFormatters.formatCurrency(bazaarData.quickStatus.buyPrice, 1)) ) } else if (lowestBin != null) { it.lines.add(Text.literal("")) it.lines.add( - Text.translatable( - "firmament.tooltip.ah.lowestbin", - FirmFormatters.formatCurrency(lowestBin, 1) - ) + Text.stringifiedTranslatable("firmament.tooltip.ah.lowestbin", FirmFormatters.formatCurrency(lowestBin, 1)) ) } } diff --git a/src/main/kotlin/moe/nea/firmament/features/mining/PristineProfitTracker.kt b/src/main/kotlin/moe/nea/firmament/features/mining/PristineProfitTracker.kt index 294c835..ddda5a5 100644 --- a/src/main/kotlin/moe/nea/firmament/features/mining/PristineProfitTracker.kt +++ b/src/main/kotlin/moe/nea/firmament/features/mining/PristineProfitTracker.kt @@ -97,15 +97,9 @@ object PristineProfitTracker : FirmamentFeature { val moneyPerSecond = moneyHistogram.averagePer({ it }, 1.seconds) if (collectionPerSecond == null || moneyPerSecond == null) return ProfitHud.collectionCurrent = collectionPerSecond - ProfitHud.collectionText = Text.translatable( - "firmament.pristine-profit.collection", - formatCurrency(collectionPerSecond * SECONDS_PER_HOUR, 1) - ).formattedString() + ProfitHud.collectionText = Text.stringifiedTranslatable("firmament.pristine-profit.collection", formatCurrency(collectionPerSecond * SECONDS_PER_HOUR, 1)).formattedString() ProfitHud.moneyCurrent = moneyPerSecond - ProfitHud.moneyText = Text.translatable( - "firmament.pristine-profit.money", - formatCurrency(moneyPerSecond * SECONDS_PER_HOUR, 1) - ).formattedString() + ProfitHud.moneyText = Text.stringifiedTranslatable("firmament.pristine-profit.money", formatCurrency(moneyPerSecond * SECONDS_PER_HOUR, 1)).formattedString() val data = DConfig.data if (data != null) { if (data.maxCollectionPerSecond < collectionPerSecond && collectionHistogram.oldestUpdate() diff --git a/src/main/kotlin/moe/nea/firmament/features/world/Waypoints.kt b/src/main/kotlin/moe/nea/firmament/features/world/Waypoints.kt index 00cbc10..05b1ba5 100644 --- a/src/main/kotlin/moe/nea/firmament/features/world/Waypoints.kt +++ b/src/main/kotlin/moe/nea/firmament/features/world/Waypoints.kt @@ -52,7 +52,7 @@ object Waypoints : FirmamentFeature { ?.skinTextures ?.texture withFacingThePlayer(waypoint.pos.toCenterPos()) { - waypoint(waypoint.pos, Text.translatable("firmament.waypoint.temporary", player)) + waypoint(waypoint.pos, Text.stringifiedTranslatable("firmament.waypoint.temporary", player)) if (skin != null) { matrixStack.translate(0F, -20F, 0F) // Head front diff --git a/src/main/kotlin/moe/nea/firmament/gui/config/HudMetaHandler.kt b/src/main/kotlin/moe/nea/firmament/gui/config/HudMetaHandler.kt index 3993bfa..7df98e3 100644 --- a/src/main/kotlin/moe/nea/firmament/gui/config/HudMetaHandler.kt +++ b/src/main/kotlin/moe/nea/firmament/gui/config/HudMetaHandler.kt @@ -27,7 +27,7 @@ class HudMetaHandler(val config: ManagedConfig, val label: MutableText, val widt } override fun emitGuiElements(opt: ManagedOption<HudMeta>, guiAppender: GuiAppender) { - guiAppender.appendLabeledRow(opt.labelText, WButton(Text.translatable("firmament.hud.edit", label)) + guiAppender.appendLabeledRow(opt.labelText, WButton(Text.stringifiedTranslatable("firmament.hud.edit", label)) .also { it.setOnClick { MC.screen = JarvisIntegration.jarvis.getHudEditor( diff --git a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewer.kt b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewer.kt index e811663..ada7603 100644 --- a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewer.kt +++ b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewer.kt @@ -44,31 +44,31 @@ class ProfileViewer( companion object { suspend fun onCommand(source: FabricClientCommandSource, name: String) { - source.sendFeedback(Text.translatable("firmament.pv.lookingup", name)) + source.sendFeedback(Text.stringifiedTranslatable("firmament.pv.lookingup", name)) try { val uuid = Routes.getUUIDForPlayerName(name) if (uuid == null) { - source.sendError(Text.translatable("firmament.pv.noplayer", name)) + source.sendError(Text.stringifiedTranslatable("firmament.pv.noplayer", name)) return } val name = Routes.getPlayerNameForUUID(uuid) ?: name val names = mapOf(uuid to (name)) val data = Routes.getAccountData(uuid) if (data == null) { - source.sendError(Text.translatable("firmament.pv.noprofile", name)) + source.sendError(Text.stringifiedTranslatable("firmament.pv.noprofile", name)) return } val accountData = mapOf(data.uuid to data) val profiles = Routes.getProfiles(uuid) val profile = profiles?.profiles?.find { it.selected } if (profile == null) { - source.sendFeedback(Text.translatable("firmament.pv.noprofile", name)) + source.sendFeedback(Text.stringifiedTranslatable("firmament.pv.noprofile", name)) return } ScreenUtil.setScreenLater(CottonClientScreen(ProfileViewer(uuid, names, accountData, profile))) } catch (e: Exception) { Firmament.logger.error("Error loading profile data for $name", e) - source.sendError(Text.translatable("firmament.pv.badprofile", name, e.message)) + source.sendError(Text.stringifiedTranslatable("firmament.pv.badprofile", name, e.message)) } } } diff --git a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt index 197f560..76c88c2 100644 --- a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt +++ b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt @@ -49,7 +49,7 @@ object SkillPage : ProfilePage { ) { override fun addTooltip(tooltip: TooltipBuilder) { tooltip.add(Text.literal("$level/$maxLevel")) - tooltip.add(Text.translatable("firmament.pv.skills.total", FirmFormatters.formatCurrency(exp, 1))) + tooltip.add(Text.stringifiedTranslatable("firmament.pv.skills.total", FirmFormatters.formatCurrency(exp, 1))) } } } diff --git a/src/main/kotlin/moe/nea/firmament/rei/recipes/SBForgeRecipe.kt b/src/main/kotlin/moe/nea/firmament/rei/recipes/SBForgeRecipe.kt index 3960728..887b84e 100644 --- a/src/main/kotlin/moe/nea/firmament/rei/recipes/SBForgeRecipe.kt +++ b/src/main/kotlin/moe/nea/firmament/rei/recipes/SBForgeRecipe.kt @@ -43,7 +43,7 @@ class SBForgeRecipe(override val neuRecipe: NEUForgeRecipe) : SBRecipe() { add(Widgets.createResultSlotBackground(Point(bounds.minX + 124, bounds.minY + 46))) val arrow = Widgets.createArrow(Point(bounds.minX + 90, bounds.minY + 54 - 18 / 2)) add(arrow) - add(Widgets.createTooltip(arrow.bounds, Text.translatable("firmament.recipe.forge.time", display.neuRecipe.duration.seconds))) + add(Widgets.createTooltip(arrow.bounds, Text.stringifiedTranslatable("firmament.recipe.forge.time", display.neuRecipe.duration.seconds))) val ingredientsCenter = Point(bounds.minX + 49 - 8, bounds.minY + 54 - 8) val count = display.neuRecipe.inputs.size if (count == 1) { diff --git a/src/main/kotlin/moe/nea/firmament/repo/ItemCache.kt b/src/main/kotlin/moe/nea/firmament/repo/ItemCache.kt index 0688497..067069b 100644 --- a/src/main/kotlin/moe/nea/firmament/repo/ItemCache.kt +++ b/src/main/kotlin/moe/nea/firmament/repo/ItemCache.kt @@ -14,7 +14,7 @@ import io.github.moulberry.repo.IReloadable import io.github.moulberry.repo.NEURepository import io.github.moulberry.repo.data.NEUItem import java.text.NumberFormat -import java.util.UUID +import java.util.* import java.util.concurrent.ConcurrentHashMap import org.apache.logging.log4j.LogManager import kotlinx.coroutines.Job @@ -74,7 +74,14 @@ object ItemCache : IReloadable { fun brokenItemStack(neuItem: NEUItem?, idHint: SkyblockId? = null): ItemStack { return ItemStack(Items.PAINTING).apply { setCustomName(Text.literal(neuItem?.displayName ?: idHint?.neuItem ?: "null")) - appendLore(listOf(Text.translatable("firmament.repo.brokenitem", neuItem?.skyblockItemId ?: idHint))) + appendLore( + listOf( + Text.stringifiedTranslatable( + "firmament.repo.brokenitem", + (neuItem?.skyblockItemId ?: idHint) + ) + ) + ) } } diff --git a/src/main/kotlin/moe/nea/firmament/util/SkyblockId.kt b/src/main/kotlin/moe/nea/firmament/util/SkyblockId.kt index a071107..37a1f0c 100644 --- a/src/main/kotlin/moe/nea/firmament/util/SkyblockId.kt +++ b/src/main/kotlin/moe/nea/firmament/util/SkyblockId.kt @@ -30,6 +30,9 @@ import moe.nea.firmament.util.json.DashlessUUIDSerializer @Serializable value class SkyblockId(val neuItem: String) { val identifier get() = Identifier("skyblockitem", neuItem.lowercase().replace(";", "__").replace(":", "___")) + override fun toString(): String { + return neuItem + } /** * A bazaar stock item id, as returned by the HyPixel bazaar api endpoint. diff --git a/src/main/kotlin/moe/nea/firmament/util/WarpUtil.kt b/src/main/kotlin/moe/nea/firmament/util/WarpUtil.kt index 25cfdb0..5a7911c 100644 --- a/src/main/kotlin/moe/nea/firmament/util/WarpUtil.kt +++ b/src/main/kotlin/moe/nea/firmament/util/WarpUtil.kt @@ -65,7 +65,7 @@ object WarpUtil { ) { DConfig.data?.excludedWarps?.add(lastAttemptedWarp) DConfig.markDirty() - MC.sendChat(Text.translatable("firmament.warp-util.mark-excluded", lastAttemptedWarp)) + MC.sendChat(Text.stringifiedTranslatable("firmament.warp-util.mark-excluded", lastAttemptedWarp)) lastWarpAttempt = TimeMark.farPast() } if (it.unformattedString == "You may now fast travel to") { |