mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-20 21:32:16 +00:00
Remove Tab
This commit is contained in:
1 parent
4449ccdd45
commit
c40bb38e20
38 files changed
+2331
-2317
No files matched your search
@@ -16,106 +16,106 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
* @since 13.1
|
||||
*/
|
||||
public class ModelManager0 {
|
||||
public static enum Model{
|
||||
SKIN_DEFAULT,
|
||||
SKIN_SLIM,
|
||||
CAPE,
|
||||
ELYTRA
|
||||
}
|
||||
private static HashMap<String,Model> models=new HashMap<String,Model>();
|
||||
private static Type typeElytra=null;
|
||||
static{
|
||||
for(Type type:Type.values()){
|
||||
if(type.ordinal()==2)//ELYTRA
|
||||
typeElytra=type;
|
||||
}
|
||||
models.put("default", Model.SKIN_DEFAULT);
|
||||
models.put("slim", Model.SKIN_SLIM);
|
||||
models.put("cape", Model.CAPE);
|
||||
if(typeElytra!=null)
|
||||
models.put("elytra", Model.ELYTRA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get enum for the model.
|
||||
* @param model - string model
|
||||
* @since 14.5
|
||||
*/
|
||||
public static Model getEnumModel(String model){
|
||||
return models.get(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if model is skin.
|
||||
* @since 14.5
|
||||
* */
|
||||
public static boolean isSkin(Model model){
|
||||
return model==Model.SKIN_DEFAULT||model==Model.SKIN_SLIM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if elytra is supported.
|
||||
* @since 14.5
|
||||
*/
|
||||
public static boolean isElytraSupported(){
|
||||
return typeElytra!=null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse hashMapProfile to UserProfile
|
||||
* @param profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>)
|
||||
* @return profile - UserProfile instance
|
||||
* @since 13.1
|
||||
*/
|
||||
public static UserProfile toUserProfile(Map profile){
|
||||
UserProfile userProfile=new UserProfile();
|
||||
if(profile==null)
|
||||
return userProfile;
|
||||
MinecraftProfileTexture skin=(MinecraftProfileTexture)profile.get(Type.SKIN);
|
||||
userProfile.skinUrl= skin==null?null:skin.getUrl();//Avoid NullPointerException
|
||||
userProfile.model= skin==null?null:skin.getMetadata("model");
|
||||
if(StringUtils.isEmpty(userProfile.model))
|
||||
userProfile.model="default";
|
||||
|
||||
MinecraftProfileTexture cape=(MinecraftProfileTexture)profile.get(Type.CAPE);
|
||||
userProfile.capeUrl= cape==null?null:cape.getUrl();
|
||||
return userProfile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse UserProfile to hashMapProfile
|
||||
* @param profile - UserProfile instance
|
||||
* @return profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>)
|
||||
* @since 13.1
|
||||
*/
|
||||
public static Map fromUserProfile(UserProfile profile){
|
||||
Map map=Maps.newHashMap();
|
||||
if(profile==null)
|
||||
return map;
|
||||
if(profile.skinUrl!=null){
|
||||
Map metadata=null;
|
||||
if(profile.model!=null&&profile.model.equals("slim")){
|
||||
metadata = Maps.newHashMap();
|
||||
metadata.put("model", "slim");
|
||||
}
|
||||
map.put(Type.SKIN, getProfileTexture(profile.skinUrl,metadata));
|
||||
}
|
||||
if(profile.capeUrl!=null)
|
||||
map.put(Type.CAPE, getProfileTexture(profile.capeUrl,null));
|
||||
if(typeElytra!=null && profile.elytraUrl!=null)
|
||||
map.put(typeElytra, getProfileTexture(profile.elytraUrl,null));
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse url to MinecraftProfileTexture
|
||||
*
|
||||
* @param url - textureUrl
|
||||
* metadata - metadata
|
||||
* @return MinecraftProfileTexture
|
||||
* @since 14.5
|
||||
*/
|
||||
public static MinecraftProfileTexture getProfileTexture(String url,Map metadata){
|
||||
return new MinecraftProfileTexture(url,metadata);
|
||||
}
|
||||
public static enum Model{
|
||||
SKIN_DEFAULT,
|
||||
SKIN_SLIM,
|
||||
CAPE,
|
||||
ELYTRA
|
||||
}
|
||||
private static HashMap<String,Model> models=new HashMap<String,Model>();
|
||||
private static Type typeElytra=null;
|
||||
static{
|
||||
for(Type type:Type.values()){
|
||||
if(type.ordinal()==2)//ELYTRA
|
||||
typeElytra=type;
|
||||
}
|
||||
models.put("default", Model.SKIN_DEFAULT);
|
||||
models.put("slim", Model.SKIN_SLIM);
|
||||
models.put("cape", Model.CAPE);
|
||||
if(typeElytra!=null)
|
||||
models.put("elytra", Model.ELYTRA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get enum for the model.
|
||||
* @param model - string model
|
||||
* @since 14.5
|
||||
*/
|
||||
public static Model getEnumModel(String model){
|
||||
return models.get(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if model is skin.
|
||||
* @since 14.5
|
||||
* */
|
||||
public static boolean isSkin(Model model){
|
||||
return model==Model.SKIN_DEFAULT||model==Model.SKIN_SLIM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if elytra is supported.
|
||||
* @since 14.5
|
||||
*/
|
||||
public static boolean isElytraSupported(){
|
||||
return typeElytra!=null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse hashMapProfile to UserProfile
|
||||
* @param profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>)
|
||||
* @return profile - UserProfile instance
|
||||
* @since 13.1
|
||||
*/
|
||||
public static UserProfile toUserProfile(Map profile){
|
||||
UserProfile userProfile=new UserProfile();
|
||||
if(profile==null)
|
||||
return userProfile;
|
||||
MinecraftProfileTexture skin=(MinecraftProfileTexture)profile.get(Type.SKIN);
|
||||
userProfile.skinUrl= skin==null?null:skin.getUrl();//Avoid NullPointerException
|
||||
userProfile.model= skin==null?null:skin.getMetadata("model");
|
||||
if(StringUtils.isEmpty(userProfile.model))
|
||||
userProfile.model="default";
|
||||
|
||||
MinecraftProfileTexture cape=(MinecraftProfileTexture)profile.get(Type.CAPE);
|
||||
userProfile.capeUrl= cape==null?null:cape.getUrl();
|
||||
return userProfile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse UserProfile to hashMapProfile
|
||||
* @param profile - UserProfile instance
|
||||
* @return profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>)
|
||||
* @since 13.1
|
||||
*/
|
||||
public static Map fromUserProfile(UserProfile profile){
|
||||
Map map=Maps.newHashMap();
|
||||
if(profile==null)
|
||||
return map;
|
||||
if(profile.skinUrl!=null){
|
||||
Map metadata=null;
|
||||
if(profile.model!=null&&profile.model.equals("slim")){
|
||||
metadata = Maps.newHashMap();
|
||||
metadata.put("model", "slim");
|
||||
}
|
||||
map.put(Type.SKIN, getProfileTexture(profile.skinUrl,metadata));
|
||||
}
|
||||
if(profile.capeUrl!=null)
|
||||
map.put(Type.CAPE, getProfileTexture(profile.capeUrl,null));
|
||||
if(typeElytra!=null && profile.elytraUrl!=null)
|
||||
map.put(typeElytra, getProfileTexture(profile.elytraUrl,null));
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse url to MinecraftProfileTexture
|
||||
*
|
||||
* @param url - textureUrl
|
||||
* metadata - metadata
|
||||
* @return MinecraftProfileTexture
|
||||
* @since 14.5
|
||||
*/
|
||||
public static MinecraftProfileTexture getProfileTexture(String url,Map metadata){
|
||||
return new MinecraftProfileTexture(url,metadata);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user