Skip to content

Commit 6270c1a

Browse files
Make the MishapInvalidIota lang fallback actually work (#994)
2 parents 0124f37 + e4c989a commit 6270c1a

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidIota.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ class MishapInvalidIota(
2626

2727
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component? {
2828
val perpKey = HexIotaTypes.REGISTRY.getKey(perpetrator.getType())
29-
val perpDesc = Component.translatableWithFallback(
30-
"hexcasting.iota.${perpKey}.desc",
31-
"hexcasting.mishap.invalid_value.class.${perpKey?.getPath()}"
32-
)
29+
30+
// this translation key is preferred because it includes the namespace
31+
var perpDesc = Component.translatableWithFallback("hexcasting.iota.${perpKey}.desc", "no desc found")
32+
// for addons that don't implement the .desc key, grab the non-namespaced invalid_value key instead
33+
if (perpDesc.getString() == "no desc found")
34+
perpDesc = Component.translatable("hexcasting.mishap.invalid_value.class.${perpKey?.getPath()}")
35+
3336
return error(
3437
"invalid_value", expected, reverseIdx,
3538
perpDesc, perpetrator.display()

0 commit comments

Comments
 (0)