Search in sources :

Example 31 with Property

use of com.mojang.authlib.properties.Property in project Denizen-For-Bukkit by DenizenScript.

the class Handler method getPlayerProfile.

@Override
public PlayerProfile getPlayerProfile(Player player) {
    GameProfile gameProfile = ((CraftPlayer) player).getProfile();
    Property property = Iterables.getFirst(gameProfile.getProperties().get("textures"), null);
    return new PlayerProfile(gameProfile.getName(), gameProfile.getId(), property != null ? property.getValue() : null, property != null ? property.getSignature() : null);
}
Also used : GameProfile(com.mojang.authlib.GameProfile) PlayerProfile(com.denizenscript.denizen.nms.util.PlayerProfile) CraftPlayer(org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer) Property(com.mojang.authlib.properties.Property)

Example 32 with Property

use of com.mojang.authlib.properties.Property in project Denizen-For-Bukkit by DenizenScript.

the class ItemHelperImpl method setSkullSkin.

@Override
public ItemStack setSkullSkin(ItemStack itemStack, PlayerProfile playerProfile) {
    GameProfile gameProfile = new GameProfile(playerProfile.getUniqueId(), playerProfile.getName());
    if (playerProfile.hasTexture()) {
        gameProfile.getProperties().get("textures").clear();
        if (playerProfile.getTextureSignature() != null) {
            gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature()));
        } else {
            gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture()));
        }
    }
    net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
    net.minecraft.nbt.CompoundTag tag = nmsItemStack.hasTag() ? nmsItemStack.getTag() : new net.minecraft.nbt.CompoundTag();
    tag.put("SkullOwner", NbtUtils.writeGameProfile(new net.minecraft.nbt.CompoundTag(), gameProfile));
    nmsItemStack.setTag(tag);
    return CraftItemStack.asBukkitCopy(nmsItemStack);
}
Also used : com.denizenscript.denizen.nms.util.jnbt(com.denizenscript.denizen.nms.util.jnbt) GameProfile(com.mojang.authlib.GameProfile) Property(com.mojang.authlib.properties.Property)

Example 33 with Property

use of com.mojang.authlib.properties.Property in project Denizen-For-Bukkit by DenizenScript.

the class ItemHelperImpl method setSkullSkin.

@Override
public ItemStack setSkullSkin(ItemStack itemStack, PlayerProfile playerProfile) {
    GameProfile gameProfile = new GameProfile(playerProfile.getUniqueId(), playerProfile.getName());
    if (playerProfile.hasTexture()) {
        gameProfile.getProperties().get("textures").clear();
        if (playerProfile.getTextureSignature() != null) {
            gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature()));
        } else {
            gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture()));
        }
    }
    net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
    net.minecraft.nbt.CompoundTag tag = nmsItemStack.hasTag() ? nmsItemStack.getTag() : new net.minecraft.nbt.CompoundTag();
    tag.put("SkullOwner", NbtUtils.writeGameProfile(new net.minecraft.nbt.CompoundTag(), gameProfile));
    nmsItemStack.setTag(tag);
    return CraftItemStack.asBukkitCopy(nmsItemStack);
}
Also used : com.denizenscript.denizen.nms.util.jnbt(com.denizenscript.denizen.nms.util.jnbt) GameProfile(com.mojang.authlib.GameProfile) Property(com.mojang.authlib.properties.Property)

Example 34 with Property

use of com.mojang.authlib.properties.Property in project Denizen-For-Bukkit by DenizenScript.

the class ProfileEditorImpl method getGameProfile.

private static GameProfile getGameProfile(PlayerProfile playerProfile) {
    GameProfile gameProfile = new GameProfile(playerProfile.getUniqueId(), playerProfile.getName());
    gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature()));
    return gameProfile;
}
Also used : GameProfile(com.mojang.authlib.GameProfile) Property(com.mojang.authlib.properties.Property)

Example 35 with Property

use of com.mojang.authlib.properties.Property in project askyblock by tastybento.

the class SkullBlock method getNonPlayerProfile.

// Credits: dori99xd
public static GameProfile getNonPlayerProfile(String textureValue, String ownerUUID, String ownerName) {
    // Create a new GameProfile with .schematic informations or with fake informations
    GameProfile newSkinProfile = new GameProfile(ownerUUID == null ? UUID.randomUUID() : UUID.fromString(ownerUUID), ownerName == null ? getRandomString(16) : null);
    // Insert textures properties
    newSkinProfile.getProperties().put("textures", new Property("textures", textureValue));
    return newSkinProfile;
}
Also used : GameProfile(com.mojang.authlib.GameProfile) Property(com.mojang.authlib.properties.Property)

Aggregations

Property (com.mojang.authlib.properties.Property)73 GameProfile (com.mojang.authlib.GameProfile)67 UUID (java.util.UUID)17 PlayerProfile (net.aufdemrand.denizen.nms.util.PlayerProfile)16 PlayerProfile (com.denizenscript.denizen.nms.util.PlayerProfile)12 BigInteger (java.math.BigInteger)7 MessageDigest (java.security.MessageDigest)7 Scoreboard (org.bukkit.scoreboard.Scoreboard)7 Team (org.bukkit.scoreboard.Team)7 PropertyMap (com.mojang.authlib.properties.PropertyMap)4 MinecraftServer (net.minecraft.server.MinecraftServer)3 ItemMeta (org.bukkit.inventory.meta.ItemMeta)3 SkullMeta (org.bukkit.inventory.meta.SkullMeta)3 com.denizenscript.denizen.nms.util.jnbt (com.denizenscript.denizen.nms.util.jnbt)2 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 Collection (java.util.Collection)2 CelestialBody (micdoodle8.mods.galacticraft.api.galaxies.CelestialBody)2 SolarSystem (micdoodle8.mods.galacticraft.api.galaxies.SolarSystem)2 ISchematicPage (micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)2