Search in sources :

Example 1 with GameProfile

use of com.mojang.authlib.GameProfile in project PneumaticCraft by MineMaarten.

the class EntityDrone method initializeFakePlayer.

private void initializeFakePlayer() {
    fakePlayer = new DroneFakePlayer((WorldServer) worldObj, new GameProfile(playerUUID != null ? UUID.fromString(playerUUID) : null, playerName), new FakePlayerItemInWorldManager(worldObj, fakePlayer, this), this);
    fakePlayer.playerNetServerHandler = new NetHandlerPlayServer(MinecraftServer.getServer(), new NetworkManager(false), fakePlayer);
    fakePlayer.inventory = new InventoryFakePlayer(fakePlayer);
}
Also used : GameProfile(com.mojang.authlib.GameProfile) WorldServer(net.minecraft.world.WorldServer) NetworkManager(net.minecraft.network.NetworkManager) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer) FakePlayerItemInWorldManager(pneumaticCraft.common.ai.FakePlayerItemInWorldManager)

Example 2 with GameProfile

use of com.mojang.authlib.GameProfile in project PneumaticCraft by MineMaarten.

the class TileEntityProgrammableController method initializeFakePlayer.

private void initializeFakePlayer() {
    String playerUUID = null;
    String playerName = "Drone";
    fakePlayer = new DroneFakePlayer((WorldServer) worldObj, new GameProfile(playerUUID != null ? UUID.fromString(playerUUID) : null, playerName), new FakePlayerItemInWorldManager(worldObj, fakePlayer, this), this);
    fakePlayer.playerNetServerHandler = new NetHandlerPlayServer(MinecraftServer.getServer(), new NetworkManager(false), fakePlayer);
    fakePlayer.inventory = new InventoryPlayer(fakePlayer) {

        private ItemStack oldStack;

        @Override
        public int getSizeInventory() {
            return getDroneSlots();
        }

        @Override
        public void setInventorySlotContents(int slot, ItemStack stack) {
            super.setInventorySlotContents(slot, stack);
            if (slot == 0) {
                if (oldStack != null) {
                    getFakePlayer().getAttributeMap().removeAttributeModifiers(oldStack.getAttributeModifiers());
                }
                if (stack != null) {
                    getFakePlayer().getAttributeMap().applyAttributeModifiers(stack.getAttributeModifiers());
                }
                oldStack = stack;
            }
        }
    };
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) GameProfile(com.mojang.authlib.GameProfile) WorldServer(net.minecraft.world.WorldServer) DroneFakePlayer(pneumaticCraft.common.entity.living.EntityDrone.DroneFakePlayer) NetworkManager(net.minecraft.network.NetworkManager) ItemStack(net.minecraft.item.ItemStack) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer) FakePlayerItemInWorldManager(pneumaticCraft.common.ai.FakePlayerItemInWorldManager)

Example 3 with GameProfile

use of com.mojang.authlib.GameProfile in project PneumaticCraft by MineMaarten.

the class TileEntitySecurityStation method isPlayerOnWhiteList.

public boolean isPlayerOnWhiteList(EntityPlayer player) {
    for (int i = 0; i < sharedUsers.size(); i++) {
        GameProfile user = sharedUsers.get(i);
        if (gameProfileEquals(user, player.getGameProfile())) {
            if (user.getId() == null && player.getGameProfile().getId() != null) {
                sharedUsers.set(i, player.getGameProfile());
                Log.info("Legacy conversion: Security Station shared username '" + player.getCommandSenderName() + "' is now using UUID '" + player.getGameProfile().getId() + "'.");
            }
            return true;
        }
    }
    return false;
}
Also used : GameProfile(com.mojang.authlib.GameProfile)

Example 4 with GameProfile

use of com.mojang.authlib.GameProfile in project PneumaticCraft by MineMaarten.

the class TileEntitySecurityStation method addSharedUser.

public void addSharedUser(GameProfile user) {
    for (GameProfile sharedUser : sharedUsers) {
        if (gameProfileEquals(sharedUser, user))
            return;
    }
    sharedUsers.add(user);
    sendDescriptionPacket();
}
Also used : GameProfile(com.mojang.authlib.GameProfile)

Example 5 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)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)59 Property (com.mojang.authlib.properties.Property)28 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