From fa11d343ab65031c3f1f8b53b55e1b1f68d49f5d Mon Sep 17 00:00:00 2001 From: Daniel Orr Date: Fri, 26 Jul 2024 13:54:02 +0100 Subject: [PATCH] Catch untrusted functions --- gradle.properties | 2 +- .../entities/entity/PlayerAttachedTextDisplayEntity.kt | 8 ++++++-- .../entities/entity/TemporaryTextDisplayEntity.kt | 8 ++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 7bfbbab..b6b9399 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ kotlin_version=1.9.24 fabric_kotlin_version=1.10.20 # Mod Properties -mod_version=1.1.4 +mod_version=1.1.5 maven_group=net.mcbrawls mod_id=brawls-entities diff --git a/src/main/kotlin/net/mcbrawls/entities/entity/PlayerAttachedTextDisplayEntity.kt b/src/main/kotlin/net/mcbrawls/entities/entity/PlayerAttachedTextDisplayEntity.kt index 4c99ac6..d6ac699 100644 --- a/src/main/kotlin/net/mcbrawls/entities/entity/PlayerAttachedTextDisplayEntity.kt +++ b/src/main/kotlin/net/mcbrawls/entities/entity/PlayerAttachedTextDisplayEntity.kt @@ -65,8 +65,12 @@ open class PlayerAttachedTextDisplayEntity( startRiding(player, true) } - val text = textSupplier.getText(player, age) - setText(text) + try { + val text = textSupplier.getText(player, age) + setText(text) + } catch (exception: Exception) { + exception.printStackTrace() + } } } diff --git a/src/main/kotlin/net/mcbrawls/entities/entity/TemporaryTextDisplayEntity.kt b/src/main/kotlin/net/mcbrawls/entities/entity/TemporaryTextDisplayEntity.kt index 314019f..13bf2bd 100644 --- a/src/main/kotlin/net/mcbrawls/entities/entity/TemporaryTextDisplayEntity.kt +++ b/src/main/kotlin/net/mcbrawls/entities/entity/TemporaryTextDisplayEntity.kt @@ -46,8 +46,12 @@ open class TemporaryTextDisplayEntity( val yOffset = MAX_Y_OFFSET * percentage setPosition(initialPosition.add(0.0, yOffset, 0.0)) - val text = textSupplier.getText(this, age) - setText(text) + try { + val text = textSupplier.getText(this, age) + setText(text) + } catch (exception: Exception) { + exception.printStackTrace() + } } }