當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。