mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-11-14 19:34:58 -05:00
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
This commit is contained in:
parent
86903ecd73
commit
05a699d1ba
2 changed files with 12 additions and 6 deletions
|
@ -14,7 +14,6 @@ import java.security.spec.X509EncodedKeySpec;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -371,7 +370,7 @@ public class GameProfile {
|
||||||
* The model used for a profile texture.
|
* The model used for a profile texture.
|
||||||
*/
|
*/
|
||||||
public enum TextureModel {
|
public enum TextureModel {
|
||||||
NORMAL,
|
WIDE,
|
||||||
SLIM;
|
SLIM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,7 +389,7 @@ public class GameProfile {
|
||||||
*/
|
*/
|
||||||
public Texture(String url, Map<String, String> metadata) {
|
public Texture(String url, Map<String, String> metadata) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.metadata = new HashMap<>(metadata);
|
this.metadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -408,6 +407,10 @@ public class GameProfile {
|
||||||
* @return The metadata value corresponding to the given key.
|
* @return The metadata value corresponding to the given key.
|
||||||
*/
|
*/
|
||||||
public String getMetadata(String key) {
|
public String getMetadata(String key) {
|
||||||
|
if (this.metadata == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return this.metadata.get(key);
|
return this.metadata.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,7 +421,7 @@ public class GameProfile {
|
||||||
*/
|
*/
|
||||||
public TextureModel getModel() {
|
public TextureModel getModel() {
|
||||||
String model = this.getMetadata("model");
|
String model = this.getMetadata("model");
|
||||||
return model != null && model.equals("slim") ? TextureModel.SLIM : TextureModel.NORMAL;
|
return model != null && model.equals("slim") ? TextureModel.SLIM : TextureModel.WIDE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -36,8 +36,11 @@ public class HTTPUtils {
|
||||||
throw new IllegalArgumentException("URI cannot be null.");
|
throw new IllegalArgumentException("URI cannot be null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpResponse response = createHttpClient(proxy).execute(input == null ? new HttpRequest("GET", uri.toURL()) :
|
HttpResponse response = createHttpClient(proxy)
|
||||||
new HttpContentRequest("POST", uri.toURL()).setContent(HttpContent.string(GSON.toJson(input))));
|
.execute(input == null ? new HttpRequest("GET", uri.toURL()) :
|
||||||
|
new HttpContentRequest("POST", uri.toURL())
|
||||||
|
.setContent(HttpContent.string(GSON.toJson(input)))
|
||||||
|
.setHeader(Headers.CONTENT_TYPE, ContentTypes.APPLICATION_JSON.toString()));
|
||||||
|
|
||||||
if (responseType == null) {
|
if (responseType == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue