Skip to content

Commit 05a699d

Browse files
Fix edge-case where Texture#toString has a NullPointer, fix join requests (#838)
* Fix edge-case where Texture#toString has a NullPointer because gson set a null metadata Also changes NORMAL name to WIDE since that's the accurate name. * Fix join requests Fixes #837
1 parent 86903ec commit 05a699d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

protocol/src/main/java/org/geysermc/mcprotocollib/auth/GameProfile.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import java.util.ArrayList;
1515
import java.util.Base64;
1616
import java.util.Collections;
17-
import java.util.HashMap;
1817
import java.util.List;
1918
import java.util.Map;
2019
import java.util.Objects;
@@ -371,7 +370,7 @@ public enum TextureType {
371370
* The model used for a profile texture.
372371
*/
373372
public enum TextureModel {
374-
NORMAL,
373+
WIDE,
375374
SLIM;
376375
}
377376

@@ -390,7 +389,7 @@ public static class Texture {
390389
*/
391390
public Texture(String url, Map<String, String> metadata) {
392391
this.url = url;
393-
this.metadata = new HashMap<>(metadata);
392+
this.metadata = metadata;
394393
}
395394

396395
/**
@@ -408,6 +407,10 @@ public String getURL() {
408407
* @return The metadata value corresponding to the given key.
409408
*/
410409
public String getMetadata(String key) {
410+
if (this.metadata == null) {
411+
return null;
412+
}
413+
411414
return this.metadata.get(key);
412415
}
413416

@@ -418,7 +421,7 @@ public String getMetadata(String key) {
418421
*/
419422
public TextureModel getModel() {
420423
String model = this.getMetadata("model");
421-
return model != null && model.equals("slim") ? TextureModel.SLIM : TextureModel.NORMAL;
424+
return model != null && model.equals("slim") ? TextureModel.SLIM : TextureModel.WIDE;
422425
}
423426

424427
/**

protocol/src/main/java/org/geysermc/mcprotocollib/auth/util/HTTPUtils.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ public static <T> T makeRequest(@Nullable ProxyInfo proxy, URI uri, Object input
3636
throw new IllegalArgumentException("URI cannot be null.");
3737
}
3838

39-
HttpResponse response = createHttpClient(proxy).execute(input == null ? new HttpRequest("GET", uri.toURL()) :
40-
new HttpContentRequest("POST", uri.toURL()).setContent(HttpContent.string(GSON.toJson(input))));
39+
HttpResponse response = createHttpClient(proxy)
40+
.execute(input == null ? new HttpRequest("GET", uri.toURL()) :
41+
new HttpContentRequest("POST", uri.toURL())
42+
.setContent(HttpContent.string(GSON.toJson(input)))
43+
.setHeader(Headers.CONTENT_TYPE, ContentTypes.APPLICATION_JSON.toString()));
4144

4245
if (responseType == null) {
4346
return null;

0 commit comments

Comments
 (0)