Search in sources :

Example 1 with PropertyMap

use of com.mojang.authlib.properties.PropertyMap in project SkinsRestorerX by DoNotSpamPls.

the class SkinsGUI method setSkin.

private static ItemStack setSkin(ItemStack head, String b64stringtexture) {
    GameProfile profile = new GameProfile(UUID.randomUUID(), null);
    PropertyMap propertyMap = profile.getProperties();
    if (propertyMap == null) {
        throw new IllegalStateException("Profile doesn't contain a property map");
    }
    propertyMap.put("textures", new Property("textures", b64stringtexture));
    ItemMeta headMeta = head.getItemMeta();
    Class<?> headMetaClass = headMeta.getClass();
    try {
        ReflectionUtil.getField(headMetaClass, "profile", GameProfile.class, 0).set(headMeta, profile);
    } catch (IllegalArgumentException | IllegalAccessException e) {
        e.printStackTrace();
    }
    head.setItemMeta(headMeta);
    return head;
}
Also used : PropertyMap(com.mojang.authlib.properties.PropertyMap) GameProfile(com.mojang.authlib.GameProfile) Property(com.mojang.authlib.properties.Property) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 2 with PropertyMap

use of com.mojang.authlib.properties.PropertyMap in project SpongeCommon by SpongePowered.

the class HumanEntity method setProfileName.

private void setProfileName(final net.minecraft.network.chat.@Nullable Component newName) {
    final PropertyMap props = this.fakeProfile.getProperties();
    this.fakeProfile = new GameProfile(this.fakeProfile.getId(), newName == null ? "" : newName.getString());
    this.fakeProfile.getProperties().putAll(props);
}
Also used : PropertyMap(com.mojang.authlib.properties.PropertyMap) GameProfile(com.mojang.authlib.GameProfile)

Example 3 with PropertyMap

use of com.mojang.authlib.properties.PropertyMap in project SpongeCommon by SpongePowered.

the class EntityHuman method renameProfile.

private void renameProfile(String newName) {
    PropertyMap props = this.fakeProfile.getProperties();
    this.fakeProfile = new GameProfile(this.fakeProfile.getId(), newName);
    this.fakeProfile.getProperties().putAll(props);
}
Also used : PropertyMap(com.mojang.authlib.properties.PropertyMap) GameProfile(com.mojang.authlib.GameProfile)

Example 4 with PropertyMap

use of com.mojang.authlib.properties.PropertyMap in project SpongeCommon by SpongePowered.

the class EntityHuman method updateFakeProfileWithSkin.

private boolean updateFakeProfileWithSkin(UUID skin) {
    PropertyMap properties = PROPERTIES_CACHE.getUnchecked(skin);
    if (properties.isEmpty()) {
        return false;
    }
    this.fakeProfile.getProperties().replaceValues("textures", properties.get("textures"));
    this.skinUuid = skin;
    return true;
}
Also used : PropertyMap(com.mojang.authlib.properties.PropertyMap)

Aggregations

PropertyMap (com.mojang.authlib.properties.PropertyMap)4 GameProfile (com.mojang.authlib.GameProfile)3 Property (com.mojang.authlib.properties.Property)1 ItemMeta (org.bukkit.inventory.meta.ItemMeta)1