Java Code Examples for com.mojang.authlib.GameProfile#getName()

The following examples show how to use com.mojang.authlib.GameProfile#getName() . 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: YggdrasilMinecraftSessionService.java    From Launcher with GNU General Public License v3.0 8 votes vote down vote up
@Override
public GameProfile hasJoinedServer(GameProfile profile, String serverID) throws AuthenticationUnavailableException {
    String username = profile.getName();
    if (LogHelper.isDebugEnabled()) {
        LogHelper.debug("checkServer, Username: '%s', Server ID: %s", username, serverID);
    }

    // Make checkServer request
    PlayerProfile pp;
    try {
        pp = new CheckServerRequest(username, serverID).request().playerProfile;
    } catch (Exception e) {
        LogHelper.error(e);
        throw new AuthenticationUnavailableException(e);
    }

    // Return profile if found
    return pp == null ? null : toGameProfile(pp);
}
 
Example 2
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 3
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 4
Source File: PacketPlayOutPlayerInfo.java    From TAB with Apache License 2.0 5 votes vote down vote up
public static PlayerInfoData fromNMS(Object nmsData) throws Exception{
	int ping = PING.getInt(nmsData);
	EnumGamemode gamemode = EnumGamemode.fromNMS(GAMEMODE.get(nmsData));
	GameProfile profile = (GameProfile) PROFILE.get(nmsData);
	Object nmsComponent = LISTNAME.get(nmsData);
	IChatBaseComponent listName = IChatBaseComponent.fromString(MethodAPI.getInstance().componentToString(nmsComponent));
	return new PlayerInfoData(profile.getName(), profile.getId(), profile.getProperties(), ping, gamemode, listName);
}
 
Example 5
Source File: CraftPlayerProfile.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public UUID setId(@Nullable UUID uuid) {
    GameProfile prev = this.profile;
    this.profile = new GameProfile(uuid, prev.getName());
    copyProfileProperties(prev, this.profile);
    return prev.getId();
}
 
Example 6
Source File: CraftPlayerProfile.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String setName(@Nullable String name) {
    GameProfile prev = this.profile;
    this.profile = new GameProfile(prev.getId(), name);
    copyProfileProperties(prev, this.profile);
    return prev.getName();
}
 
Example 7
Source File: GameProfileWrapper.java    From NameTagChanger with MIT License 5 votes vote down vote up
public static GameProfileWrapper fromHandle(Object object) {
    Validate.isTrue(object instanceof GameProfile, "object is not a GameProfile");
    GameProfile gameProfile = (GameProfile) object;
    GameProfileWrapper wrapper = new GameProfileWrapper(gameProfile.getId(), gameProfile.getName());
    for (Map.Entry<String, Collection<Property>> entry : gameProfile.getProperties().asMap().entrySet()) {
        for (Property property : entry.getValue()) {
            wrapper.getProperties().put(entry.getKey(), PropertyWrapper.fromHandle(property));
        }
    }
    return wrapper;
}
 
Example 8
Source File: FaweForge.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String getName(UUID uuid) {
    try {
        GameProfile profile = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getProfileByUUID(uuid);
        return profile.getName();
    } catch (Throwable e) {
        return null;
    }
}
 
Example 9
Source File: FaweForge.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String getName(UUID uuid) {
    try {
        GameProfile profile = MinecraftServer.getServer().getPlayerProfileCache().getProfileByUUID(uuid);
        return profile.getName();
    } catch (Throwable e) {
        return null;
    }
}
 
Example 10
Source File: FaweForge.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String getName(UUID uuid) {
    try {
        GameProfile profile = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getProfileByUUID(uuid);
        return profile.getName();
    } catch (Throwable e) {
        return null;
    }
}
 
Example 11
Source File: FaweForge.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String getName(UUID uuid) {
    try {
        GameProfile profile = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getProfileByUUID(uuid);
        return profile.getName();
    } catch (Throwable e) {
        return null;
    }
}
 
Example 12
Source File: FaweForge.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String getName(UUID uuid) {
    try {
        GameProfile profile = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getProfileByUUID(uuid);
        return profile.getName();
    } catch (Throwable e) {
        return null;
    }
}
 
Example 13
Source File: AdapterSkull.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@MultipleReturn
@ScriptCallable(returnTypes = { ReturnType.STRING, ReturnType.STRING })
public Object[] getPlayer(TileEntitySkull skull) {
	if (skull.func_145904_a() != 3) return new Object[] { null, null };

	GameProfile profile = skull.func_152108_a();
	if (profile == null) return new Object[] { null, null };

	return new Object[] { profile.getId(), profile.getName() };
}
 
Example 14
Source File: CartTools.java    From NEI-Integration with MIT License 5 votes vote down vote up
/**
 * Sets a carts owner.
 * <p/>
 * The is really only needed by the bukkit ports.
 *
 * @param cart
 * @param owner
 */
public static void setCartOwner(EntityMinecart cart, GameProfile owner) {
    if (!cart.worldObj.isRemote) {
        NBTTagCompound data = cart.getEntityData();
        if (owner.getName() != null)
            data.setString("owner", owner.getName());
        if (owner.getId() != null)
            data.setString("ownerId", owner.getId().toString());
    }
}
 
Example 15
Source File: CraftPlayerProfile.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static PlayerProfile asBukkitCopy(GameProfile gameProfile) {
    CraftPlayerProfile profile = new CraftPlayerProfile(gameProfile.getId(), gameProfile.getName());
    copyProfileProperties(gameProfile, profile.profile);
    return profile;
}
 
Example 16
Source File: NMSAuthService.java    From AlwaysOnline with GNU General Public License v2.0 3 votes vote down vote up
@Override
public GameProfile hasJoinedServer(GameProfile user, String serverId) throws AuthenticationUnavailableException {

	if (AlwaysOnline.MOJANG_OFFLINE_MODE) {

		UUID uuid = this.database.getUUID(user.getName());

		if (uuid != null) {

			return new GameProfile(uuid, user.getName());

		} else {

			SpigotLoader.getPlugin(SpigotLoader.class).log(Level.INFO, user.getName() + " " +
					"never joined this server before when mojang servers were online. Denying their access.");

			throw new AuthenticationUnavailableException("Mojang servers are offline and we can't authenticate the player with our own system.");

		}

	} else {

		return super.hasJoinedServer(user, serverId);

	}

}