Skip to content

Commit 7740e0b

Browse files
committed
fix(bukkit/nms): safely retrieve ServerEntity constructor using runCatching
1 parent a01f1f7 commit 7740e0b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • stickynote-bukkit/stickynote-bukkit-nms/src/main/kotlin/org/sayandev/stickynote/bukkit/nms

stickynote-bukkit/stickynote-bukkit-nms/src/main/kotlin/org/sayandev/stickynote/bukkit/nms/NMSUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ import java.util.function.UnaryOperator
3232

3333
object NMSUtils {
3434

35-
private val PAPER_SERVER_ENTITY_CONSTRUCTOR: Constructor<*>? = ServerEntityAccessor.TYPE?.getDeclaredConstructor(
35+
private val PAPER_SERVER_ENTITY_CONSTRUCTOR: Constructor<*>? = runCatching { ServerEntityAccessor.TYPE?.getDeclaredConstructor(
3636
ServerLevelAccessor.TYPE,
3737
EntityAccessor.TYPE,
3838
Int::class.java,
3939
Boolean::class.java,
4040
Consumer::class.java,
4141
Set::class.java
42-
)
42+
) }.getOrNull()
4343
private val CRAFT_ITEM_STACK: Result<Class<*>> = runCatching { XReflection.getCraftClass("inventory.CraftItemStack") }
4444
private val CRAFT_PLAYER: Result<Class<*>> = runCatching { XReflection.getCraftClass("entity.CraftPlayer") }
4545
private val CRAFT_WORLD: Result<Class<*>> = runCatching { XReflection.getCraftClass("CraftWorld") }

0 commit comments

Comments
 (0)