Search in sources :

Example 6 with PlayerProfile

use of com.denizenscript.denizen.nms.util.PlayerProfile in project Denizen-For-Bukkit by DenizenScript.

the class BlockHelperImpl method getPlayerProfile.

@Override
public PlayerProfile getPlayerProfile(Skull skull) {
    GameProfile profile = getTE(((CraftSkull) skull)).gameProfile;
    if (profile == null) {
        return null;
    }
    String name = profile.getName();
    UUID id = profile.getId();
    com.mojang.authlib.properties.Property property = Iterables.getFirst(profile.getProperties().get("textures"), null);
    return new PlayerProfile(name, id, property != null ? property.getValue() : null);
}
Also used : GameProfile(com.mojang.authlib.GameProfile) PlayerProfile(com.denizenscript.denizen.nms.util.PlayerProfile) Property(com.mojang.authlib.properties.Property) UUID(java.util.UUID)

Example 7 with PlayerProfile

use of com.denizenscript.denizen.nms.util.PlayerProfile 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_17_R1.entity.CraftPlayer) Property(com.mojang.authlib.properties.Property)

Example 8 with PlayerProfile

use of com.denizenscript.denizen.nms.util.PlayerProfile in project Denizen-For-Bukkit by DenizenScript.

the class Handler method fillPlayerProfile.

@Override
public PlayerProfile fillPlayerProfile(PlayerProfile playerProfile) {
    try {
        if (playerProfile != null) {
            GameProfile gameProfile = new GameProfile(playerProfile.getUniqueId(), playerProfile.getName());
            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()));
            }
            MinecraftServer minecraftServer = ((CraftServer) Bukkit.getServer()).getServer();
            GameProfile gameProfile1 = null;
            if (gameProfile.getId() != null) {
                gameProfile1 = minecraftServer.getProfileCache().get(gameProfile.getId()).orElse(null);
            }
            if (gameProfile1 == null && gameProfile.getName() != null) {
                gameProfile1 = minecraftServer.getProfileCache().get(gameProfile.getName()).orElse(null);
            }
            if (gameProfile1 == null) {
                gameProfile1 = gameProfile;
            }
            if (playerProfile.hasTexture()) {
                gameProfile1.getProperties().get("textures").clear();
                if (playerProfile.getTextureSignature() != null) {
                    gameProfile1.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature()));
                } else {
                    gameProfile1.getProperties().put("textures", new Property("textures", playerProfile.getTexture()));
                }
            }
            if (Iterables.getFirst(gameProfile1.getProperties().get("textures"), null) == null) {
                gameProfile1 = minecraftServer.getSessionService().fillProfileProperties(gameProfile1, true);
            }
            Property property = Iterables.getFirst(gameProfile1.getProperties().get("textures"), null);
            return new PlayerProfile(gameProfile1.getName(), gameProfile1.getId(), property != null ? property.getValue() : null, property != null ? property.getSignature() : null);
        }
    } catch (Exception e) {
        if (Debug.verbose) {
            Debug.echoError(e);
        }
    }
    return null;
}
Also used : GameProfile(com.mojang.authlib.GameProfile) PlayerProfile(com.denizenscript.denizen.nms.util.PlayerProfile) CraftServer(org.bukkit.craftbukkit.v1_17_R1.CraftServer) Property(com.mojang.authlib.properties.Property) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 9 with PlayerProfile

use of com.denizenscript.denizen.nms.util.PlayerProfile in project Denizen-For-Bukkit by DenizenScript.

the class BlockHelperImpl method getPlayerProfile.

@Override
public PlayerProfile getPlayerProfile(Skull skull) {
    GameProfile profile = getTE(((CraftSkull) skull)).owner;
    if (profile == null) {
        return null;
    }
    String name = profile.getName();
    UUID id = profile.getId();
    com.mojang.authlib.properties.Property property = Iterables.getFirst(profile.getProperties().get("textures"), null);
    return new PlayerProfile(name, id, property != null ? property.getValue() : null);
}
Also used : GameProfile(com.mojang.authlib.GameProfile) PlayerProfile(com.denizenscript.denizen.nms.util.PlayerProfile) Property(com.mojang.authlib.properties.Property)

Example 10 with PlayerProfile

use of com.denizenscript.denizen.nms.util.PlayerProfile 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)

Aggregations

PlayerProfile (com.denizenscript.denizen.nms.util.PlayerProfile)19 GameProfile (com.mojang.authlib.GameProfile)12 Property (com.mojang.authlib.properties.Property)12 UUID (java.util.UUID)7 ListTag (com.denizenscript.denizencore.objects.core.ListTag)3 BigInteger (java.math.BigInteger)3 MessageDigest (java.security.MessageDigest)3 Scoreboard (org.bukkit.scoreboard.Scoreboard)3 Team (org.bukkit.scoreboard.Team)3 DurationTag (com.denizenscript.denizencore.objects.core.DurationTag)2 ServerLevel (net.minecraft.server.level.ServerLevel)2 BukkitScriptEvent (com.denizenscript.denizen.events.BukkitScriptEvent)1 NMSHandler (com.denizenscript.denizen.nms.NMSHandler)1 BiomeNMS (com.denizenscript.denizen.nms.abstracts.BiomeNMS)1 EntityHelper (com.denizenscript.denizen.nms.interfaces.EntityHelper)1 CraftFakePlayerImpl (com.denizenscript.denizen.nms.v1_16.impl.entities.CraftFakePlayerImpl)1 EntityFakePlayerImpl (com.denizenscript.denizen.nms.v1_16.impl.entities.EntityFakePlayerImpl)1 CraftFakePlayerImpl (com.denizenscript.denizen.nms.v1_17.impl.entities.CraftFakePlayerImpl)1 EntityFakePlayerImpl (com.denizenscript.denizen.nms.v1_17.impl.entities.EntityFakePlayerImpl)1 CraftFakePlayerImpl (com.denizenscript.denizen.nms.v1_18.impl.entities.CraftFakePlayerImpl)1