com.mojang.authlib.GameProfile Java Examples

The following examples show how to use com.mojang.authlib.GameProfile. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SkullUtils.java    From XSeries with MIT License 6 votes vote down vote up
@Nonnull
public static SkullMeta getSkullByValue(@Nonnull SkullMeta head, @Nonnull String value) {
    Validate.notEmpty(value, "Skull value cannot be null or empty");
    GameProfile profile = new GameProfile(UUID.randomUUID(), null);

    profile.getProperties().put("textures", new Property("textures", value));
    try {
        Field profileField = head.getClass().getDeclaredField("profile");
        profileField.setAccessible(true);
        profileField.set(head, profile);
    } catch (SecurityException | NoSuchFieldException | IllegalAccessException ex) {
        ex.printStackTrace();
    }

    return head;
}
 
Example #2
Source File: ServerInfoPacketHandler.java    From PingAPI with MIT License 6 votes vote down vote up
/**
 * Creates a new PingReply instance from the data found in a PacketStatusOutServerInfo packet
 * @param packet The PacketStatusOutServerInfo instance
 * @param ctx The ChannelHandlerContext instance
 * @return A PingReply instance
 */
public static PingReply constructReply(PacketStatusOutServerInfo packet, ChannelHandlerContext ctx) {
	try {
		ServerPing ping = (ServerPing) SERVER_PING_FIELD.get(packet);
		String motd = ChatSerializer.a(ping.a());
		int max = ping.b().a();
		int online = ping.b().b();
		int protocolVersion = ping.c().b();
		String protocolName = ping.c().a();
		GameProfile[] profiles = ping.b().c();
		List<String> list = new ArrayList<String>();
		for(int i = 0; i < profiles.length; i++) {
			list.add(profiles[i].getName());
		}
		PingReply reply = new PingReply(ctx, motd, online, max, protocolVersion, protocolName, list);
		return reply;
	} catch(IllegalAccessException e) {
		e.printStackTrace();
	}
	return null;
}
 
Example #3
Source File: ResourceManager.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
public boolean renderInPersonMode(Object instance, Object itemStackObject, Object entityPlayerObject, Object cameraTransformTypeObject, boolean leftHand) {
	if (!MinecraftFactory.getClassProxyCallback().isRenderCustomModels()) {
		return false;
	}
	adz itemStack = (adz) itemStackObject;
	if (!(entityPlayerObject instanceof zs)) {
		return false;
	}
	zs entityPlayer = (zs) entityPlayerObject;
	bpl.b cameraTransformType = (bpl.b) cameraTransformTypeObject;
	GameProfile profile = entityPlayer.cP();
	PlayerResource playerResource = playerProfile.getName().equals(profile.getName()) ? ownPlayerResource : playerResources.getIfPresent(profile.getId());
	if (playerResource == null || playerResource.getItemModelResources() == null) {
		return false;
	}
	for (ItemModelResource itemModelResource : playerResource.getItemModelResources()) {
		if (shouldRender(itemModelResource, entityPlayer, itemStack)) {
			render(instance, itemStack, itemModelResource, cameraTransformType, leftHand);
			return true;
		}
	}

	return false;
}
 
Example #4
Source File: ServerInfoPacketHandler.java    From PingAPI with MIT License 6 votes vote down vote up
/**
 * Creates a new PacketStatusOutServerInfo packet from the data found in a PingReply instance
 * @param reply The PingReply instance
 * @return A PacketStatusOutServerInfo packet
 */
public static PacketStatusOutServerInfo constructPacket(PingReply reply) {
	GameProfile[] sample = new GameProfile[reply.getPlayerSample().size()];
	List<String> list = reply.getPlayerSample();
	for(int i = 0; i < list.size(); i++) {
		sample[i] = new GameProfile(UUID.randomUUID(), list.get(i));
	}
	ServerPingPlayerSample playerSample = new ServerPingPlayerSample(reply.getMaxPlayers(), reply.getOnlinePlayers());
	playerSample.a(sample);
	ServerPing ping = new ServerPing();
	ping.setMOTD(new ChatComponentText(reply.getMOTD()));
	ping.setPlayerSample(playerSample);
	ping.setServerInfo(new ServerData(reply.getProtocolName(), reply.getProtocolVersion()));
	ping.setFavicon(((CraftIconCache) reply.getIcon()).value);
	return new PacketStatusOutServerInfo(ping);
}
 
Example #5
Source File: YggdrasilMinecraftSessionService.java    From Launcher with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void joinServer(GameProfile profile, String accessToken, String serverID) throws AuthenticationException {

    // Join server
    String username = profile.getName();
    if (LogHelper.isDebugEnabled()) {
        LogHelper.debug("joinServer, Username: '%s', Access token: %s, Server ID: %s", username, accessToken, serverID);
    }

    // Make joinServer request
    boolean success;
    try {
        success = new JoinServerRequest(username, accessToken, serverID).request().allow;
    } catch (Exception e) {
        LogHelper.error(e);
        throw new AuthenticationUnavailableException(e);
    }

    // Verify is success
    if (!success)
        throw new AuthenticationException("Bad Login (Clientside)");
}
 
Example #6
Source File: NMSHacks.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
static PacketPlayOutPlayerInfo.PlayerInfoData playerListPacketData(
    PacketPlayOutPlayerInfo packet,
    UUID uuid,
    String name,
    @Nullable BaseComponent displayName,
    GameMode gamemode,
    int ping,
    @Nullable Skin skin) {
  GameProfile profile = new GameProfile(uuid, name);
  if (skin != null) {
    for (Map.Entry<String, Collection<Property>> entry :
        Skins.toProperties(skin).asMap().entrySet()) {
      profile.getProperties().putAll(entry.getKey(), entry.getValue());
    }
  }
  PacketPlayOutPlayerInfo.PlayerInfoData data =
      packet.constructData(
          profile,
          ping,
          gamemode == null ? null : WorldSettings.EnumGamemode.getById(gamemode.getValue()),
          null); // ELECTROID
  data.displayName = displayName == null ? null : new BaseComponent[] {displayName};
  return data;
}
 
Example #7
Source File: ServerPing.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
private int checkPing() {
	long l = System.currentTimeMillis();
	if (l - lastPinged < 1000) {
		return ping;
	}
	lastPinged = l;

	GameProfile gameProfile = The5zigMod.getDataManager().getGameProfile();
	for (NetworkPlayerInfo networkPlayerInfo : The5zigMod.getVars().getServerPlayers()) {
		if (gameProfile.equals(networkPlayerInfo.getGameProfile()) || gameProfile.getName().equals(ChatColor.stripColor(networkPlayerInfo.getDisplayName()))
				|| (networkPlayerInfo.getGameProfile() != null && gameProfile.getName().equals(networkPlayerInfo.getGameProfile().getName()))) {
			if (networkPlayerInfo.getPing() <= 0) {
				ping = 0;
			} else {
				ping = networkPlayerInfo.getPing();
			}
			break;
		}
	}

	return ping;
}
 
Example #8
Source File: ServerInfoPacketHandler.java    From PingAPI with MIT License 6 votes vote down vote up
/**
 * Creates a new PingReply instance from the data found in a PacketStatusOutServerInfo packet
 * @param packet The PacketStatusOutServerInfo instance
 * @param ctx The ChannelHandlerContext instance
 * @return A PingReply instance
 */
public static PingReply constructReply(PacketStatusOutServerInfo packet, ChannelHandlerContext ctx) {
	try {
		ServerPing ping = (ServerPing) SERVER_PING_FIELD.get(packet);
		String motd = ChatSerializer.a(ping.a());
		int max = ping.b().a();
		int online = ping.b().b();
		int protocolVersion = ping.getServerData().getProtocolVersion();
		String protocolName = ping.getServerData().a();
		GameProfile[] profiles = ping.b().c();
		List<String> list = new ArrayList<String>();
		for(int i = 0; i < profiles.length; i++) {
			list.add(profiles[i].getName());
		}
		PingReply reply = new PingReply(ctx, motd, online, max, protocolVersion, protocolName, list);
		return reply;
	} catch(IllegalAccessException e) {
		e.printStackTrace();
	}
	return null;
}
 
Example #9
Source File: PonySkull.java    From MineLittlePony with MIT License 6 votes vote down vote up
@Override
public Identifier getSkinResource(@Nullable GameProfile profile) {
    deadMau5.setVisible(profile != null && "deadmau5".equals(profile.getName()));

    if (profile != null) {
        Identifier skin = SkinsProxy.instance.getSkinTexture(profile);

        if (skin != null) {
            return skin;
        }

        return DefaultSkinHelper.getTexture(PlayerEntity.getUuidFromProfile(profile));
    }

    return DefaultSkinHelper.getTexture();
}
 
Example #10
Source File: PlayerCommand.java    From fabric-carpet with MIT License 6 votes vote down vote up
private static boolean cantSpawn(CommandContext<ServerCommandSource> context)
{
    String playerName = StringArgumentType.getString(context, "player");
    MinecraftServer server = context.getSource().getMinecraftServer();
    PlayerManager manager = server.getPlayerManager();
    PlayerEntity player = manager.getPlayer(playerName);
    if (player != null)
    {
        Messenger.m(context.getSource(), "r Player ", "rb " + playerName, "r  is already logged on");
        return true;
    }
    GameProfile profile = server.getUserCache().findByName(playerName);
    if (manager.getUserBanList().contains(profile))
    {
        Messenger.m(context.getSource(), "r Player ", "rb " + playerName, "r  is banned");
        return true;
    }
    if (manager.isWhitelistEnabled() && profile != null && manager.isWhitelisted(profile) && !context.getSource().hasPermissionLevel(2))
    {
        Messenger.m(context.getSource(), "r Whitelisted players can only be spawned by operators");
        return true;
    }
    return false;
}
 
Example #11
Source File: ServerInfoPacketHandler.java    From PingAPI with MIT License 6 votes vote down vote up
/**
 * Creates a new PingReply instance from the data found in a PacketStatusOutServerInfo packet
 * @param packet The PacketStatusOutServerInfo instance
 * @param ctx The ChannelHandlerContext instance
 * @return A PingReply instance
 */
public static PingReply constructReply(PacketStatusOutServerInfo packet, ChannelHandlerContext ctx) {
	try {
		ServerPing ping = (ServerPing) SERVER_PING_FIELD.get(packet);
		String motd = ChatSerializer.a(ping.a());
		int max = ping.b().a();
		int online = ping.b().b();
		int protocolVersion = ping.getServerData().getProtocolVersion();
		String protocolName = ping.getServerData().a();
		GameProfile[] profiles = ping.b().c();
		List<String> list = new ArrayList<String>();
		for(int i = 0; i < profiles.length; i++) {
			list.add(profiles[i].getName());
		}
		PingReply reply = new PingReply(ctx, motd, online, max, protocolVersion, protocolName, list);
		return reply;
	} catch(IllegalAccessException e) {
		e.printStackTrace();
	}
	return null;
}
 
Example #12
Source File: SkullMetaTransformer.java    From RuntimeTransformer with MIT License 6 votes vote down vote up
@Inject(InjectionType.OVERRIDE)
void applyToItem(final NBTTagCompound tag) {
    super_applyToItem(tag);
    if (this.profile != null) {
        NBTTagCompound owner = new NBTTagCompound();
        GameProfileSerializer.serialize(owner, this.profile);
        tag.set("SkullOwner", owner);
        System.out.println("Set owner to " + owner);
        TileEntitySkull.b(this.profile, new Predicate<GameProfile>() {
            @Override
            public boolean apply(@Nullable GameProfile gameProfile) {
                NBTTagCompound newOwner = new NBTTagCompound();
                GameProfileSerializer.serialize(newOwner, gameProfile);
                tag.set("SkullOwner", newOwner);
                System.out.println("Received game profile!");
                return false;
            }
        });
    }

}
 
Example #13
Source File: ServerInfoPacketHandler.java    From PingAPI with MIT License 6 votes vote down vote up
/**
 * Creates a new PingReply instance from the data found in a PacketStatusOutServerInfo packet
 * @param packet The PacketStatusOutServerInfo instance
 * @param ctx The ChannelHandlerContext instance
 * @return A PingReply instance
 */
public static PingReply constructReply(PacketStatusOutServerInfo packet, ChannelHandlerContext ctx) {
	try {
		ServerPing ping = (ServerPing) SERVER_PING_FIELD.get(packet);
		String motd = ChatSerializer.a(ping.a());
		int max = ping.b().a();
		int online = ping.b().b();
		int protocolVersion = ping.c().b();
		String protocolName = ping.c().a();
		GameProfile[] profiles = ping.b().c();
		List<String> list = new ArrayList<String>();
		for(int i = 0; i < profiles.length; i++) {
			list.add(profiles[i].getName());
		}
		PingReply reply = new PingReply(ctx, motd, online, max, protocolVersion, protocolName, list);
		return reply;
	} catch(IllegalAccessException e) {
		e.printStackTrace();
	}
	return null;
}
 
Example #14
Source File: SkullHandler.java    From QualityArmory with GNU General Public License v3.0 6 votes vote down vote up
public static String getURL(ItemStack is) {
	if (is.getType() !=MultiVersionLookup.getSkull())
		return null;
	ItemMeta headMeta = is.getItemMeta();
	Class<?> headMetaClass = headMeta.getClass();
	GameProfile prof = ReflectionsUtil.getField(headMetaClass, "profile", GameProfile.class).get(headMeta);
	PropertyMap propertyMap = prof.getProperties();
	Collection<Property> textures64 = propertyMap.get("textures");
	String tex64 = null;
	for (Property p : textures64) {
		if (p.getName().equals("textures")) {
			tex64 = p.getValue();
			break;
		}
	}
	if (tex64 != null) {
	    byte[] decode = null;
		decode = Base64.getDecoder().decode(tex64);
		String string = new String(decode);
		String parsed = string.split("SKIN:{url:\"")[1].split("\"}}}")[0];
		return parsed;
	}
	return null;
}
 
Example #15
Source File: ServerInfoPacketHandler.java    From PingAPI with MIT License 6 votes vote down vote up
/**
 * Creates a new PingReply instance from the data found in a PacketStatusOutServerInfo packet
 * @param packet The PacketStatusOutServerInfo instance
 * @param ctx The ChannelHandlerContext instance
 * @return A PingReply instance
 */
public static PingReply constructReply(PacketStatusOutServerInfo packet, ChannelHandlerContext ctx) {
	try {
		ServerPing ping = (ServerPing) SERVER_PING_FIELD.get(packet);
		String motd = ChatSerializer.a(ping.a());
		int max = ping.b().a();
		int online = ping.b().b();
		int protocolVersion = ping.getServerData().getProtocolVersion();
		String protocolName = ping.getServerData().a();
		GameProfile[] profiles = ping.b().c();
		List<String> list = new ArrayList<String>();
		for(int i = 0; i < profiles.length; i++) {
			list.add(profiles[i].getName());
		}
		PingReply reply = new PingReply(ctx, motd, online, max, protocolVersion, protocolName, list);
		return reply;
	} catch(IllegalAccessException e) {
		e.printStackTrace();
	}
	return null;
}
 
Example #16
Source File: ChatIdentifierService.java    From ForgeHax with MIT License 6 votes vote down vote up
private static boolean extract(
    String message, Pattern[] patterns, BiConsumer<GameProfile, String> callback) {
  for (Pattern pattern : patterns) {
    Matcher matcher = pattern.matcher(message);
    if (matcher.find()) {
      final String messageSender = matcher.group(1);
      final String messageOnly = matcher.group(2);
      if (!Strings.isNullOrEmpty(messageSender)) {
        for (NetworkPlayerInfo data : getLocalPlayer().connection.getPlayerInfoMap()) {
          if (
              String.CASE_INSENSITIVE_ORDER
                  .compare(messageSender, data.getGameProfile().getName())
                  == 0) {
            callback.accept(data.getGameProfile(), messageOnly);
            return true;
          }
        }
      }
    }
  }
  return false;
}
 
Example #17
Source File: ResourceManager.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
public boolean renderInPersonMode(Object instance, Object itemStackObject, Object entityPlayerObject, Object cameraTransformTypeObject, boolean leftHand) {
	if (!MinecraftFactory.getClassProxyCallback().isRenderCustomModels()) {
		return false;
	}
	adq itemStack = (adq) itemStackObject;
	if (!(entityPlayerObject instanceof zj)) {
		return false;
	}
	zj entityPlayer = (zj) entityPlayerObject;
	bos.b cameraTransformType = (bos.b) cameraTransformTypeObject;
	GameProfile profile = entityPlayer.cK();
	PlayerResource playerResource = playerProfile.getName().equals(profile.getName()) ? ownPlayerResource : playerResources.getIfPresent(profile.getId());
	if (playerResource == null || playerResource.getItemModelResources() == null) {
		return false;
	}
	for (ItemModelResource itemModelResource : playerResource.getItemModelResources()) {
		if (shouldRender(itemModelResource, entityPlayer, itemStack)) {
			render(instance, itemStack, itemModelResource, cameraTransformType, leftHand);
			return true;
		}
	}

	return false;
}
 
Example #18
Source File: ItemSkullRenderer.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@Override
public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
	GameProfile profile = stack.hasTagCompound() ? profile = getGameProfile(stack) : null;

	switch (type) {
		case ENTITY:
			renderSkull(-0.25F, -0.5F, -0.5F, stack.getItemDamage(), profile);
			break;
		case EQUIPPED:
			renderSkull(0.5F, 0.0F, 0.0F, stack.getItemDamage(), profile);
			break;
		case EQUIPPED_FIRST_PERSON:
			renderSkull(0.5F, 0.35F, 0.25F, stack.getItemDamage(), profile);
			break;
		case INVENTORY:
			OpenGLHelper.scale(1.5, 1.5, 1.5);
			renderSkull(0.75F, 0.30F, 0.5F, stack.getItemDamage(), profile);
			break;
		default:
			break;
	}
}
 
Example #19
Source File: ServerInfoPacketHandler.java    From PingAPI with MIT License 6 votes vote down vote up
/**
 * Creates a new PacketStatusOutServerInfo packet from the data found in a PingReply instance
 * @param reply The PingReply instance
 * @return A PacketStatusOutServerInfo packet
 */
public static PacketStatusOutServerInfo constructPacket(PingReply reply) {
	GameProfile[] sample = new GameProfile[reply.getPlayerSample().size()];
	List<String> list = reply.getPlayerSample();
	for(int i = 0; i < list.size(); i++) {
		sample[i] = new GameProfile(UUID.randomUUID(), list.get(i));
	}
	ServerPingPlayerSample playerSample = new ServerPingPlayerSample(reply.getMaxPlayers(), reply.getOnlinePlayers());
	playerSample.a(sample);
	ServerPing ping = new ServerPing();
	ping.setMOTD(new ChatComponentText(reply.getMOTD()));
	ping.setPlayerSample(playerSample);
	ping.setServerInfo(new ServerData(reply.getProtocolName(), reply.getProtocolVersion()));
	ping.setFavicon(((CraftIconCache) reply.getIcon()).value);
	return new PacketStatusOutServerInfo(ping);
}
 
Example #20
Source File: TileEntityGlassesBridge.java    From OpenPeripheral-Addons with MIT License 6 votes vote down vote up
private void queueEvent(String event, EntityPlayer user, IEventArgsSource source) {
	final GameProfile gameProfile = user.getGameProfile();
	final UUID userId = gameProfile.getId();
	final String idString = userId != null? userId.toString() : null;
	final String userName = gameProfile.getName();

	for (IArchitectureAccess computer : computers) {
		final Object[] extra = source.getArgs(computer);
		final Object[] args = new Object[3 + extra.length];
		System.arraycopy(extra, 0, args, 3, extra.length);
		args[0] = computer.peripheralName();
		args[1] = userName;
		args[2] = idString;

		computer.signal(event, args);
	}
}
 
Example #21
Source File: ScoreboardListenerService.java    From ForgeHax with MIT License 6 votes vote down vote up
private void fireEvents(
    SPacketPlayerListItem.Action action, PlayerInfo info, GameProfile profile) {
  if (ignore || info == null) {
    return;
  }
  switch (action) {
    case ADD_PLAYER: {
      MinecraftForge.EVENT_BUS.post(new PlayerConnectEvent.Join(info, profile));
      break;
    }
    case REMOVE_PLAYER: {
      MinecraftForge.EVENT_BUS.post(new PlayerConnectEvent.Leave(info, profile));
      break;
    }
  }
}
 
Example #22
Source File: FaweForge.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public UUID getUUID(String name) {
    try {
        GameProfile profile = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getGameProfileForUsername(name);
        return profile.getId();
    } catch (Throwable e) {
        return null;
    }
}
 
Example #23
Source File: CraftProfileBanList.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void pardon(String target) {
    Validate.notNull(target, "Target cannot be null");

    GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(target);
    list.func_152684_c(profile);
}
 
Example #24
Source File: NMS_1_13.java    From 1.13-Command-API with Apache License 2.0 5 votes vote down vote up
@Override
public Player getPlayer(CommandContext cmdCtx, String str) throws CommandSyntaxException {
    Player target = Bukkit.getPlayer(((GameProfile) ArgumentProfile.a(cmdCtx, str).iterator().next()).getId());
    if (target == null) {
        throw ArgumentProfile.a.create();
    } else {
        return target;
    }
}
 
Example #25
Source File: CraftProfileBanEntry.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public CraftProfileBanEntry(GameProfile profile, UserListBansEntry entry, UserListBans list) {
    this.list = list;
    this.profile = profile;
    this.created = entry.getCreated() != null ? new Date(entry.getCreated().getTime()) : null;
    this.source = entry.getSource();
    this.expiration = entry.getBanEndDate() != null ? new Date(entry.getBanEndDate().getTime()) : null;
    this.reason = entry.getBanReason();
}
 
Example #26
Source File: MixinNBTUtil.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @author Sk1er
 * @reason Not proper null checks
 */
@Overwrite
public static GameProfile readGameProfileFromNBT(NBTTagCompound compound) {
    String s = null;
    String s1 = null;

    if (compound.hasKey("Name", 8)) s = compound.getString("Name");
    if (compound.hasKey("Id", 8)) s1 = compound.getString("Id");

    if (StringUtils.isNullOrEmpty(s) && StringUtils.isNullOrEmpty(s1)) {
        return null;
    } else {
        UUID uuid = null;
        if (s1 != null)
            try {
                uuid = UUID.fromString(s1);
            } catch (Throwable ignored) {
            }

        GameProfile gameprofile = new GameProfile(uuid, s);

        if (compound.hasKey("Properties", 10)) {
            NBTTagCompound nbttagcompound = compound.getCompoundTag("Properties");

            for (String s2 : nbttagcompound.getKeySet()) {
                NBTTagList nbttaglist = nbttagcompound.getTagList(s2, 10);

                int bound = nbttaglist.tagCount();
                for (int i = 0; i < bound; i++) {
                    NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                    String s3 = nbttagcompound1.getString("Value");
                    gameprofile.getProperties().put(s2, nbttagcompound1.hasKey("Signature", 8) ?
                        new Property(s2, s3, nbttagcompound1.getString("Signature")) : new Property(s2, s3));
                }
            }
        }

        return gameprofile;
    }
}
 
Example #27
Source File: FaweForge.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public UUID getUUID(String name) {
    try {
        GameProfile profile = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getGameProfileForUsername(name);
        return profile.getId();
    } catch (Throwable e) {
        return null;
    }
}
 
Example #28
Source File: TileEntityGlassesBridge.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
@Asynchronous
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get the names of all the users linked up to this bridge")
public List<GameProfile> getUsers() {
	List<GameProfile> result = Lists.newArrayList();
	for (PlayerInfo info : knownPlayersByUUID.values())
		result.add(info.profile);

	return result;
}
 
Example #29
Source File: GameprofileTest.java    From Item-NBT-API with MIT License 5 votes vote down vote up
@Override
public void test() throws Exception {
	UUID uuid = UUID.randomUUID();
	GameProfile profile = new GameProfile(uuid, "random");
	NBTCompound nbt = NBTGameProfile.toNBT(profile);
	profile = null;
	profile = NBTGameProfile.fromNBT(nbt);
	if (profile == null || !profile.getId().equals(uuid)) {
		throw new NbtApiException("Error when converting a GameProfile from/to NBT!");
	}
}
 
Example #30
Source File: ResourceManager.java    From The-5zig-Mod with MIT License 5 votes vote down vote up
@Override
public Object getCapeLocation(Object player) {
	GameProfile profile = ((bpp) player).cS();
	if (playerProfile.getName().equals(profile.getName())) {
		return getCapeLocation(ownPlayerResource);
	} else {
		return getCapeLocation(playerResources.getIfPresent(profile.getId()));
	}
}