use of com.mojang.authlib.exceptions.AuthenticationUnavailableException in project Krothium-Launcher by DarkLBP.
the class YggdrasilMinecraftSessionService method hasJoinedServer.
public GameProfile hasJoinedServer(GameProfile user, String serverId, InetAddress address) throws AuthenticationUnavailableException {
Map<String, Object> arguments = new HashMap();
arguments.put("username", user.getName());
arguments.put("serverId", serverId);
if (address != null) {
arguments.put("ip", address.getHostAddress());
}
URL url = HttpAuthenticationService.concatenateURL(CHECK_URL, HttpAuthenticationService.buildQuery(arguments));
try {
HasJoinedMinecraftServerResponse response = (HasJoinedMinecraftServerResponse) this.getAuthenticationService().makeRequest(url, (Object) null, HasJoinedMinecraftServerResponse.class);
if (response != null && response.getId() != null) {
GameProfile result = new GameProfile(response.getId(), user.getName());
if (response.getProperties() != null) {
result.getProperties().putAll(response.getProperties());
}
return result;
} else {
return null;
}
} catch (AuthenticationUnavailableException var8) {
throw var8;
} catch (AuthenticationException var9) {
return null;
}
}
use of com.mojang.authlib.exceptions.AuthenticationUnavailableException in project Wurst-MC-1.12 by Wurst-Imperium.
the class LoginManager method login.
public static String login(String email, String password) {
YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "").createUserAuthentication(Agent.MINECRAFT);
auth.setUsername(email);
auth.setPassword(password);
try {
auth.logIn();
Minecraft.getMinecraft().session = new Session(auth.getSelectedProfile().getName(), auth.getSelectedProfile().getId().toString(), auth.getAuthenticatedToken(), "mojang");
return "";
} catch (AuthenticationUnavailableException e) {
return "�4�lCannot contact authentication server!";
} catch (AuthenticationException e) {
e.printStackTrace();
if (e.getMessage().contains("Invalid username or password.") || e.getMessage().toLowerCase().contains("account migrated"))
return "�4�lWrong password!";
else
return "�4�lCannot contact authentication server!";
} catch (NullPointerException e) {
return "�4�lWrong password!";
}
}
Aggregations