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