/*
 * Copyright (c) 2015 JBYoshi
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package jbyoshi.devlauncher.auth;

import org.apache.commons.lang3.*;

import com.mojang.authlib.*;
import com.mojang.authlib.exceptions.*;

public final class AuthenticatedUser extends User {
	private final String token;
	private final String id;

	AuthenticatedUser(UserAuthentication login, UserFactory factory) {
		// If the profile is non-null, it will be complete.
		super(checkLoggedIn(login), factory);
		this.token = login.getAuthenticatedToken();
		this.id = login.getUserID();
	}

	private static GameProfile checkLoggedIn(UserAuthentication auth) {
		Validate.isTrue(auth.isLoggedIn(), "auth.logIn() was not called!");
		return auth.getSelectedProfile();
	}

	public String getAccessToken() {
		return token;
	}

	public void joinServer(String serverId) throws AuthenticationException {
		factory.sessions.joinServer(getProfile(), token, serverId);
	}

	public String getID() {
		return id;
	}
}

@@ -729,16 +729,44 @@
 ons.*;%0A%0A
+import java.util.Optional;%0A%0A
 public f
@@ -999,292 +999,256 @@
 per(
-checkLoggedIn(login), factory);%0A%09%09this.token = login.getAuthenticatedToken();%0A%09%09this.id = login.getUserID();%0A%09%7D%0A%0A%09private static GameProfile checkLoggedIn(UserAuthentication auth) %7B%0A%09%09Validate.isTrue(auth.isLoggedIn(), %22auth.logIn() was not called!%22);%0A%09%09return auth.getSelectedProfile
+Optional.of(login).filter(UserAuthentication::isLoggedIn).orElseThrow(() -%3E new IllegalArgumentException(%0A%09%09%09%09%22auth.logIn() was not called!%22)).getSelectedProfile(), factory);%0A%09%09this.token = login.getAuthenticatedToken();%0A%09%09this.id = login.getUserID
 ();%0A

Replace usage of unnecessary method with Optional.