當前位置: 首頁>>代碼示例>>Java>>正文


Java Property類代碼示例

本文整理匯總了Java中com.mojang.authlib.properties.Property的典型用法代碼示例。如果您正苦於以下問題:Java Property類的具體用法?Java Property怎麽用?Java Property使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Property類屬於com.mojang.authlib.properties包,在下文中一共展示了Property類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getSkull

import com.mojang.authlib.properties.Property; //導入依賴的package包/類
public static ItemStack getSkull(String url) {
    ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    if (url.isEmpty())
        return head;
    SkullMeta headMeta = (SkullMeta) head.getItemMeta();
    GameProfile profile = new GameProfile(UUID.randomUUID(), null);
    byte[] encodedData = Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
    profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
    Field profileField = null;
    try {
        profileField = headMeta.getClass().getDeclaredField("profile");
        profileField.setAccessible(true);
        profileField.set(headMeta, profile);
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
        e1.printStackTrace();
    }
    head.setItemMeta(headMeta);
    return head;
}
 
開發者ID:edasaki,項目名稱:ZentrelaCore,代碼行數:20,代碼來源:RHead.java

示例2: getProfile

import com.mojang.authlib.properties.Property; //導入依賴的package包/類
public static GameProfile getProfile(UUID uuid, String name, String skinUrl, String capeUrl)
{
    GameProfile profile = new GameProfile(uuid, name);
    boolean cape = capeUrl != null && !capeUrl.isEmpty();

    List<Object> args = new ArrayList<Object>();
    args.add(System.currentTimeMillis());
    args.add(UUIDTypeAdapter.fromUUID(uuid));
    args.add(name);
    args.add(skinUrl);
    if (cape)
    {
        args.add(capeUrl);
    }

    profile.getProperties().put("textures", new Property("textures", Base64Coder.encodeString(String.format(cape ? JSON_CAPE : JSON_SKIN, args.toArray(new Object[args.size()])))));
    return profile;
}
 
開發者ID:SamaGames,項目名稱:SamaGamesAPI,代碼行數:19,代碼來源:GameProfileBuilder.java

示例3: getSkinUrl

import com.mojang.authlib.properties.Property; //導入依賴的package包/類
public String getSkinUrl(GameProfile prof) throws ParseException {
    Collection<Property> ps = prof.getProperties().get("textures");

    if (ps == null || ps.isEmpty()) {
        return null;
    } else {
        Property p = Iterators.getLast(ps.iterator());

        JSONObject obj = (JSONObject) new JSONParser().parse(
                new String(Base64.getDecoder().decode(p.getValue())));

        obj = ((JSONObject) obj.get("textures"));
        obj = ((JSONObject) obj.get("SKIN"));
        return (String) obj.get("url");
    }
}
 
開發者ID:devcexx,項目名稱:libtrails,代碼行數:17,代碼來源:SkinDownloader.java

示例4: updateGameprofile

import com.mojang.authlib.properties.Property; //導入依賴的package包/類
public GameProfile updateGameprofile(GameProfile input) {
    if (input != null && !StringUtils.isNullOrEmpty(input.getName())) {
        if (input.isComplete() && input.getProperties().containsKey("textures")) {
            return input;
        } else if (profileCache != null && sessionService != null) {
            GameProfile gameprofile = profileCache.getGameProfileForUsername(input.getName());

            if (gameprofile == null) {
                return input;
            } else {
                Property property = (Property) Iterables.getFirst(gameprofile.getProperties().get("textures"), (Object) null);

                if (property == null) {
                    gameprofile = sessionService.fillProfileProperties(gameprofile, true);
                }

                return gameprofile;
            }
        } else {
            return input;
        }
    } else {
        return input;
    }
}
 
開發者ID:CreeperShift,項目名稱:WirelessCharger,代碼行數:26,代碼來源:TilePersonalCharger.java

示例5: getProfile

import com.mojang.authlib.properties.Property; //導入依賴的package包/類
/**
 * Builds a GameProfile for the specified args
 *
 * @param name    The name
 * @param skinUrl Url from the skin image
 * @param capeUrl Url from the cape image
 * @return A GameProfile built from the arguments
 * @see GameProfile
 */
public static GameProfile getProfile(String name, String skinUrl, String capeUrl) {
    UUID id = UUID.randomUUID();
    GameProfile profile = new GameProfile(id, name);
    boolean cape = capeUrl != null && !capeUrl.isEmpty();

    List<Object> args = new ArrayList<>();
    args.add(System.currentTimeMillis());
    args.add(UUIDTypeAdapter.fromUUID(id));
    args.add(name);
    args.add(skinUrl);
    if (cape) args.add(capeUrl);

    profile.getProperties().clear();
    profile.getProperties().put("textures", new Property("textures", Base64Coder.encodeString(String.format(cape ? JSON_CAPE : JSON_SKIN, args.toArray(new Object[args.size()])))));
    return profile;
}
 
開發者ID:AlphaHelixDev,項目名稱:AlphaLibary,代碼行數:26,代碼來源:GameProfileBuilder.java

示例6: PlayerSkin

import com.mojang.authlib.properties.Property; //導入依賴的package包/類
public PlayerSkin(UUID uuid){
	profile = new GameProfile(uuid, ProfileUtil.getUsername(uuid));
	PropertyMap properties = ProfileUtil.getProperties(uuid);
	if(properties !=null){
		Property textureProperty = Iterables.getFirst(properties.get("textures"), null);
		Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = null;
		MinecraftTexturesPayload result;
        try {
            String json = new String(Base64.decodeBase64(textureProperty.getValue()), Charsets.UTF_8);
            result = gson.fromJson(json, MinecraftTexturesPayload.class);
            map = result.getTextures();
        } catch (JsonParseException e) {
            ModLogger.error("Could not decode textures payload", e);
            map = new HashMap<MinecraftProfileTexture.Type, MinecraftProfileTexture>();
        }
        for(Type type : map.keySet()){
        	Minecraft.getMinecraft().getSkinManager().loadSkin(map.get(type), type, this);
        }
	}
	
	//playerTextures = downloadPlayerTextures(profile);
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:23,代碼來源:DownloadedTextures.java

示例7: getSkullFromURL

import com.mojang.authlib.properties.Property; //導入依賴的package包/類
public static ItemStack getSkullFromURL(String url, String name)
		throws Exception {
	ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
	SkullMeta sm = (SkullMeta) skull.getItemMeta();
	sm.setOwner("NacOJerk");
	skull.setItemMeta(sm);
	url = Base64Coder.encodeString("{textures:{SKIN:{url:\"" + url
			+ "\"}}}");
	GameProfile gp = new GameProfile(UUID.randomUUID(), name);
	gp.getProperties().put("textures", new Property("textures", url));
	Object isskull = asNMSCopy(skull);
	Object nbt = getNMS("NBTTagCompound").getConstructor().newInstance();
	Method serialize = getNMS("GameProfileSerializer").getMethod(
			"serialize", getNMS("NBTTagCompound"), GameProfile.class);
	serialize.invoke(null, nbt, gp);
	Object nbtr = isskull.getClass().getMethod("getTag").invoke(isskull);
	nbtr.getClass().getMethod("set", String.class, getNMS("NBTBase"))
			.invoke(nbtr, "SkullOwner", nbt);
	isskull.getClass().getMethod("setTag", getNMS("NBTTagCompound"))
			.invoke(isskull, nbtr);
	skull = asBukkitCopy(isskull);
	return skull;
}
 
開發者ID:NacOJerk,項目名稱:Pokecraft,代碼行數:24,代碼來源:ItemStackUtils.java

示例8: setSkullTexture

import com.mojang.authlib.properties.Property; //導入依賴的package包/類
@Override
public SkullMeta setSkullTexture(SkullMeta meta, String skinUrl) {
    if (meta == null) {
        return meta;
    }

    GameProfile profile = new GameProfile(UUID.randomUUID(), null);
    profile.getProperties().put("textures", new Property("textures", new String(Utils.getSkullTexture(skinUrl))));

    try {
        Field profileField = meta.getClass().getDeclaredField("profile");
        profileField.setAccessible(true);
        profileField.set(meta, profile);

    } catch (NoSuchFieldException | IllegalAccessException e) {
        e.printStackTrace();
    }
    return meta;
}
 
開發者ID:GameBoxx,項目名稱:GameBoxx,代碼行數:20,代碼來源:ItemUtils_V1_10_R1.java

示例9: getSkull

import com.mojang.authlib.properties.Property; //導入依賴的package包/類
/**
 * Load skin into a skull item stack
 *
 * @param uri
 *            the url, eg:
 *            "http://textures.minecraft.net/texture/e58c3ff46ac3fa1a408b24e5b99913cb4c116d8ad7b259186c9fd529464a71c"
 * @return the item stack
 * @throws NoSuchFieldException
 *             bad version (not 1.9.2-4)
 * @throws SecurityException
 *             LET ME DO STUFF
 * @throws IllegalArgumentException
 *             shouldnt happen
 * @throws IllegalAccessException
 *             not good
 */
public static ItemStack getSkull(String uri) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
{
	ItemStack localItemStack = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
	ItemMeta localItemMeta = localItemStack.getItemMeta();
	localItemMeta.setDisplayName("skull");
	GameProfile localGameProfile = new GameProfile(UUID.randomUUID(), null);
	byte[] arrayOfByte = Base64.encodeBytesToBytes(String.format("{textures:{SKIN:{url:\"%s\"}}}", new Object[] {uri}).getBytes());
	localGameProfile.getProperties().put("textures", new Property("textures", new String(arrayOfByte)));
	Field localField = null;
	localField = localItemMeta.getClass().getDeclaredField("profile");
	localField.setAccessible(true);
	localField.set(localItemMeta, localGameProfile);
	localItemStack.setItemMeta(localItemMeta);

	return localItemStack;
}
 
開發者ID:PhantomAPI,項目名稱:Phantom,代碼行數:33,代碼來源:Items.java

示例10: getOfflineProfile

import com.mojang.authlib.properties.Property; //導入依賴的package包/類
/**
 * @author jamierocks - 7th May 2016
 * @reason Overwrite to enable BungeeCord support.
 */
@Overwrite
protected GameProfile getOfflineProfile(GameProfile original) {
    final UUID uuid;
    if (((IMixinNetworkManager_Bungee) this.networkManager).getSpoofedUUID() != null) {
        uuid = ((IMixinNetworkManager_Bungee) this.networkManager).getSpoofedUUID();
    } else {
        uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + original.getName()).getBytes(Charsets.UTF_8));
    }

    original = new GameProfile(uuid, original.getName());

    if (((IMixinNetworkManager_Bungee) this.networkManager).getSpoofedProfile() != null) {
        for (final Property property : ((IMixinNetworkManager_Bungee) this.networkManager).getSpoofedProfile()) {
            original.getProperties().put(property.getName(), property);
        }
    }

    return original;
}
 
開發者ID:NeptunePowered,項目名稱:NeptuneMod,代碼行數:24,代碼來源:MixinNetHandlerLoginServer_Bungee.java

示例11: onProcessHandshake

import com.mojang.authlib.properties.Property; //導入依賴的package包/類
@Inject(method = "processHandshake", at = @At(value = "HEAD"), cancellable = true)
private void onProcessHandshake(C00Handshake packetIn, CallbackInfo ci) {
    if (packetIn.getRequestedState().equals(EnumConnectionState.LOGIN)) {
        final String[] split = packetIn.ip.split("\00");

        if (split.length >= 3) {
            packetIn.ip = split[0];
            ((IMixinNetworkManager_Bungee) this.networkManager).setRemoteAddress(new InetSocketAddress(split[1],
                            ((InetSocketAddress) this.networkManager.getRemoteAddress()).getPort()));
            ((IMixinNetworkManager_Bungee) this.networkManager).setSpoofedUUID(UUIDTypeAdapter.fromString(split[2]));

            if (split.length == 4) {
                ((IMixinNetworkManager_Bungee) this.networkManager).setSpoofedProfile(GSON.fromJson(split[3], Property[].class));
            }
        } else {
            final ChatComponentText chatcomponenttext =
                    new ChatComponentText("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!");
            this.networkManager.sendPacket(new S00PacketDisconnect(chatcomponenttext));
            this.networkManager.closeChannel(chatcomponenttext);
        }
    }
}
 
開發者ID:NeptunePowered,項目名稱:NeptuneMod,代碼行數:23,代碼來源:MixinNetHandlerHandshakeTCP_Bungee.java

示例12: getSkin

import com.mojang.authlib.properties.Property; //導入依賴的package包/類
private Property getSkin() {
    try {
        BufferedReader in = new BufferedReader(new InputStreamReader(new URL("https://sessionserver.mojang.com/session/minecraft/profile/136f2ba62be3444ca2968ec597edb57e?unsigned=false").openConnection().getInputStream()));
        String inputLine;
        StringBuilder response = new StringBuilder();
        while ((inputLine = in.readLine()) != null)
            response.append(inputLine);
        in.close();
        JsonObject json = Jsoner.deserialize(response.toString(), new JsonObject());
        JsonObject jo = (JsonObject) ((JsonArray) json.get("properties")).get(0);
        String signature = jo.getString(Jsoner.mintJsonKey("signature", null)), value = jo.getString(Jsoner.mintJsonKey("value", null));
        return new Property("textures", value, signature);
    } catch (Exception ignored) {
    }
    return null;
}
 
開發者ID:pupnewfster,項目名稱:Necessities,代碼行數:17,代碼來源:Necessities.java

示例13: setSkin

import com.mojang.authlib.properties.Property; //導入依賴的package包/類
public void setSkin(UUID uuid) {//TODO make this refresh their skin. Currently changes their gameprofile to have correct skin... but doesn't refresh the player
    if (bukkitPlayer == null)
        return;
    GameProfile profile = ((CraftPlayer) bukkitPlayer).getHandle().getProfile();
    try {
        Field prop = profile.getProperties().getClass().getDeclaredField("properties");
        prop.setAccessible(true);
        Multimap<String, Property> properties = (Multimap<String, Property>) prop.get(profile.getProperties());
        BufferedReader in = new BufferedReader(new InputStreamReader(new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid.toString().replaceAll("-", "") + "?unsigned=false").openConnection().getInputStream()));
        String inputLine;
        StringBuilder response = new StringBuilder();
        while ((inputLine = in.readLine()) != null)
            response.append(inputLine);
        in.close();
        JsonObject json = Jsoner.deserialize(response.toString(), new JsonObject());
        JsonObject jo = (JsonObject) ((JsonArray) json.get("properties")).get(0);
        String signature = jo.getString(Jsoner.mintJsonKey("signature", null)), value = jo.getString(Jsoner.mintJsonKey("value", null));
        properties.removeAll("textures");
        properties.put("textures", new Property("textures", value, signature));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:pupnewfster,項目名稱:Necessities,代碼行數:24,代碼來源:User.java

示例14: readPacketData

import com.mojang.authlib.properties.Property; //導入依賴的package包/類
public void readPacketData(PacketBuffer p_148837_1_) throws IOException
{
    this.field_148957_a = p_148837_1_.readVarIntFromBuffer();
    UUID uuid = UUID.fromString(p_148837_1_.readStringFromBuffer(36));
    this.field_148955_b = new GameProfile(uuid, p_148837_1_.readStringFromBuffer(16));
    int i = p_148837_1_.readVarIntFromBuffer();

    for (int j = 0; j < i; ++j)
    {
        String s = p_148837_1_.readStringFromBuffer(32767);
        String s1 = p_148837_1_.readStringFromBuffer(32767);
        String s2 = p_148837_1_.readStringFromBuffer(32767);
        this.field_148955_b.getProperties().put(s, new Property(s, s1, s2));
    }

    this.field_148956_c = p_148837_1_.readInt();
    this.field_148953_d = p_148837_1_.readInt();
    this.field_148954_e = p_148837_1_.readInt();
    this.field_148951_f = p_148837_1_.readByte();
    this.field_148952_g = p_148837_1_.readByte();
    this.field_148959_h = p_148837_1_.readShort();
    this.field_148958_j = DataWatcher.readWatchedListFromPacketBuffer(p_148837_1_);
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:24,代碼來源:S0CPacketSpawnPlayer.java

示例15: writePacketData

import com.mojang.authlib.properties.Property; //導入依賴的package包/類
public void writePacketData(PacketBuffer p_148840_1_) throws IOException
{
    p_148840_1_.writeVarIntToBuffer(this.field_148957_a);
    UUID uuid = this.field_148955_b.getId();
    p_148840_1_.writeStringToBuffer(uuid == null ? "" : uuid.toString());
    p_148840_1_.writeStringToBuffer(this.field_148955_b.getName());
    p_148840_1_.writeVarIntToBuffer(this.field_148955_b.getProperties().size());
    Iterator iterator = this.field_148955_b.getProperties().values().iterator();

    while (iterator.hasNext())
    {
        Property property = (Property)iterator.next();
        p_148840_1_.writeStringToBuffer(property.getName());
        p_148840_1_.writeStringToBuffer(property.getValue());
        p_148840_1_.writeStringToBuffer(property.getSignature());
    }

    p_148840_1_.writeInt(this.field_148956_c);
    p_148840_1_.writeInt(this.field_148953_d);
    p_148840_1_.writeInt(this.field_148954_e);
    p_148840_1_.writeByte(this.field_148951_f);
    p_148840_1_.writeByte(this.field_148952_g);
    p_148840_1_.writeShort(this.field_148959_h);
    this.field_148960_i.func_151509_a(p_148840_1_);
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:26,代碼來源:S0CPacketSpawnPlayer.java


注:本文中的com.mojang.authlib.properties.Property類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。