Bump 14.4

This commit is contained in:
xfl03 committed 2016-08-28 20:55:54 +08:00
1 parent 958023382d
commit 23f301c819
3 files changed
+29 -6

No files matched your search

@@ -1,8 +1,13 @@
package customskinloader.loader;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.codec.Charsets;
import org.apache.commons.codec.binary.Base64;
import com.google.common.collect.Iterables;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
@@ -10,6 +15,8 @@ import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload;
import com.mojang.util.UUIDTypeAdapter;
import customskinloader.CustomSkinLoader;
@@ -30,7 +37,7 @@ public class MojangAPILoader implements ProfileLoader.IProfileLoader {
CustomSkinLoader.logger.warning("Session Service Not Exist.");
return null;
}
Map<MinecraftProfileTexture.Type,MinecraftProfileTexture> map=defaultSessionService.getTextures(gameProfile, false);
Map<MinecraftProfileTexture.Type,MinecraftProfileTexture> map=getTextures(gameProfile);
if(!map.isEmpty()){
CustomSkinLoader.logger.info("Default profile will be used.");
return ModelManager0.toUserProfile(map);
@@ -42,7 +49,7 @@ public class MojangAPILoader implements ProfileLoader.IProfileLoader {
return null;
}
defaultSessionService.fillProfileProperties(newGameProfile, false);
map=defaultSessionService.getTextures(newGameProfile, false);
map=getTextures(newGameProfile);
if(!map.isEmpty()){
gameProfile.getProperties().putAll(newGameProfile.getProperties());
return ModelManager0.toUserProfile(map);
@@ -50,17 +57,33 @@ public class MojangAPILoader implements ProfileLoader.IProfileLoader {
CustomSkinLoader.logger.info("Profile not found.("+username+" doesn't have skin/cape.)");
return null;
}
public static GameProfile loadGameProfile(String username) throws JsonSyntaxException{
public static GameProfile loadGameProfile(String username) throws Exception{
//Doc (http://wiki.vg/Mojang_API#Username_-.3E_UUID_at_time)
String json0=HttpUtil0.readHttp("https://api.mojang.com/users/profiles/minecraft/"+username,null);
if(json0==null||json0.equals(""))
return null;
Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
GameProfile gameProfile=gson.fromJson(json0, GameProfile.class);
if(gameProfile.getId()==null)
return null;
return new GameProfile(gameProfile.getId(),gameProfile.getName());
}
public static Map<MinecraftProfileTexture.Type,MinecraftProfileTexture> getTextures(GameProfile gameProfile) throws Exception{
Property textureProperty=(Property)Iterables.getFirst(gameProfile.getProperties().get("textures"), null);
if (textureProperty==null)
return new HashMap();
String value=textureProperty.getValue();
if(value==null||value.equals(""))
return new HashMap();
String json=new String(Base64.decodeBase64(value),Charsets.UTF_8);
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class,new UUIDTypeAdapter()).create();
MinecraftTexturesPayload result=(MinecraftTexturesPayload)gson.fromJson(json,MinecraftTexturesPayload.class);
if (result==null||result.getTextures()==null)
return new HashMap();
return result.getTextures();
}
@Override
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
return true;
+1 -1
View File
@@ -19,7 +19,7 @@ public class HttpUtil0 {
public static String readHttp(String url,String userAgent){
HttpURLConnection c=null;
try {
CustomSkinLoader.logger.info("Try to read '"+url+(userAgent==null?" without user agent.":"' with user agent '"+userAgent+"'."));
CustomSkinLoader.logger.info("Try to read '"+url+(userAgent==null?"' without user agent.":"' with user agent '"+userAgent+"'."));
c=createConnection(url,userAgent);
int res = c.getResponseCode()/100;
if (res==4||res==5||c.getResponseCode()==HttpURLConnection.HTTP_NO_CONTENT) {
+1 -1
View File
@@ -3,4 +3,4 @@ group=customskinloader
version=14.4
dev_version=
#RELEASE: snapshot_version=
snapshot_version=20160828-1
snapshot_version=