Skip to content

Commit 080c6e3

Browse files
author
TheProgramSrc
committed
Changelog:
* Code Improvements * SkinTexture Fixes
1 parent b9a4b11 commit 080c6e3

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>xyz.theprogramsrc</groupId>
88
<artifactId>SuperCoreAPI</artifactId>
9-
<version>4.2.0-BETA1</version>
9+
<version>4.2.0-BETA2</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SuperCoreAPI</name>

src/main/java/xyz/theprogramsrc/supercoreapi/spigot/utils/skintexture/SkinTexture.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@
55
import com.mojang.authlib.GameProfile;
66
import com.mojang.authlib.properties.Property;
77
import org.apache.commons.codec.binary.Base64;
8-
import org.apache.commons.io.IOUtils;
98
import org.bukkit.entity.Player;
109
import xyz.theprogramsrc.supercoreapi.global.utils.Utils;
1110

12-
import java.io.IOException;
13-
import java.net.URL;
14-
import java.nio.charset.Charset;
1511
import java.util.UUID;
1612

1713
@SuppressWarnings("ALL")
@@ -62,10 +58,10 @@ public static SkinTexture fromPlayer(Player player) {
6258
* @return the skin
6359
*/
6460
public static SkinTexture fromMojang(String playerName) {
65-
String response = getResponse("https://api.mojang.com/users/profiles/minecraft/" + playerName);
61+
String response = Utils.readWithInputStream("https://api.mojang.com/users/profiles/minecraft/" + playerName);
6662
if(response == null)
6763
return null;
68-
String uuid = (new JsonParser()).parse(getResponse(response)).getAsJsonObject().get("id").getAsString();
64+
String uuid = (new JsonParser()).parse(Utils.readWithInputStream(response)).getAsJsonObject().get("id").getAsString();
6965
String fullUUID = Utils.uuidToFullUUID(uuid);
7066
return fromMojang(UUID.fromString(fullUUID));
7167
}
@@ -76,7 +72,7 @@ public static SkinTexture fromMojang(String playerName) {
7672
* @return the skin
7773
*/
7874
public static SkinTexture fromMojang(UUID uuid) {
79-
String response = getResponse("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid.toString().replace("-", "") + "?unsigned=false");
75+
String response = Utils.readWithInputStream("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid.toString().replace("-", "") + "?unsigned=false");
8076
if(response == null)
8177
return null;
8278
JsonObject properties = (new JsonParser()).parse(response).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject();
@@ -93,16 +89,6 @@ public static SkinTexture fromURL(String url){
9389
return new SkinTexture(url);
9490
}
9591

96-
private static String getResponse(String stringUrl) {
97-
try {
98-
URL url = new URL(stringUrl);
99-
return IOUtils.toString(url.openStream(), Charset.forName("UTF-8"));
100-
} catch (IOException e) {
101-
e.printStackTrace();
102-
return null;
103-
}
104-
}
105-
10692
private static String base64ToUrl(String base64) {
10793
String content = new String(Base64.decodeBase64(base64.getBytes()));
10894
JsonObject json = new JsonParser().parse(content).getAsJsonObject().get("textures").getAsJsonObject().get("SKIN").getAsJsonObject();

0 commit comments

Comments
 (0)