Search in sources :

Example 26 with GameProfile

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

the class ProfileEditor_v1_10_R1 method updatePlayerProfiles.

public static void updatePlayerProfiles(PacketPlayOutPlayerInfo packet) {
    PacketPlayOutPlayerInfo.EnumPlayerInfoAction action = ReflectionHelper.getFieldValue(PacketPlayOutPlayerInfo.class, "a", packet);
    if (action != PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER) {
        return;
    }
    List<?> dataList = ReflectionHelper.getFieldValue(PacketPlayOutPlayerInfo.class, "b", packet);
    if (dataList != null) {
        try {
            for (Object data : dataList) {
                GameProfile gameProfile = (GameProfile) playerInfoData_gameProfile.get(data);
                if (fakeProfiles.containsKey(gameProfile.getId())) {
                    playerInfoData_gameProfile.set(data, getGameProfile(fakeProfiles.get(gameProfile.getId())));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : GameProfile(com.mojang.authlib.GameProfile) PacketPlayOutPlayerInfo(net.minecraft.server.v1_10_R1.PacketPlayOutPlayerInfo)

Example 27 with GameProfile

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

the class ProfileEditor_v1_10_R1 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 28 with GameProfile

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

the class ItemHelper_v1_8_R3 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.server.v1_8_R3.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tag = nmsItemStack.hasTag() ? nmsItemStack.getTag() : new NBTTagCompound();
    tag.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameProfile));
    nmsItemStack.setTag(tag);
    return CraftItemStack.asBukkitCopy(nmsItemStack);
}
Also used : GameProfile(com.mojang.authlib.GameProfile) NBTTagCompound(net.minecraft.server.v1_8_R3.NBTTagCompound) Property(com.mojang.authlib.properties.Property) CompoundTag_v1_8_R3(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_8_R3)

Example 29 with GameProfile

use of com.mojang.authlib.GameProfile in project minecolonies by Minecolonies.

the class Permissions method loadPermissions.

/**
     * Reads the permissionMap from a NBT.
     *
     * @param compound NBT to read from.
     */
public void loadPermissions(@NotNull final NBTTagCompound compound) {
    //  Owners
    final NBTTagList ownerTagList = compound.getTagList(TAG_OWNERS, net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < ownerTagList.tagCount(); ++i) {
        final NBTTagCompound ownerCompound = ownerTagList.getCompoundTagAt(i);
        @NotNull final UUID id = UUID.fromString(ownerCompound.getString(TAG_ID));
        final Rank rank = Rank.valueOf(ownerCompound.getString(TAG_RANK));
        final GameProfile player = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getProfileByUUID(id);
        if (player != null) {
            players.put(id, new Player(id, player.getName(), rank));
        }
    }
    //Permissions
    final NBTTagList permissionsTagList = compound.getTagList(TAG_PERMISSIONS, net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < permissionsTagList.tagCount(); ++i) {
        final NBTTagCompound permissionsCompound = permissionsTagList.getCompoundTagAt(i);
        final Rank rank = Rank.valueOf(permissionsCompound.getString(TAG_RANK));
        final NBTTagList flagsTagList = permissionsCompound.getTagList(TAG_FLAGS, net.minecraftforge.common.util.Constants.NBT.TAG_STRING);
        int flags = 0;
        for (int j = 0; j < flagsTagList.tagCount(); ++j) {
            final String flag = flagsTagList.getStringTagAt(j);
            flags = Utils.setFlag(flags, Action.valueOf(flag).getFlag());
        }
        permissionMap.put(rank, flags);
    }
    if (compound.hasKey(TAG_OWNER)) {
        ownerName = compound.getString(TAG_OWNER);
    }
    if (compound.hasKey(TAG_OWNER_ID)) {
        try {
            ownerUUID = UUID.fromString(compound.getString(TAG_OWNER_ID));
        } catch (final IllegalArgumentException e) {
        /*
                 * Intentionally left empty. Happens when the UUID hasn't been saved yet.
                 */
        }
    }
    this.updatedPermissionAlready = compound.getBoolean(TAG_UPDATE);
    if (!updatedPermissionAlready) {
        updateNewPermissions();
    }
    restoreOwnerIfNull();
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) Player(com.minecolonies.api.colony.permissions.Player) EntityPlayer(net.minecraft.entity.player.EntityPlayer) GameProfile(com.mojang.authlib.GameProfile) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Rank(com.minecolonies.api.colony.permissions.Rank) NBTTagString(net.minecraft.nbt.NBTTagString) NotNull(org.jetbrains.annotations.NotNull)

Example 30 with GameProfile

use of com.mojang.authlib.GameProfile in project minecolonies by Minecolonies.

the class Permissions method setPlayerRank.

/**
     * Sets the player's rank to a given rank.
     *
     * @param id    UUID of the player of the new rank.
     * @param rank  Desired rank.
     * @param world the world the player is in.
     * @return True if successful, otherwise false.
     */
public boolean setPlayerRank(final UUID id, final Rank rank, final World world) {
    final Player player = players.get(id);
    if (player != null) {
        player.setRank(rank);
        markDirty();
        AchievementUtils.syncAchievements(colony);
    } else {
        final GameProfile gameprofile = world.getMinecraftServer().getPlayerProfileCache().getProfileByUUID(id);
        return gameprofile != null && addPlayer(gameprofile, rank);
    }
    return true;
}
Also used : Player(com.minecolonies.api.colony.permissions.Player) EntityPlayer(net.minecraft.entity.player.EntityPlayer) GameProfile(com.mojang.authlib.GameProfile)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)60 Property (com.mojang.authlib.properties.Property)30 PlayerProfile (net.aufdemrand.denizen.nms.util.PlayerProfile)16 UUID (java.util.UUID)11 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 BigInteger (java.math.BigInteger)4 MessageDigest (java.security.MessageDigest)4 Player (com.minecolonies.api.colony.permissions.Player)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 WorldServer (net.minecraft.world.WorldServer)3 Scoreboard (org.bukkit.scoreboard.Scoreboard)3 Team (org.bukkit.scoreboard.Team)3 FakeDedicatedServer (com.builtbroken.mc.testing.junit.server.FakeDedicatedServer)2 TestPlayer (com.builtbroken.mc.testing.junit.testers.TestPlayer)2 File (java.io.File)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 NBTTagString (net.minecraft.nbt.NBTTagString)2 NetHandlerPlayServer (net.minecraft.network.NetHandlerPlayServer)2 NetworkManager (net.minecraft.network.NetworkManager)2 PotionEffect (net.minecraft.potion.PotionEffect)2