本文整理汇总了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;
}
示例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;
}
示例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();
}
}
}