Firstly,
Hello everyone. I'm creating some plugin to Paper that will care about player metrics.
For that I have a list of metrics, that will have a lot of handlers for each metric. Like: playerDamageToPlayers, playerMinedBlockOres, etc.

This implies that I can many metrics for each spread event, so when player break a block, I can have one or more metrics, like this one above.
The event handler will get the metrics list and do something like that:

The problem:
I'm running this metrics in some Coroutine with launch() from kotlin. So lines like:


Evaluate different types of blocks. I think that happens because when I use .block (getBlock) out of the coroutine the event get the context has the blocks as being dirt yet, but in coroutine the block has been break already, so it gets the type air, because the block is now air. Something like that.
How do you guys handle that when using kotlin and have to use coroutines?
Hello everyone. I'm creating some plugin to Paper that will care about player metrics.
For that I have a list of metrics, that will have a lot of handlers for each metric. Like: playerDamageToPlayers, playerMinedBlockOres, etc.

This implies that I can many metrics for each spread event, so when player break a block, I can have one or more metrics, like this one above.
The event handler will get the metrics list and do something like that:

The problem:
I'm running this metrics in some Coroutine with launch() from kotlin. So lines like:


Evaluate different types of blocks. I think that happens because when I use .block (getBlock) out of the coroutine the event get the context has the blocks as being dirt yet, but in coroutine the block has been break already, so it gets the type air, because the block is now air. Something like that.
How do you guys handle that when using kotlin and have to use coroutines?