当前位置: 首页>>代码示例>>Java>>正文


Java GameProfile.getProperties方法代码示例

本文整理汇总了Java中com.mojang.authlib.GameProfile.getProperties方法的典型用法代码示例。如果您正苦于以下问题:Java GameProfile.getProperties方法的具体用法?Java GameProfile.getProperties怎么用?Java GameProfile.getProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mojang.authlib.GameProfile的用法示例。


在下文中一共展示了GameProfile.getProperties方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHeadCustomizedGameProfile

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
/**
 * Create a {@link GameProfile} instance with a base64 encoded texture
 *
 * @param texture Base64 texture
 *
 * @return A custom {@link GameProfile} instance with your texture
 */
public static GameProfile getHeadCustomizedGameProfile(String texture)
{
    GameProfile profile = new GameProfile(UUID.randomUUID(), null);
    PropertyMap propertyMap = profile.getProperties();

    if (propertyMap == null)
        throw new IllegalStateException("Profile doesn't contain a property map");

    byte[] encodedData = texture.getBytes();
    propertyMap.put("textures", new Property("textures", new String(encodedData)));

    return profile;
}
 
开发者ID:SamaGames,项目名称:SamaGamesAPI,代码行数:21,代码来源:ItemUtils.java

示例2: changeSkin

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
public static GameProfile changeSkin(String url) {
    GameProfile profile = new GameProfile(UUID.randomUUID(), null);
    PropertyMap propertyMap = profile.getProperties();

    if (propertyMap == null) {
        throw new IllegalStateException("Profile doesn't contain a property map");
    }

    byte[] encodedData = BASE64.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
    propertyMap.put("textures", new Property("textures", new String(encodedData)));

    return profile;
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:14,代码来源:SkinChangeUtil.java

示例3: setSkin

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
public static void setSkin(VPPlayer player, String name){
	if((player == null) || (!player.isOnline())) {
		return;
	}
	GameProfile gp = getProfile(player.getPlayer());
	if(gp != null){
		PropertyMap pro = gp.getProperties();
		try {
			HttpURLConnection httpConnection = (HttpURLConnection)new URL("https://use.gameapis.net/mc/player/profile/"+name).openConnection();
		    httpConnection.setConnectTimeout(3000);
		    httpConnection.setReadTimeout(6000);
		    httpConnection.setRequestProperty("Content-Type", "application/json");
		    httpConnection.setRequestProperty("User-Agent", "VanillPlus-Bukkit-Plugin");
		    BufferedReader reader = new BufferedReader(new InputStreamReader(httpConnection.getInputStream()));
		    String line = "";
		    while (true){
		    	String l = reader.readLine();
		    	if(l!=null)
		    		line += l;
		    	else
		    		break;
		    }
		    if (!line.isEmpty() && (!line.startsWith("{\"error\""))){
		    	JSONObject json =  (JSONObject) ((JSONArray) ((JSONObject) new JSONParser().parse(line)).get("properties")).get(0);
		    	pro.clear();
		    	pro.put("textures", new Property("textures", json.get("value").toString(), json.get("signature").toString()));
		    }
			/*
			String uuid = uuidLink.get(name);
			if(uuid == null){
				HttpURLConnection httpConnection = (HttpURLConnection)new URL("https://api.mojang.com/users/profiles/minecraft/"+name).openConnection();
			    httpConnection.setConnectTimeout(3000);
			    httpConnection.setReadTimeout(6000);
			    httpConnection.setRequestProperty("Content-Type", "application/json");
			    httpConnection.setRequestProperty("User-Agent", "ChangeSkin-Bukkit-Plugin");
			    BufferedReader reader = new BufferedReader(new InputStreamReader(httpConnection.getInputStream()));
			    String line = reader.readLine();
			    if ((line != null) && (!line.equals("null"))){
			    	uuid = (String)((JSONObject) new JSONParser().parse(line)).get("id");
			    	if( uuid == null) return;
			    	else uuidLink.put(name, uuid);
			    }else
			    	return;
			}
			LiteEntry<String, String>texture = textureLink.get(uuid);
			if(texture == null) {
				HttpURLConnection httpConnection = (HttpURLConnection)new URL("https://sessionserver.mojang.com/session/minecraft/profile/"+uuid+"?unsigned=false").openConnection();
			    httpConnection.setConnectTimeout(3000);
			    httpConnection.setReadTimeout(6000);
			    httpConnection.setRequestProperty("Content-Type", "application/json");
			    httpConnection.setRequestProperty("User-Agent", "ChangeSkin-Bukkit-Plugin");
			    BufferedReader reader = new BufferedReader(new InputStreamReader(httpConnection.getInputStream()));
			    String line = reader.readLine();
			    if ((line != null) && (!line.equals("null"))){
			    	JSONObject json =  (JSONObject) ((JSONArray) ((JSONObject) new JSONParser().parse(line)).get("properties")).get(0);
			    	pro.clear();
			    	textureLink.put(uuid, new LiteEntry<String, String>(json.get("value").toString(), json.get("signature").toString()));
			    	pro.put("textures", new Property("textures", json.get("value").toString(), json.get("signature").toString()));
			    }
			}
			*/
		} catch (ParseException | IOException e) {
			e.printStackTrace();
		}
	}	
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:67,代码来源:CraftPlayerUtils.java


注:本文中的com.mojang.authlib.GameProfile.getProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。