blob: 79068cc76b93def65dee4337b2053f89f045a314 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
package moe.nea.ledger
import com.mojang.util.UUIDTypeAdapter
import net.minecraft.client.Minecraft
import java.util.UUID
object MCUUIDUtil {
fun parseDashlessUuid(string: String) = UUIDTypeAdapter.fromString(string)
val NIL_UUID = UUID(0L, 0L)
fun getPlayerUUID(): UUID {
val currentUUID = Minecraft.getMinecraft().thePlayer?.uniqueID
?: Minecraft.getMinecraft().session?.playerID?.let(::parseDashlessUuid)
?: lastKnownUUID
lastKnownUUID = currentUUID
return currentUUID
}
private var lastKnownUUID: UUID = NIL_UUID
}
|