You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: surf-api-core/surf-api-core-api/src/main/kotlin/dev/slne/surf/surfapi/core/api/service/PlayerLookupService.kt
+42-8Lines changed: 42 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -45,14 +45,18 @@ object PlayerLookupService {
45
45
*/
46
46
privateval nameToUuid =Caffeine.newBuilder()
47
47
.expireAfterWrite(15.minutes)
48
-
.asLoadingCache<String, UUID?> {
48
+
.asLoadingCache<String, UUID?> { name ->
49
49
try {
50
-
MinecraftApi.getUuid(it)
50
+
MojangApi.getUuid(name)
51
51
} catch (_:Exception) {
52
52
try {
53
-
MinetoolsApi.getUuid(it)
53
+
MinecraftServicesApi.getUuid(name)
54
54
} catch (_:Exception) {
55
-
null
55
+
try {
56
+
MinetoolsApi.getUuid(name)
57
+
} catch (_:Exception) {
58
+
null
59
+
}
56
60
}
57
61
}
58
62
}
@@ -63,15 +67,19 @@ object PlayerLookupService {
63
67
*/
64
68
privateval uuidToName =Caffeine.newBuilder()
65
69
.expireAfterWrite(15.minutes)
66
-
.asLoadingCache<UUID, String?> {
70
+
.asLoadingCache<UUID, String?> { uuid ->
67
71
try {
68
-
MinecraftApi.getUsername(it)
72
+
MojangApi.getUsername(uuid)
69
73
} catch (_:Exception) {
70
74
try {
71
-
MinetoolsApi.getUsername(it)
75
+
MinecraftServicesApi.getUsername(uuid)
76
+
} catch (_:Exception) {
77
+
try {
78
+
MinetoolsApi.getUsername(uuid)
72
79
} catch (_:Exception) {
73
80
null
74
81
}
82
+
}
75
83
}
76
84
}
77
85
@@ -92,7 +100,7 @@ object PlayerLookupService {
92
100
/**
93
101
* API interaction with Mojang's official endpoints.
0 commit comments