Skip to content

Commit 8f16579

Browse files
fix(CosmeticService): possible NPE (if player unloaded) (#7592)
1 parent a7864cf commit 8f16579

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/kotlin/net/ccbluex/liquidbounce/features/cosmetic/CosmeticService.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ import net.ccbluex.liquidbounce.event.suspendHandler
3333
import net.ccbluex.liquidbounce.utils.client.Chronometer
3434
import net.ccbluex.liquidbounce.utils.client.logger
3535
import net.ccbluex.liquidbounce.utils.client.mc
36-
import net.ccbluex.liquidbounce.utils.client.player
3736
import net.ccbluex.liquidbounce.utils.kotlin.toMD5
38-
import java.util.*
37+
import java.util.UUID
3938

4039
/**
4140
* A more reliable, safer and stress reduced cosmetics service
@@ -57,7 +56,7 @@ object CosmeticService : EventListener, Configurable("Cosmetics") {
5756
* function frequently based on the REFRESH_DELAY.
5857
*/
5958
internal var carriers = emptySet<String>()
60-
internal var carriersCosmetics = hashMapOf<UUID, Set<Cosmetic>>()
59+
internal val carriersCosmetics = hashMapOf<UUID, Set<Cosmetic>>()
6160

6261
private val lastUpdate = Chronometer()
6362
private var task: Job? = null
@@ -97,7 +96,7 @@ object CosmeticService : EventListener, Configurable("Cosmetics") {
9796
val clientAccount = ClientAccountManager.clientAccount
9897

9998
// Check if the client account is available and the requested UUID is the same as the session UUID
100-
if ((uuid == mc.user.profileId || uuid == player.uuid) && clientAccount != ClientAccount.EMPTY_ACCOUNT) {
99+
if ((uuid == mc.user.profileId || uuid == mc.player?.uuid) && clientAccount != ClientAccount.EMPTY_ACCOUNT) {
101100
clientAccount.cosmetics?.let { cosmetics ->
102101
done(cosmetics.find { cosmetic -> cosmetic.category == category } ?: return)
103102
return
@@ -150,7 +149,7 @@ object CosmeticService : EventListener, Configurable("Cosmetics") {
150149
// Check if the client account is available and the requested UUID is the same as the session UUID
151150
val clientAccount = ClientAccountManager.clientAccount
152151

153-
if ((uuid == mc.user.profileId || uuid == player.uuid) && clientAccount != ClientAccount.EMPTY_ACCOUNT) {
152+
if ((uuid == mc.user.profileId || uuid == mc.player?.uuid) && clientAccount != ClientAccount.EMPTY_ACCOUNT) {
154153
clientAccount.cosmetics?.let { cosmetics ->
155154
return cosmetics.find { cosmetic -> cosmetic.category == category }
156155
}

0 commit comments

Comments
 (0)