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);
}
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;
}
}
};
}
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;
}
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();
}
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();
}
Aggregations