@@ -37,6 +37,24 @@ public final class SkinManager {
37
37
private static final Gson GSON = new Gson ();
38
38
private static final ExecutorService executorService = Executors
39
39
.newCachedThreadPool ();
40
+ private static final URI SESSION_HOST =
41
+ URI .create (
42
+ System .getProperty (
43
+ "minecraft.api.session.host" ,
44
+ "https://sessionserver.mojang.com"
45
+ )
46
+ );
47
+ private static final URI PROFILE_ENDPOINT = URI .create (
48
+ // 1.21.9+
49
+ System .getProperty (
50
+ "minecraft.api.profiles.host" ,
51
+ System .getProperty (
52
+ // 1.21.9-
53
+ "minecraft.api.session.host" ,
54
+ "https://api.mojang.com"
55
+ )
56
+ )
57
+ );
40
58
41
59
public static void resetSkin (final Player player , final boolean shouldSendMessage ) {
42
60
executorService .submit (() -> {
@@ -128,8 +146,10 @@ public static CompletableFuture<SkinData> getSkinData(final String playerName) {
128
146
public static CompletableFuture <SkinData > getSkinData (final UUID uuid ) {
129
147
return CompletableFuture .supplyAsync (() -> {
130
148
final SkinResponse response = sendRequestForJSON (
131
- "https://sessionserver.mojang.com/session/minecraft/profile/"
132
- + uuid + "?unsigned=false" , SkinResponse .class );
149
+ SESSION_HOST ,
150
+ "/session/minecraft/profile/" + uuid + "?unsigned=false" ,
151
+ SkinResponse .class
152
+ );
133
153
134
154
final List <ProfileProperty > properties = response .properties ();
135
155
@@ -145,10 +165,10 @@ public static CompletableFuture<SkinData> getSkinData(final UUID uuid) {
145
165
}, executorService );
146
166
}
147
167
148
- private static <T > T sendRequestForJSON (String url , Class <T > clazz ) {
168
+ private static <T > T sendRequestForJSON (URI uri , String endpoint , Class <T > clazz ) {
149
169
final HttpRequest request = HttpRequest .newBuilder ()
150
170
.GET ()
151
- .uri (URI . create ( url ))
171
+ .uri (uri . resolve ( endpoint ))
152
172
.build ();
153
173
154
174
final HttpResponse <String > response ;
@@ -164,9 +184,11 @@ private static <T> T sendRequestForJSON(String url, Class<T> clazz) {
164
184
165
185
private static CompletableFuture <UUID > getUUID (final String playerName ) {
166
186
return CompletableFuture .supplyAsync (() -> {
167
- final ProfileResponse parsedResponse = sendRequestForJSON
168
- ("https://api.mojang.com/users/profiles/minecraft/" + playerName ,
169
- ProfileResponse .class );
187
+ final ProfileResponse parsedResponse = sendRequestForJSON (
188
+ PROFILE_ENDPOINT ,
189
+ "/users/profiles/minecraft/" + playerName ,
190
+ ProfileResponse .class
191
+ );
170
192
171
193
final String dashedUuid = parsedResponse
172
194
.id ()
0 commit comments