updated loads of stuff + new themes

This commit is contained in:
The Biggest skiddd 2023-06-11 00:13:54 +02:00
parent 15c16eab3c
commit b1fda05d3a
672 changed files with 11590 additions and 525 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,130 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth;
/**
* The server Auth Points
*
* <p>
* Contains the pages url of a server
* </p>
*
* @version 1.0.4
* @author Litarvan
*/
public class AuthPoints {
/**
* The Mojang auth server auth points
*/
public static final AuthPoints NORMAL_AUTH_POINTS = new AuthPoints("authenticate", "refresh", "validate", "signout", "invalidate");
/**
* The server authenticate point
*/
private String authenticatePoint;
/**
* The server refresh point
*/
private String refreshPoint;
/**
* The server validate point
*/
private String validatePoint;
/**
* The server signout point
*/
private String signoutPoint;
/**
* The server invalidate point
*/
private String invalidatePoint;
/**
* AuthPoints constructor
*
* @param authenticatePoint
* Authenticate point
* @param refreshPoint
* Refresh point
* @param validatePoint
* Validate point
* @param signoutPoint
* Signout point
* @param invalidatePoint
* Invalidate point
*/
public AuthPoints(String authenticatePoint, String refreshPoint, String validatePoint, String signoutPoint, String invalidatePoint) {
this.authenticatePoint = authenticatePoint;
this.refreshPoint = refreshPoint;
this.validatePoint = validatePoint;
this.signoutPoint = signoutPoint;
this.invalidatePoint = invalidatePoint;
}
/**
* Returns the server authenticate point
*
* @return The authenticate point
*/
public String getAuthenticatePoint() {
return this.authenticatePoint;
}
/**
* Returns the server refresh point
*
* @return The refresh point
*/
public String getRefreshPoint() {
return this.refreshPoint;
}
/**
* Returns the server validate point
*
* @return The validate point
*/
public String getValidatePoint() {
return this.validatePoint;
}
/**
* Returns the server signout point
*
* @return The signout point
*/
public String getSignoutPoint() {
return this.signoutPoint;
}
/**
* Returns the server invalidate point
*
* @return The invalidate point
*/
public String getInvalidatePoint() {
return this.invalidatePoint;
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth;
import fr.litarvan.openauth.model.AuthError;
/**
* Authentication exceptions
*
* @version 1.0.4
* @author Litarvan
*/
public class AuthenticationException extends Exception {
/**
* The given JSON model instance of the error
*/
private AuthError model;
/**
* Create a new Authentication Exception
*
* @param model
* The given JSON model instance of the error
*/
public AuthenticationException(AuthError model) {
super(model.getErrorMessage());
this.model = model;
}
/**
* Returns the given JSON model instance of the error
*
* @return The error model
*/
public AuthError getErrorModel() {
return model;
}
}

View File

@ -0,0 +1,263 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth;
import com.google.gson.Gson;
import fr.litarvan.openauth.model.AuthAgent;
import fr.litarvan.openauth.model.request.*;
import fr.litarvan.openauth.model.response.*;
import fr.litarvan.openauth.model.AuthError;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
/**
* The Authenticator
*
* <p>
* The main class of the lib, use it to authenticate a user !
* </p>
*
* @version 1.0.4
* @author Litarvan
*/
public class Authenticator {
/**
* The Mojang official auth server
*/
public static final String MOJANG_AUTH_URL = "https://authserver.mojang.com/";
/**
* The auth server URL
*/
private String authURL;
/**
* The server auth points
*/
private AuthPoints authPoints;
/**
* Create an authenticator
*
* @param authURL
* The auth server URL
*
* @param authPoints
* The URIs of the multiple requests
*/
public Authenticator(String authURL, AuthPoints authPoints) {
this.authURL = authURL;
this.authPoints = authPoints;
}
/**
* Authenticates an user using his password.
*
* @param agent
* The auth agent (optional)
* @param username
* User mojang account name
* @param password
* User mojang account password
* @param clientToken
* The client token (optional, like a key for the access token)
*
* @throws AuthenticationException If the server returned an error as a JSON
*
* @return The response sent by the server (parsed from a JSON)
*/
public AuthResponse authenticate(AuthAgent agent, String username, String password, String clientToken) throws AuthenticationException {
AuthRequest request = new AuthRequest(agent, username, password, clientToken);
return (AuthResponse) sendRequest(request, AuthResponse.class, authPoints.getAuthenticatePoint());
}
/**
* Refresh a valid access token. It can be uses to keep a user logged in between gaming sessions
* and is preferred over storing the user's password in a file.
*
* @param accessToken
* The saved access token
* @param clientToken
* The saved client token (need to be the same used when authenticated to get the acces token)
*
* @throws AuthenticationException If the server returned an error as a JSON
*
* @return The response sent by the server (parsed from a JSON)
*/
public RefreshResponse refresh(String accessToken, String clientToken) throws AuthenticationException {
RefreshRequest request = new RefreshRequest(accessToken, clientToken);
return (RefreshResponse) sendRequest(request, RefreshResponse.class, authPoints.getRefreshPoint());
}
/**
* Check if an access token is a valid session token with a currently-active session.
* Note: this method will not respond successfully to all currently-logged-in sessions,
* just the most recently-logged-in for each user. It is intended to be used by servers to validate
* that a user should be connecting (and reject users who have logged in elsewhere since starting Minecraft),
* NOT to auth that a particular session token is valid for authentication purposes.
* To authenticate a user by session token, use the refresh verb and catch resulting errors.
*
* @param accessToken
* The access token to check
*
* @throws AuthenticationException If the server returned an error as a JSON
*/
public void validate(String accessToken) throws AuthenticationException {
ValidateRequest request = new ValidateRequest(accessToken);
sendRequest(request, null, authPoints.getValidatePoint());
}
/**
* Invalidates accessTokens using an account's username and password
*
* @param username
* User mojang account name
* @param password
* User mojang account password
*
* @throws AuthenticationException If the server returned an error as a JSON
*/
public void signout(String username, String password) throws AuthenticationException {
SignoutRequest request = new SignoutRequest(username, password);
sendRequest(request, null, authPoints.getSignoutPoint());
}
/**
* Invalidates accessTokens using a client/access token pair
*
* @param accessToken
* Valid access token to invalidate
* @param clientToken
* Client token used when authenticated to get the access token
*
* @throws AuthenticationException If the server returned an error as a JSON
*/
public void invalidate(String accessToken, String clientToken) throws AuthenticationException {
InvalidateRequest request = new InvalidateRequest(accessToken, clientToken);
sendRequest(request, null, authPoints.getInvalidatePoint());
}
/**
* Send a request to the auth server
*
* @param request
* The auth request to send
* @param model
* The model of the reponse
* @param authPoint
* The auth point of the request
* @throws AuthenticationException
* If it returned an error or the request failed
*
* @throws AuthenticationException If the server returned an error as a JSON
*
* @return Instance of the given reponse model if it not null
*/
private Object sendRequest(Object request, Class<?> model, String authPoint) throws AuthenticationException {
Gson gson = new Gson();
String response;
try {
response = sendPostRequest(this.authURL + authPoint, gson.toJson(request));
} catch (IOException e) {
throw new AuthenticationException(new AuthError("Can't send the request : " + e.getClass().getName(), e.getMessage(), "Unknown"));
}
if(model != null)
return gson.fromJson(response, model);
else
return null;
}
/**
* Sends a post request of a json
*
* @param url
* The url to send the request
* @param json
* The json to send
* @throws IOException
* If it failed
*
* @throws AuthenticationException If the request returned an error JSON or not a JSON
*
* @return The request response
*/
private String sendPostRequest(String url, String json) throws AuthenticationException, IOException {
byte[] jsonBytes = json.getBytes(StandardCharsets.UTF_8);
URL serverURL = new URL(url);
HttpURLConnection connection = (HttpURLConnection) serverURL.openConnection();
connection.setRequestMethod("POST");
// Sending post request
connection.setDoOutput(true);
connection.setRequestProperty("Accept-Charset", "UTF-8");
connection.setRequestProperty("Content-Type", "application/json;charset=utf-8");
connection.setRequestProperty("Content-Length", String.valueOf(jsonBytes.length));
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.write(jsonBytes, 0, jsonBytes.length);
wr.flush();
wr.close();
connection.connect();
int responseCode = connection.getResponseCode();
if(responseCode == 204) {
connection.disconnect();
return null;
}
InputStream is;
if(responseCode == 200)
is = connection.getInputStream();
else
is = connection.getErrorStream();
String response;
BufferedReader br = new BufferedReader(new InputStreamReader(is));
response = br.readLine();
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
connection.disconnect();
while (response != null && response.startsWith("\uFEFF"))
response = response.substring(1);
if (responseCode != 200) {
Gson gson = new Gson();
if (response != null && !response.startsWith("{"))
throw new AuthenticationException(new AuthError("Internal server error", response, "Remote"));
throw new AuthenticationException(gson.fromJson(response, AuthError.class));
}
return response;
}
}

View File

@ -0,0 +1,41 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft;
public class AuthTokens
{
private final String accessToken;
private final String refreshToken;
public AuthTokens(String accessToken, String refreshToken)
{
this.accessToken = accessToken;
this.refreshToken = refreshToken;
}
public String getAccessToken()
{
return accessToken;
}
public String getRefreshToken()
{
return refreshToken;
}
}

View File

@ -0,0 +1,166 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft;
import com.google.gson.Gson;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.util.Map;
public class HttpClient
{
public static final String MIME_TYPE_JSON = "application/json";
public static final String MIME_TYPE_URLENCODED_FORM = "application/x-www-form-urlencoded";
private final Gson gson;
public HttpClient()
{
this.gson = new Gson();
}
public String getText(String url, Map<String, String> params) throws MicrosoftAuthenticationException
{
return readResponse(createConnection(url + '?' + buildParams(params)));
}
public <T> T getJson(String url, String token, Class<T> responseClass) throws MicrosoftAuthenticationException
{
HttpsURLConnection connection = createConnection(url);
connection.addRequestProperty("Authorization", "Bearer " + token);
connection.addRequestProperty("Accept", MIME_TYPE_JSON);
return readJson(connection, responseClass);
}
public HttpsURLConnection postForm(String url, Map<String, String> params) throws MicrosoftAuthenticationException
{
return post(url, MIME_TYPE_URLENCODED_FORM, "*/*", buildParams(params));
}
public <T> T postJson(String url, Object request, Class<T> responseClass) throws MicrosoftAuthenticationException
{
HttpsURLConnection connection = post(url, MIME_TYPE_JSON, MIME_TYPE_JSON, gson.toJson(request));
return readJson(connection, responseClass);
}
public <T> T postFormGetJson(String url, Map<String, String> params, Class<T> responseClass) throws MicrosoftAuthenticationException
{
return readJson(postForm(url, params), responseClass);
}
protected HttpsURLConnection post(String url, String contentType, String accept, String data) throws MicrosoftAuthenticationException
{
HttpsURLConnection connection = createConnection(url);
connection.setDoOutput(true);
connection.addRequestProperty("Content-Type", contentType);
connection.addRequestProperty("Accept", accept);
try {
connection.setRequestMethod("POST");
connection.getOutputStream().write(data.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
throw new MicrosoftAuthenticationException(e);
}
return connection;
}
protected <T> T readJson(HttpsURLConnection connection, Class<T> responseType) throws MicrosoftAuthenticationException
{
return gson.fromJson(readResponse(connection), responseType);
}
protected String readResponse(HttpsURLConnection connection) throws MicrosoftAuthenticationException
{
String redirection = connection.getHeaderField("Location");
if (redirection != null) {
return readResponse(createConnection(redirection));
}
StringBuilder response = new StringBuilder();
try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
String line;
while ((line = br.readLine()) != null) {
response.append(line).append('\n');
}
} catch (IOException e) {
throw new MicrosoftAuthenticationException(e);
}
return response.toString();
}
protected HttpsURLConnection followRedirects(HttpsURLConnection connection) throws MicrosoftAuthenticationException
{
String redirection = connection.getHeaderField("Location");
if (redirection != null) {
connection = followRedirects(createConnection(redirection));
}
return connection;
}
protected String buildParams(Map<String, String> params)
{
StringBuilder query = new StringBuilder();
params.forEach((key, value) -> {
if (query.length() > 0) {
query.append('&');
}
try {
query.append(key).append('=').append(URLEncoder.encode(value, "UTF-8"));
} catch (UnsupportedEncodingException ignored) {
// Can't happen
}
});
return query.toString();
}
protected HttpsURLConnection createConnection(String url) throws MicrosoftAuthenticationException
{
HttpsURLConnection connection;
try {
connection = (HttpsURLConnection) new URL(url).openConnection();
} catch (IOException e) {
throw new MicrosoftAuthenticationException(e);
}
String userAgent = "Mozilla/5.0 (XboxReplay; XboxLiveAuth/3.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36";
connection.setRequestProperty("Accept-Language", "en-US");
connection.setRequestProperty("Accept-Charset", "UTF-8");
connection.setRequestProperty("User-Agent", userAgent);
return connection;
}
}

View File

@ -0,0 +1,71 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft;
import fr.litarvan.openauth.microsoft.model.response.MinecraftProfile;
/**
* Microsoft authentication result
*
* <p>
* This class contains the result of a successful Microsoft authentication: a player profile and its tokens (both
* access and refresh token).
* </p>
*
* @author Litarvan
* @version 1.1.0
*/
public class MicrosoftAuthResult
{
private final MinecraftProfile profile;
private final String accessToken;
private final String refreshToken;
public MicrosoftAuthResult(MinecraftProfile profile, String accessToken, String refreshToken)
{
this.profile = profile;
this.accessToken = accessToken;
this.refreshToken = refreshToken;
}
/**
* @return The player Minecraft profile (contains its UUID and username)
*/
public MinecraftProfile getProfile()
{
return profile;
}
/**
* @return The Minecraft access token
*/
public String getAccessToken()
{
return accessToken;
}
/**
* @return The Microsoft refresh token that can be used to log the user back silently using
* {@link MicrosoftAuthenticator#loginWithRefreshToken(String)}
*/
public String getRefreshToken()
{
return refreshToken;
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft;
import java.io.IOException;
public class MicrosoftAuthenticationException extends Exception
{
public MicrosoftAuthenticationException(String message)
{
super(message);
}
public MicrosoftAuthenticationException(IOException cause)
{
super("I/O exception thrown during Microsoft HTTP requests", cause);
}
public MicrosoftAuthenticationException(Throwable cause)
{
super(cause);
}
}

View File

@ -0,0 +1,333 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft;
/*
* Ported from the amazing work of Alexis Bize on @xboxreplay/xboxlive-auth
*
* https://github.com/Alexis-Bize
* https://github.com/XboxReplay/xboxlive-auth
*/
import fr.litarvan.openauth.microsoft.model.request.MinecraftLoginRequest;
import fr.litarvan.openauth.microsoft.model.request.XSTSAuthorizationProperties;
import fr.litarvan.openauth.microsoft.model.request.XboxLiveLoginProperties;
import fr.litarvan.openauth.microsoft.model.request.XboxLoginRequest;
import fr.litarvan.openauth.microsoft.model.response.*;
import javax.net.ssl.HttpsURLConnection;
import java.io.UnsupportedEncodingException;
import java.net.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Microsoft authenticator
*
* <p>
* This class can be used to authenticate a player using its Microsoft account.
* Use {@link #loginWithCredentials} to retrieve a player profile from his Microsoft credentials,
* or loginWithWebview to use a webview with Microsoft login form.
* </p>
*
* @version 1.1.0
* @author Litarvan
*/
public class MicrosoftAuthenticator
{
public static final String MICROSOFT_AUTHORIZATION_ENDPOINT = "https://login.live.com/oauth20_authorize.srf";
public static final String MICROSOFT_TOKEN_ENDPOINT = "https://login.live.com/oauth20_token.srf";
public static final String MICROSOFT_REDIRECTION_ENDPOINT = "https://login.live.com/oauth20_desktop.srf";
public static final String XBOX_LIVE_AUTH_HOST = "user.auth.xboxlive.com";
public static final String XBOX_LIVE_CLIENT_ID = "000000004C12AE6F";
public static final String XBOX_LIVE_SERVICE_SCOPE = "service::user.auth.xboxlive.com::MBI_SSL";
public static final String XBOX_LIVE_AUTHORIZATION_ENDPOINT = "https://user.auth.xboxlive.com/user/authenticate";
public static final String XSTS_AUTHORIZATION_ENDPOINT = "https://xsts.auth.xboxlive.com/xsts/authorize";
public static final String MINECRAFT_AUTH_ENDPOINT = "https://api.minecraftservices.com/authentication/login_with_xbox";
public static final String XBOX_LIVE_AUTH_RELAY = "http://auth.xboxlive.com";
public static final String MINECRAFT_AUTH_RELAY = "rp://api.minecraftservices.com/";
public static final String MINECRAFT_STORE_ENDPOINT = "https://api.minecraftservices.com/entitlements/mcstore";
public static final String MINECRAFT_PROFILE_ENDPOINT = "https://api.minecraftservices.com/minecraft/profile";
public static final String MINECRAFT_STORE_IDENTIFIER = "game_minecraft";
private final HttpClient http;
public MicrosoftAuthenticator()
{
this.http = new HttpClient();
}
/**
* Logs in a player using its Microsoft account credentials, and retrieve its Minecraft profile
*
* @param email Player Microsoft account e-mail
* @param password Player Microsoft account password
*
* @return The player Minecraft profile
*
* @throws MicrosoftAuthenticationException Thrown if one of the several HTTP requests failed at some point
*/
public MicrosoftAuthResult loginWithCredentials(String email, String password) throws MicrosoftAuthenticationException
{
CookieHandler currentHandler = CookieHandler.getDefault();
CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
Map<String, String> params = new HashMap<>();
params.put("login", email);
params.put("loginfmt", email);
params.put("passwd", password);
HttpsURLConnection result;
try {
PreAuthData authData = preAuthRequest();
params.put("PPFT", authData.getPPFT());
result = http.followRedirects(http.postForm(authData.getUrlPost(), params));
} finally {
CookieHandler.setDefault(currentHandler);
}
try {
return loginWithTokens(extractTokens(result.getURL().toString()));
} catch (MicrosoftAuthenticationException e) {
if (match("identity/confirm", http.readResponse(result)) != null) {
throw new MicrosoftAuthenticationException(
"User has enabled double-authentication or must allow sign-in on https://account.live.com/activity"
);
}
throw e;
}
}
// /**
// * Logs in a player using a webview to display Microsoft login page.
// * <b>This function blocks the current thread until the process is finished; this can cause your application to
// * freeze. When calling from the JavaFX thread or any thread which must not be blocked, use
// * {@link #loginWithAsyncWebview()}</b>
// *
// * @return The player Minecraft profile
// *
// * @throws MicrosoftAuthenticationException Thrown if one of the several HTTP requests failed at some point
// */
// public MicrosoftAuthResult loginWithWebview() throws MicrosoftAuthenticationException
// {
// try {
// return loginWithAsyncWebview().get();
// } catch (InterruptedException | ExecutionException e) {
// throw new MicrosoftAuthenticationException(e);
// }
// }
// /**
// * Logs in a player using a webview to display Microsoft login page. This function does not block the current thread.
// *
// * @return A future resolved by the player Minecraft profile
// */
// public CompletableFuture<MicrosoftAuthResult> loginWithAsyncWebview()
// {
// String url = String.format("%s?%s", MICROSOFT_AUTHORIZATION_ENDPOINT, http.buildParams(getLoginParams()));
// LoginFrame frame = new LoginFrame();
//
// return frame.start(url).thenApplyAsync(result -> {
// try {
// return loginWithTokens(extractTokens(result));
// } catch (MicrosoftAuthenticationException e) {
// throw new CompletionException(e);
// }
// });
// }
/*public MicrosoftAuthResult loginWithWebview() throws MicrosoftAuthenticationException
{
try {
return loginWithAsyncWebview().get();
} catch (InterruptedException | ExecutionException e) {
throw new MicrosoftAuthenticationException(e);
}
}*/
/*public CompletableFuture<MicrosoftAuthResult> loginWithAsyncWebview()
{
String url = String.format("%s?%s", MICROSOFT_AUTHORIZATION_ENDPOINT, http.buildParams(getLoginParams()));
LoginFrame frame = new LoginFrame();
return frame.start(url).thenApplyAsync(result -> {
try {
return loginWithTokens(extractTokens(result));
} catch (MicrosoftAuthenticationException e) {
throw new CompletionException(e);
}
});
}*/
/**
* Logs in a player using a Microsoft account refresh token retrieved earlier.
*
* @param refreshToken Player Microsoft account refresh token
*
* @return The player Minecraft profile
*
* @throws MicrosoftAuthenticationException Thrown if one of the several HTTP requests failed at some point
*/
public MicrosoftAuthResult loginWithRefreshToken(String refreshToken) throws MicrosoftAuthenticationException
{
Map<String, String> params = getLoginParams();
params.put("refresh_token", refreshToken);
params.put("grant_type", "refresh_token");
MicrosoftRefreshResponse response = http.postFormGetJson(
MICROSOFT_TOKEN_ENDPOINT,
params, MicrosoftRefreshResponse.class
);
return loginWithTokens(new AuthTokens(response.getAccessToken() , response.getRefreshToken()));
}
/**
* Logs in a player using a Microsoft account tokens retrieved earlier.
* <b>If the token was retrieved using Azure AAD/MSAL, it should be prefixed with d=</b>
*
* @param tokens Player Microsoft account tokens pair
*
* @return The player Minecraft profile
*
* @throws MicrosoftAuthenticationException Thrown if one of the several HTTP requests failed at some point
*/
public MicrosoftAuthResult loginWithTokens(AuthTokens tokens) throws MicrosoftAuthenticationException
{
XboxLoginResponse xboxLiveResponse = xboxLiveLogin(tokens.getAccessToken());
XboxLoginResponse xstsResponse = xstsLogin(xboxLiveResponse.getToken());
String userHash = xstsResponse.getDisplayClaims().getUsers()[0].getUserHash();
MinecraftLoginResponse minecraftResponse = minecraftLogin(userHash, xstsResponse.getToken());
MinecraftStoreResponse storeResponse = http.getJson(
MINECRAFT_STORE_ENDPOINT,
minecraftResponse.getAccessToken(),
MinecraftStoreResponse.class
);
if (Arrays.stream(storeResponse.getItems()).noneMatch(item -> item.getName().equals(MINECRAFT_STORE_IDENTIFIER))) {
throw new MicrosoftAuthenticationException("Player didn't buy Minecraft Java Edition or did not migrate its account");
}
MinecraftProfile profile = http.getJson(
MINECRAFT_PROFILE_ENDPOINT,
minecraftResponse.getAccessToken(),
MinecraftProfile.class
);
return new MicrosoftAuthResult(profile, minecraftResponse.getAccessToken(), tokens.getRefreshToken());
}
protected PreAuthData preAuthRequest() throws MicrosoftAuthenticationException
{
Map<String, String> params = getLoginParams();
params.put("display", "touch");
params.put("locale", "en");
String result = http.getText(MICROSOFT_AUTHORIZATION_ENDPOINT, params);
String ppft = match("sFTTag:'.*value=\"([^\"]*)\"", result);
String urlPost = match("urlPost: ?'(.+?(?='))", result);
return new PreAuthData(ppft, urlPost);
}
protected XboxLoginResponse xboxLiveLogin(String accessToken) throws MicrosoftAuthenticationException
{
XboxLiveLoginProperties properties = new XboxLiveLoginProperties("RPS", XBOX_LIVE_AUTH_HOST, accessToken);
XboxLoginRequest<XboxLiveLoginProperties> request = new XboxLoginRequest<>(
properties, XBOX_LIVE_AUTH_RELAY, "JWT"
);
return http.postJson(XBOX_LIVE_AUTHORIZATION_ENDPOINT, request, XboxLoginResponse.class);
}
protected XboxLoginResponse xstsLogin(String xboxLiveToken) throws MicrosoftAuthenticationException
{
XSTSAuthorizationProperties properties = new XSTSAuthorizationProperties("RETAIL", new String[] { xboxLiveToken });
XboxLoginRequest<XSTSAuthorizationProperties> request = new XboxLoginRequest<>(
properties, MINECRAFT_AUTH_RELAY, "JWT"
);
return http.postJson(XSTS_AUTHORIZATION_ENDPOINT, request, XboxLoginResponse.class);
}
protected MinecraftLoginResponse minecraftLogin(String userHash, String xstsToken) throws MicrosoftAuthenticationException
{
MinecraftLoginRequest request = new MinecraftLoginRequest(String.format("XBL3.0 x=%s;%s", userHash, xstsToken));
return http.postJson(MINECRAFT_AUTH_ENDPOINT, request, MinecraftLoginResponse.class);
}
protected Map<String, String> getLoginParams()
{
Map<String, String> params = new HashMap<>();
params.put("client_id", XBOX_LIVE_CLIENT_ID);
params.put("redirect_uri", MICROSOFT_REDIRECTION_ENDPOINT);
params.put("scope", XBOX_LIVE_SERVICE_SCOPE);
params.put("response_type", "token");
return params;
}
protected AuthTokens extractTokens(String url) throws MicrosoftAuthenticationException
{
return new AuthTokens(extractValue(url, "access_token"), extractValue(url, "refresh_token"));
}
protected String extractValue(String url, String key) throws MicrosoftAuthenticationException
{
String matched = match(key + "=([^&]*)", url);
if (matched == null) {
throw new MicrosoftAuthenticationException("Invalid credentials or tokens");
}
try {
return URLDecoder.decode(matched, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new MicrosoftAuthenticationException(e);
}
}
protected String match(String regex, String content)
{
Matcher matcher = Pattern.compile(regex).matcher(content);
if (!matcher.find()) {
return null;
}
return matcher.group(1);
}
}

View File

@ -0,0 +1,150 @@
package fr.litarvan.openauth.microsoft;
/*
* Thanks a lot to Mickaël Guessant for this trick
*
* https://github.com/mguessan
* https://github.com/mguessan/davmail/blob/master/src/java/davmail/exchange/auth/O365InteractiveAuthenticatorFrame.java
*/
import java.io.*;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
/**
* HttpURLConnection Microsoft-patched wrapped
*
* <p>
* This class serves as HttpURLConnection, but actually wraps a real one and
* patch its input to disable Microsoft meta integrity check, which can fail
* on Java >=11 on non-macOS platforms.
* </p>
*
* @version 1.1.1
* @author Litarvan
*/
public class MicrosoftPatchedHttpURLConnection extends HttpURLConnection
{
private final HttpURLConnection inner;
public MicrosoftPatchedHttpURLConnection(URL url, HttpURLConnection inner)
{
super(url);
this.inner = inner;
}
@Override
public void setRequestMethod(String method) throws ProtocolException
{
this.inner.setRequestMethod(method);
}
@Override
public void setInstanceFollowRedirects(boolean followRedirects)
{
this.inner.setInstanceFollowRedirects(followRedirects);
}
@Override
public boolean getInstanceFollowRedirects()
{
return this.inner.getInstanceFollowRedirects();
}
@Override
public String getRequestMethod()
{
return this.inner.getRequestMethod();
}
@Override
public int getResponseCode() throws IOException
{
return this.inner.getResponseCode();
}
@Override
public String getResponseMessage() throws IOException
{
return this.inner.getResponseMessage();
}
@Override
public Map<String, List<String>> getHeaderFields()
{
return this.inner.getHeaderFields();
}
@Override
public String getHeaderField(String name)
{
return this.inner.getHeaderField(name);
}
@Override
public String getHeaderField(int n)
{
return this.inner.getHeaderField(n);
}
@Override
public void disconnect()
{
this.inner.disconnect();
}
@Override
public void setDoOutput(boolean dooutput)
{
this.inner.setDoOutput(dooutput);
}
@Override
public boolean usingProxy()
{
return this.inner.usingProxy();
}
@Override
public void connect() throws IOException
{
this.inner.connect();
}
@Override
public InputStream getInputStream() throws IOException
{
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try (InputStream in = this.inner.getInputStream()) {
int n;
byte[] data = new byte[8192];
while ((n = in.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, n);
}
}
byte[] patched = buffer
.toString("UTF-8")
.replaceAll("integrity ?=", "integrity.disabled=")
.replaceAll("setAttribute\\(\"integrity\"", "setAttribute(\"integrity.disabled\"")
.getBytes(StandardCharsets.UTF_8);
return new ByteArrayInputStream(patched);
}
@Override
public OutputStream getOutputStream() throws IOException
{
return this.inner.getOutputStream();
}
@Override
public InputStream getErrorStream()
{
return this.inner.getErrorStream();
}
}

View File

@ -0,0 +1,41 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft;
public class PreAuthData
{
private final String ppft;
private final String urlPost;
public PreAuthData(String ppft, String urlPost)
{
this.ppft = ppft;
this.urlPost = urlPost;
}
public String getPPFT()
{
return ppft;
}
public String getUrlPost()
{
return urlPost;
}
}

View File

@ -0,0 +1,34 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.request;
public class MinecraftLoginRequest
{
private final String identityToken;
public MinecraftLoginRequest(String identityToken)
{
this.identityToken = identityToken;
}
public String getIdentityToken()
{
return identityToken;
}
}

View File

@ -0,0 +1,41 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.request;
public class XSTSAuthorizationProperties
{
private final String SandboxId;
private final String[] UserTokens;
public XSTSAuthorizationProperties(String SandboxId, String[] UserTokens)
{
this.SandboxId = SandboxId;
this.UserTokens = UserTokens;
}
public String getSandboxId()
{
return SandboxId;
}
public String[] getUserTokens()
{
return UserTokens;
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.request;
public class XboxLiveLoginProperties
{
private final String AuthMethod;
private final String SiteName;
private final String RpsTicket;
public XboxLiveLoginProperties(String AuthMethod, String SiteName, String RpsTicket)
{
this.AuthMethod = AuthMethod;
this.SiteName = SiteName;
this.RpsTicket = RpsTicket;
}
public String getAuthMethod()
{
return AuthMethod;
}
public String getSiteName()
{
return SiteName;
}
public String getRpsTicket()
{
return RpsTicket;
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.request;
public class XboxLoginRequest<T>
{
private final T Properties;
private final String RelyingParty;
private final String TokenType;
public XboxLoginRequest(T Properties, String RelyingParty, String TokenType)
{
this.Properties = Properties;
this.RelyingParty = RelyingParty;
this.TokenType = TokenType;
}
public T getProperties()
{
return Properties;
}
public String getSiteName()
{
return RelyingParty;
}
public String getTokenType()
{
return TokenType;
}
}

View File

@ -0,0 +1,69 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.response;
public class MicrosoftRefreshResponse
{
private final String token_type;
private final long expires_in;
private final String scope;
private final String access_token;
private final String refresh_token;
private final String user_id;
public MicrosoftRefreshResponse(String token_type, long expires_in, String scope, String access_token, String refresh_token, String user_id)
{
this.token_type = token_type;
this.expires_in = expires_in;
this.scope = scope;
this.access_token = access_token;
this.refresh_token = refresh_token;
this.user_id = user_id;
}
public String getTokenType()
{
return token_type;
}
public long getExpiresIn()
{
return expires_in;
}
public String getScope()
{
return scope;
}
public String getAccessToken()
{
return access_token;
}
public String getRefreshToken()
{
return refresh_token;
}
public String getUserId()
{
return user_id;
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.response;
public class MinecraftLoginResponse
{
private final String username;
private final String access_token;
private final String token_type;
private final long expires_in;
public MinecraftLoginResponse(String username, String access_token, String token_type, long expires_in)
{
this.username = username;
this.access_token = access_token;
this.token_type = token_type;
this.expires_in = expires_in;
}
public String getUsername()
{
return username;
}
public String getAccessToken()
{
return access_token;
}
public String getTokenType()
{
return token_type;
}
public long getExpiresIn()
{
return expires_in;
}
}

View File

@ -0,0 +1,107 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.response;
/**
* Minecraft player profile
*
* <p>
* Represents a Minecraft player profile data. UUID is {@link #id} and username is {@link #name}.
* </p>
*
* @version 1.1.0
* @author Litarvan
*/
public class MinecraftProfile
{
private final String id;
private final String name;
private final MinecraftSkin[] skins;
public MinecraftProfile(String id, String name, MinecraftSkin[] skins)
{
this.id = id;
this.name = name;
this.skins = skins;
}
/**
* @return The player Minecraft UUID
*/
public String getId()
{
return id;
}
/**
* @return The player Minecraft username
*/
public String getName()
{
return name;
}
public MinecraftSkin[] getSkins()
{
return skins;
}
public static class MinecraftSkin
{
private final String id;
private final String state;
private final String url;
private final String variant;
private final String alias;
public MinecraftSkin(String id, String state, String url, String variant, String alias)
{
this.id = id;
this.state = state;
this.url = url;
this.variant = variant;
this.alias = alias;
}
public String getId()
{
return id;
}
public String getState()
{
return state;
}
public String getUrl()
{
return url;
}
public String getVariant()
{
return variant;
}
public String getAlias()
{
return alias;
}
}
}

View File

@ -0,0 +1,70 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.response;
public class MinecraftStoreResponse
{
private final StoreProduct[] items;
private final String signature;
private final String keyId;
public MinecraftStoreResponse(StoreProduct[] items, String signature, String keyId)
{
this.items = items;
this.signature = signature;
this.keyId = keyId;
}
public StoreProduct[] getItems()
{
return items;
}
public String getSignature()
{
return signature;
}
public String getKeyId()
{
return keyId;
}
public static class StoreProduct
{
private final String name;
private final String signature;
public StoreProduct(String name, String signature)
{
this.name = name;
this.signature = signature;
}
public String getName()
{
return name;
}
public String getSignature()
{
return signature;
}
}
}

View File

@ -0,0 +1,85 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.response;
public class XboxLoginResponse
{
private final String IssueInstant;
private final String NotAfter;
private final String Token;
private final XboxLiveLoginResponseClaims DisplayClaims;
public XboxLoginResponse(String IssueInstant, String NotAfter, String Token, XboxLiveLoginResponseClaims DisplayClaims)
{
this.IssueInstant = IssueInstant;
this.NotAfter = NotAfter;
this.Token = Token;
this.DisplayClaims = DisplayClaims;
}
public String getIssueInstant()
{
return IssueInstant;
}
public String getNotAfter()
{
return NotAfter;
}
public String getToken()
{
return Token;
}
public XboxLiveLoginResponseClaims getDisplayClaims()
{
return DisplayClaims;
}
public static class XboxLiveLoginResponseClaims
{
private final XboxLiveUserInfo[] xui;
public XboxLiveLoginResponseClaims(XboxLiveUserInfo[] xui)
{
this.xui = xui;
}
public XboxLiveUserInfo[] getUsers()
{
return xui;
}
}
public static class XboxLiveUserInfo
{
private final String uhs;
public XboxLiveUserInfo(String uhs)
{
this.uhs = uhs;
}
public String getUserHash()
{
return uhs;
}
}
}

View File

@ -0,0 +1,100 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model;
/**
* JSON model of an auth agent
*
* @version 1.0.4
* @author Litarvan
*/
public class AuthAgent {
/**
* The Minecraft auth agent
*/
public static final AuthAgent MINECRAFT = new AuthAgent("Minecraft", 1);
/**
* The Scroll auth agent
*/
public static final AuthAgent SCROLLS = new AuthAgent("Scrolls", 1);
/**
* The agent name
*/
private String name;
/**
* The agent version
*/
private int version;
/**
* Agent constructor
*
* @param name
* The name of the agent
* @param version
* The version of the agent (1 by default)
*/
public AuthAgent(String name, int version) {
this.name = name;
this.version = version;
}
/**
* Sets a new name
*
* @param name
* The new name
*/
public void setName(String name) {
this.name = name;
}
/**
* Returns the name of the agent
*
* @return The agent name
*/
public String getName() {
return this.name;
}
/**
* Sets a new version
*
* @param version
* The new version
*/
public void setVersion(int version) {
this.version = version;
}
/**
* Returns the version of the agent
*
* @return The agent version
*/
public int getVersion() {
return this.version;
}
}

View File

@ -0,0 +1,87 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model;
/**
* JSON model of an error
*
* @version 1.0.4
* @author Litarvan
*/
public class AuthError {
/**
* Short description of the error
*/
private String error;
/**
* Longer description wich can be shown to the user
*/
private String errorMessage;
/**
* Cause of the error (optional)
*/
private String cause;
/**
* Auth Error constructor
*
* @param error
* Short description of the error
* @param errorMessage
* Longer description wich can be shown to the user
* @param cause
* Cause of the error
*/
public AuthError(String error, String errorMessage, String cause) {
this.error = error;
this.errorMessage = errorMessage;
this.cause = cause;
}
/**
* Returns the error (Short description of the error)
*
* @return The error
*/
public String getError() {
return error;
}
/**
* Returns the error message (Longer description of the error)
*
* @return The error message
*/
public String getErrorMessage() {
return this.errorMessage;
}
/**
* Returns the cause of the error
*
* @return The cause
*/
public String getCause() {
return cause;
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model;
/**
* JSON model of a profile
*
* @version 1.0.4
* @author Litarvan
*/
public class AuthProfile {
/**
* The profile name
*/
private String name;
/**
* The profile UUID
*/
private String id;
/**
* Blank auth profile
*/
public AuthProfile() {
this.name = "";
this.id = "";
}
/**
* Normal auth profile
*
* @param name
* The profile name
* @param id
* The profile UUID
*/
public AuthProfile(String name, String id) {
this.name = name;
this.id = id;
}
/**
* Returns the name of the profile
*
* @return The profile name
*/
public String getName() {
return this.name;
}
/**
* Returns the profile UUID
*
* @return The profile UUID
*/
public String getId() {
return this.id;
}
}

View File

@ -0,0 +1,146 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model.request;
import fr.litarvan.openauth.model.AuthAgent;
/**
* JSON Model of an authentication request
*
* @version 1.0.4
* @author Litarvan
*/
public class AuthRequest {
/**
* The authentication agent (Optional, the game profile you want to use, Minecraft, Scrolls, etc...)
*/
private AuthAgent agent;
/**
* The username (The username of the player you want to authenticate)
*/
private String username;
/**
* The password (The password of the player you want to authenticate)
*/
private String password;
/**
* The client token (Optional, it's like a password for the access token)
*/
private String clientToken;
/**
* Authentication Request
*
* @param agent
* The authentication agent (Optional, the game you want to use, Minecraft, Scrolls, etc...)
* @param username
* The username (The username of the player you want to authenticate)
* @param password
* The password (The password of the player you want to authenticate)
* @param clientToken
* The client token (Optional, It's like a password for the access token)
*/
public AuthRequest(AuthAgent agent, String username, String password, String clientToken) {
this.agent = agent;
this.username = username;
this.password = password;
this.clientToken = clientToken;
}
/**
* Sets a new authentication agent (Optional, the game you want to use, Minecraft, Scrolls, etc...)
*
* @param agent
* The new agent
*/
public void setAgent(AuthAgent agent) {
this.agent = agent;
}
/**
* Returns the authentication agent (Given with the constructor or the setter)
*
* @return The given auth agent
*/
public AuthAgent getAgent() {
return this.agent;
}
/**
* Sets a new username (The username of the player you want to authenticate)
*
* @param username
* The new username
*/
public void setUsername(String username) {
this.username = username;
}
/**
* Returns the username (Given with the constructor or the setter)
*
* @return The given username
*/
public String getUsername() {
return this.username;
}
/**
* Sets a new password (The password of the player you want to authenticate)
*
* @param password
* The new password
*/
public void setPassword(String password) {
this.password = password;
}
/**
* Returns the password (Given with the constructor or the setter)
*
* @return The given password
*/
public String getPassword() {
return this.password;
}
/**
* Sets a new client token (It's like a password for the access token)
*
* @param clientToken
* The new client token
*/
public void setClientToken(String clientToken) {
this.clientToken = clientToken;
}
/**
* Returns the client token (Given with the constructor or the setter)
*
* @return The given client token
*/
public String getClientToken() {
return clientToken;
}
}

View File

@ -0,0 +1,90 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model.request;
/**
* JSON Model of an invalidate request
*
* @version 1.0.4
* @author Litarvan
*/
public class InvalidateRequest {
/**
* The access token you want to invalidate
*/
private String accessToken;
/**
* The client token associated with the access token
*/
private String clientToken;
/**
* Invalidate Request constructor
*
* @param accessToken
* The access token you want to invalidate
* @param clientToken
* The client token associated with the access token
*/
public InvalidateRequest(String accessToken, String clientToken) {
this.accessToken = accessToken;
this.clientToken = clientToken;
}
/**
* Sets a new access token (That you want to invalidate)
*
* @param accessToken
* The new access token
*/
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
/**
* Returns the access token (Given by the constructor or the setter)
*
* @return The given access token
*/
public String getAccessToken() {
return this.accessToken;
}
/**
* Sets a new client token (Need to be associated with the access token)
*
* @param clientToken
* The new client token
*/
public void setClientToken(String clientToken) {
this.clientToken = clientToken;
}
/**
* Returns the client token (Given by the constructor or the setter)
*
* @return The given client token
*/
public String getClientToken() {
return clientToken;
}
}

View File

@ -0,0 +1,90 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model.request;
/**
* JSON model of a refresh request
*
* @version 1.0.4
* @author Litarvan
*/
public class RefreshRequest {
/**
* The saved access token that you want to refresh
*/
private String accessToken;
/**
* The saved client token associated with the access token
*/
private String clientToken;
/**
* Refresh Request constructor
*
* @param accessToken
* The saved access token that you want to refresh
* @param clientToken
* The saved client token associated with the access token
*/
public RefreshRequest(String accessToken, String clientToken) {
this.accessToken = accessToken;
this.clientToken = clientToken;
}
/**
* Sets a new access token (That you want to refresh)
*
* @param accessToken
* The new access token
*/
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
/**
* Returns the access token (Given by the constructor or the setter)
*
* @return The given access token
*/
public String getAccessToken() {
return this.accessToken;
}
/**
* Sets a new client token (Need to be associated with the access token)
*
* @param clientToken
* The new client token
*/
public void setClientToken(String clientToken) {
this.clientToken = clientToken;
}
/**
* Returns the client token (Given by the constructor or the setter)
*
* @return The given client token
*/
public String getClientToken() {
return this.clientToken;
}
}

View File

@ -0,0 +1,90 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model.request;
/**
* JSON Model of an signout request
*
* @version 1.0.4
* @author Litarvan
*/
public class SignoutRequest {
/**
* The username of the player that you want to signout
*/
private String username;
/**
* The password of the player that you want to signout
*/
private String password;
/**
* Signout Request constructor
*
* @param username
* The username of the player that you want to signout
* @param password
* The password of the player that you want to signout
*/
public SignoutRequest(String username, String password) {
this.username = username;
this.password = password;
}
/**
* Sets a new username (Of the player that you want to signout)
*
* @param username
* The new username
*/
public void setUsername(String username) {
this.username = username;
}
/**
* Returns the username (Given by the constructor or the setter)
*
* @return The given username
*/
public String getUsername() {
return this.username;
}
/**
* Sets a new password (Of the player that you want to signout)
*
* @param password
* The new password
*/
public void setPassword(String password) {
this.password = password;
}
/**
* Returns the password (Given by the constructor or the setter)
*
* @return The given password
*/
public String getPassword() {
return password;
}
}

View File

@ -0,0 +1,63 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model.request;
/**
* JSON Model of an validate request
*
* @version 1.0.4
* @author Litarvan
*/
public class ValidateRequest {
/**
* The access token that you want to validate
*/
private String accessToken;
/**
* Validate Request constructor
*
* @param accessToken
* The access token that you want to validate
*/
public ValidateRequest(String accessToken) {
this.accessToken = accessToken;
}
/**
* Sets a new access token
*
* @param accessToken
* The new access token
*/
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
/**
* Returns the access token (Given by the constructor or the setter)
*
* @return The given access token
*/
public String getAccessToken() {
return accessToken;
}
}

View File

@ -0,0 +1,106 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model.response;
import fr.litarvan.openauth.model.AuthProfile;
/**
* JSON Model of an authentication response
*
* @version 1.0.4
* @author Litarvan
*/
public class AuthResponse {
/**
* The access token
*/
private String accessToken;
/**
* The client token (same as the one given by the request)
*/
private String clientToken;
/**
* All available profiles
*/
private AuthProfile[] availableProfiles;
/**
* The current selected profile from the agent
*/
private AuthProfile selectedProfile;
/**
* Auth Response constructor
*
* @param accessToken
* The access token
* @param clientToken
* The client token (same as the one given by the request)
* @param availableProfiles
* All available profiles
* @param selectedProfile
* The current selected profile from the agent
*/
public AuthResponse(String accessToken, String clientToken, AuthProfile[] availableProfiles, AuthProfile selectedProfile) {
this.accessToken = accessToken;
this.clientToken = clientToken;
this.availableProfiles = availableProfiles;
this.selectedProfile = selectedProfile;
}
/**
* Returns the access token
*
* @return The access token
*/
public String getAccessToken() {
return this.accessToken;
}
/**
* Returns the client token (same as the one given by the request)
*
* @return The client token
*/
public String getClientToken() {
return this.clientToken;
}
/**
* Returns the available profiles
*
* @return The available profiles
*/
public AuthProfile[] getAvailableProfiles() {
return this.availableProfiles;
}
/**
* Returns the selected profile from the agent
*
* @return The selected profile
*/
public AuthProfile getSelectedProfile() {
return this.selectedProfile;
}
}

View File

@ -0,0 +1,91 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model.response;
import fr.litarvan.openauth.model.AuthProfile;
/**
* JSON Model of an refresh response
*
* @version 1.0.4
* @author Litarvan
*/
public class RefreshResponse {
/**
* The access token (not the same as the one given by the request)
*/
private String accessToken;
/**
* The client token (same as the one given by the request)
*/
private String clientToken;
/**
* The selected profile
*/
private AuthProfile selectedProfile;
/**
* Refresh Response constructor
*
* @param accessToken
* The access token (not the same as the one given by the request)
* @param clientToken
* The client token (same as the one given by the request)
* @param selectedProfile
* The profile selected (depending of the sent AuthAgent) containing
* more information about the agent (the game) selected, like the
* username for Minecraft
*/
public RefreshResponse(String accessToken, String clientToken, AuthProfile selectedProfile) {
this.accessToken = accessToken;
this.clientToken = clientToken;
this.selectedProfile = selectedProfile;
}
/**
* Returns the access token (not the same as the one given by the request)
*
* @return The access token
*/
public String getAccessToken() {
return accessToken;
}
/**
* Returns the client token (same as the one given by the request)
*
* @return The client token
*/
public String getClientToken() {
return clientToken;
}
/**
* Returns the selected profile
*
* @return The selected profile
*/
public AuthProfile getSelectedProfile() {
return selectedProfile;
}
}

View File

@ -196,6 +196,7 @@ import rip.athena.client.events.types.render.RenderEvent;
import rip.athena.client.events.types.render.RenderType; import rip.athena.client.events.types.render.RenderType;
import rip.athena.client.gui.menu.AthenaMenu; import rip.athena.client.gui.menu.AthenaMenu;
import rip.athena.client.modules.impl.fpssettings.OptimizerMod; import rip.athena.client.modules.impl.fpssettings.OptimizerMod;
import rip.athena.client.modules.impl.mods.HitDelayFix;
public class Minecraft implements IThreadListener, IPlayerUsage public class Minecraft implements IThreadListener, IPlayerUsage
{ {
@ -1536,9 +1537,13 @@ public class Minecraft implements IThreadListener, IPlayerUsage
if (this.playerController.isNotCreative()) if (this.playerController.isNotCreative())
{ {
if(Athena.INSTANCE.getModuleManager().get(HitDelayFix.class).isToggled()) {
this.leftClickCounter = 0;
} else {
this.leftClickCounter = 10; this.leftClickCounter = 10;
} }
} }
}
else else
{ {
switch (this.objectMouseOver.typeOfHit) switch (this.objectMouseOver.typeOfHit)
@ -3182,7 +3187,7 @@ public class Minecraft implements IThreadListener, IPlayerUsage
} }
else else
{ {
GuiStreamUnavailable.func_152321_a(this.currentScreen); //GuiStreamUnavailable.func_152321_a(this.currentScreen);
} }
} }
else if (i == this.gameSettings.keyBindStreamPauseUnpause.getKeyCode()) else if (i == this.gameSettings.keyBindStreamPauseUnpause.getKeyCode())

View File

@ -42,15 +42,11 @@ import net.minecraft.potion.Potion;
import net.minecraft.stats.StatBase; import net.minecraft.stats.StatBase;
import net.minecraft.stats.StatFileWriter; import net.minecraft.stats.StatFileWriter;
import net.minecraft.tileentity.TileEntitySign; import net.minecraft.tileentity.TileEntitySign;
import net.minecraft.util.BlockPos; import net.minecraft.util.*;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.MovementInput;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IInteractionObject; import net.minecraft.world.IInteractionObject;
import net.minecraft.world.World; import net.minecraft.world.World;
import rip.athena.client.Athena;
import rip.athena.client.modules.impl.mods.ToggleSprint;
public class EntityPlayerSP extends AbstractClientPlayer public class EntityPlayerSP extends AbstractClientPlayer
{ {
@ -783,7 +779,12 @@ public class EntityPlayerSP extends AbstractClientPlayer
boolean flag1 = this.movementInput.sneak; boolean flag1 = this.movementInput.sneak;
float f = 0.8F; float f = 0.8F;
boolean flag2 = this.movementInput.moveForward >= f; boolean flag2 = this.movementInput.moveForward >= f;
if(Athena.INSTANCE.getModuleManager().get(ToggleSprint.class).isToggled()) {
ToggleSprint.update(mc, (MovementInputFromOptions) this.movementInput, this);
} else {
this.movementInput.updatePlayerMoveState(); this.movementInput.updatePlayerMoveState();
}
if (this.isUsingItem() && !this.isRiding()) if (this.isUsingItem() && !this.isRiding())
{ {
@ -820,17 +821,25 @@ public class EntityPlayerSP extends AbstractClientPlayer
this.setSprinting(false); this.setSprinting(false);
} }
if (this.capabilities.allowFlying) if(Athena.INSTANCE.getModuleManager().get(ToggleSprint.class).isToggled()) {
if(ToggleSprint.optionEnableFlyBoost && this.capabilities.isFlying && ToggleSprint.sprint)
{ {
if (this.mc.playerController.isSpectatorMode()) if(ToggleSprint.sprint && ToggleSprint.optionEnableFlyBoost) {
{ this.capabilities.setFlySpeed(0.05F * (float) ToggleSprint.flyboostspeedHorizontal);
if (!this.capabilities.isFlying) if(this.movementInput.sneak) this.motionY -= 0.15D * (double) ToggleSprint.flyboostspeedVertical;
{ if(this.movementInput.jump) this.motionY += 0.15D * (double) ToggleSprint.flyboostspeedVertical;
this.capabilities.isFlying = true; } else if(!ToggleSprint.optionEnableFlyBoost && this.mc.gameSettings.keyBindSprint.isKeyDown()) {
this.sendPlayerAbilities(); this.capabilities.setFlySpeed(0.05F * (float) ToggleSprint.flyboostspeedHorizontal);
if(this.movementInput.sneak) this.motionY -= 0.15D * (double) ToggleSprint.flyboostspeedVertical;
if(this.movementInput.jump) this.motionY += 0.15D * (double) ToggleSprint.flyboostspeedVertical;
} }
} }
else if (!flag && this.movementInput.jump) else if(this.capabilities.getFlySpeed() != 0.05F)
{
this.capabilities.setFlySpeed(0.05F);
}
if(this.capabilities.allowFlying && !isJumping && this.movementInput.jump)
{ {
if(this.flyToggleTimer == 0) if(this.flyToggleTimer == 0)
{ {
@ -843,20 +852,46 @@ public class EntityPlayerSP extends AbstractClientPlayer
this.flyToggleTimer = 0; this.flyToggleTimer = 0;
} }
} }
}
if (this.capabilities.isFlying && this.isCurrentViewEntity()) if(this.capabilities.isFlying)
{ {
if(this.movementInput.sneak) if(this.movementInput.sneak)
{ {
this.motionY -= 0.15D;
}
if(this.movementInput.jump)
{
this.motionY += 0.15D;
}
}
} else {
if (this.capabilities.allowFlying) {
if (this.mc.playerController.isSpectatorMode()) {
if (!this.capabilities.isFlying) {
this.capabilities.isFlying = true;
this.sendPlayerAbilities();
}
} else if (!flag && this.movementInput.jump) {
if (this.flyToggleTimer == 0) {
this.flyToggleTimer = 7;
} else {
this.capabilities.isFlying = !this.capabilities.isFlying;
this.sendPlayerAbilities();
this.flyToggleTimer = 0;
}
}
}
if (this.capabilities.isFlying && this.isCurrentViewEntity()) {
if (this.movementInput.sneak) {
this.motionY -= (double) (this.capabilities.getFlySpeed() * 3.0F); this.motionY -= (double) (this.capabilities.getFlySpeed() * 3.0F);
} }
if (this.movementInput.jump) if (this.movementInput.jump) {
{
this.motionY += (double) (this.capabilities.getFlySpeed() * 3.0F); this.motionY += (double) (this.capabilities.getFlySpeed() * 3.0F);
} }
} }
}
if (this.isRidingHorse()) if (this.isRidingHorse())
{ {

View File

@ -27,6 +27,8 @@ import optifine.FontUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import rip.athena.client.Athena;
import rip.athena.client.modules.impl.other.NickHider;
public class FontRenderer implements IResourceManagerReloadListener public class FontRenderer implements IResourceManagerReloadListener
{ {
@ -433,6 +435,16 @@ public class FontRenderer implements IResourceManagerReloadListener
*/ */
private void renderStringAtPos(String p_78255_1_, boolean p_78255_2_) private void renderStringAtPos(String p_78255_1_, boolean p_78255_2_)
{ {
NickHider mod = (NickHider) Athena.INSTANCE.getModuleManager().get(NickHider.class);
if(Athena.INSTANCE.getModuleManager().get(NickHider.class).isToggled()) {
if(Minecraft.getMinecraft().thePlayer != null) {
if (p_78255_1_.contains(Minecraft.getMinecraft().thePlayer.getName())) {
p_78255_1_ = p_78255_1_.replace(Minecraft.getMinecraft().thePlayer.getName(), mod.nick);
}
}
}
for (int i = 0; i < p_78255_1_.length(); ++i) for (int i = 0; i < p_78255_1_.length(); ++i)
{ {
char c0 = p_78255_1_.charAt(i); char c0 = p_78255_1_.charAt(i);
@ -654,6 +666,16 @@ public class FontRenderer implements IResourceManagerReloadListener
*/ */
public int getStringWidth(String text) public int getStringWidth(String text)
{ {
NickHider mod = (NickHider) Athena.INSTANCE.getModuleManager().get(NickHider.class);
if (Athena.INSTANCE.getModuleManager().get(NickHider.class).isToggled()) {
if (Minecraft.getMinecraft().thePlayer != null) {
if (text.contains(Minecraft.getMinecraft().thePlayer.getName())) {
text = text.replace(Minecraft.getMinecraft().thePlayer.getName(), mod.nick);
}
}
}
if (text == null) if (text == null)
{ {
return 0; return 0;

View File

@ -7,6 +7,8 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import static org.lwjgl.opengl.GL11.*;
public class Gui public class Gui
{ {
public static final ResourceLocation optionsBackground = new ResourceLocation("textures/gui/options_background.png"); public static final ResourceLocation optionsBackground = new ResourceLocation("textures/gui/options_background.png");
@ -44,6 +46,28 @@ public class Gui
drawRect(x, startY + 1, x + 1, endY, color); drawRect(x, startY + 1, x + 1, endY, color);
} }
public static void drawRect2(double x, double y, double width, double height, int color) {
GlStateManager.color(1,1,1,1);
GlStateManager.enableAlpha();
GlStateManager.alphaFunc(GL_GREATER, (float) (0 * .01));
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.disableTexture2D();
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
worldrenderer.begin(GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
worldrenderer.pos(x, y, 0.0D).color(color).endVertex();
worldrenderer.pos(x, y + height, 0.0D).color(color).endVertex();
worldrenderer.pos(x + width, y + height, 0.0D).color(color).endVertex();
worldrenderer.pos(x + width, y, 0.0D).color(color).endVertex();
tessellator.draw();
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
}
/** /**
* Draws a solid color rectangle with the specified coordinates and color (ARGB format). Args: x1, y1, x2, y2, color * Draws a solid color rectangle with the specified coordinates and color (ARGB format). Args: x1, y1, x2, y2, color
*/ */

View File

@ -5,7 +5,9 @@ import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.audio.SoundHandler; import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import rip.athena.client.Athena;
import rip.athena.client.font.FontManager; import rip.athena.client.font.FontManager;
import rip.athena.client.utils.render.ColorUtil;
import rip.athena.client.utils.render.DrawUtils; import rip.athena.client.utils.render.DrawUtils;
import rip.athena.client.utils.render.RoundedUtils; import rip.athena.client.utils.render.RoundedUtils;
@ -98,7 +100,8 @@ public class GuiButton extends Gui
int j = 14737632; int j = 14737632;
RoundedUtils.drawRoundedRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, 12, hovered ? new Color(200,200,200,100).getRGB() : new Color(100,100,100,100).getRGB()); RoundedUtils.drawRoundedRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, 12, hovered ? new Color(200,200,200,100).getRGB() : new Color(100,100,100,100).getRGB());
RoundedUtils.drawRoundedRect(this.xPosition + 1, this.yPosition + 1, (this.xPosition + this.width) - 1, (this.yPosition + this.height) - 1, 12, new Color(22, 24, 27,100).getRGB()); RoundedUtils.drawGradientRound(this.xPosition + 1, this.yPosition + 1, (this.width) - 1, (this.height) - 1, 6, ColorUtil.getClientColor(0, 255), ColorUtil.getClientColor(90, 255), ColorUtil.getClientColor(180, 255), ColorUtil.getClientColor(270, 255));
//RoundedUtils.drawRoundedRect(this.xPosition + 1, this.yPosition + 1, (this.xPosition + this.width) - 1, (this.yPosition + this.height) - 1, 12, new Color(22, 24, 27,100).getRGB());
if (!this.enabled) if (!this.enabled)

View File

@ -11,6 +11,7 @@ import net.minecraft.util.IChatComponent;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import rip.athena.client.Athena;
import rip.athena.client.font.FontManager; import rip.athena.client.font.FontManager;
import rip.athena.client.modules.impl.render.Chat; import rip.athena.client.modules.impl.render.Chat;
@ -85,11 +86,7 @@ public class GuiNewChat extends Gui
String s = chatline.getChatComponent().getFormattedText(); String s = chatline.getChatComponent().getFormattedText();
GlStateManager.color(1,1,1); GlStateManager.color(1,1,1);
GlStateManager.enableBlend(); GlStateManager.enableBlend();
if(Chat.customFont) {
rip.athena.client.utils.font.FontManager.getProductSansRegular(30).drawStringWithShadow(s, (float) i2, (float) (j2 - 10), 16777215 + (l1 << 24));
} else {
this.mc.fontRendererObj.drawStringWithShadow(s, (float) i2, (float) (j2 - 8), 16777215 + (l1 << 24)); this.mc.fontRendererObj.drawStringWithShadow(s, (float) i2, (float) (j2 - 8), 16777215 + (l1 << 24));
}
GlStateManager.disableAlpha(); GlStateManager.disableAlpha();
GlStateManager.disableBlend(); GlStateManager.disableBlend();
} }
@ -175,12 +172,15 @@ public class GuiNewChat extends Gui
{ {
this.chatLines.add(0, new ChatLine(p_146237_3_, p_146237_1_, p_146237_2_)); this.chatLines.add(0, new ChatLine(p_146237_3_, p_146237_1_, p_146237_2_));
while (this.chatLines.size() > 100) Chat mod = (Chat) Athena.INSTANCE.getModuleManager().get(Chat.class);
{
if(!mod.isToggled() && !mod.infiniteChat) {
while (this.chatLines.size() > 100) {
this.chatLines.remove(this.chatLines.size() - 1); this.chatLines.remove(this.chatLines.size() - 1);
} }
} }
} }
}
public void refreshChat() public void refreshChat()
{ {

View File

@ -214,11 +214,11 @@ public class GuiOptions extends GuiScreen implements GuiYesNoCallback
if (istream.func_152936_l() && istream.func_152928_D()) if (istream.func_152936_l() && istream.func_152928_D())
{ {
this.mc.displayGuiScreen(new GuiStreamOptions(this, this.game_settings_1)); //this.mc.displayGuiScreen(new GuiStreamOptions(this, this.game_settings_1));
} }
else else
{ {
GuiStreamUnavailable.func_152321_a(this); //GuiStreamUnavailable.func_152321_a(this);
} }
} }
} }

View File

@ -33,8 +33,8 @@ public class GuiStreamOptions extends GuiScreen
public void initGui() public void initGui()
{ {
int i = 0; int i = 0;
this.field_152319_i = I18n.format("options.stream.title", new Object[0]); //this.field_152319_i = I18n.format("options.stream.title", new Object[0]);
this.field_152313_r = I18n.format("options.stream.chat.title", new Object[0]); //this.field_152313_r = I18n.format("options.stream.chat.title", new Object[0]);
for (GameSettings.Options gamesettings$options : field_152312_a) for (GameSettings.Options gamesettings$options : field_152312_a)
{ {

View File

@ -28,6 +28,8 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldSettings; import net.minecraft.world.WorldSettings;
import rip.athena.client.Athena;
import rip.athena.client.events.types.entity.AttackEntityEvent;
public class PlayerControllerMP public class PlayerControllerMP
{ {
@ -490,6 +492,8 @@ public class PlayerControllerMP
*/ */
public void attackEntity(EntityPlayer playerIn, Entity targetEntity) public void attackEntity(EntityPlayer playerIn, Entity targetEntity)
{ {
if(!Athena.INSTANCE.getEventBus().post(new AttackEntityEvent(playerIn, targetEntity))) return;
this.syncCurrentPlayItem(); this.syncCurrentPlayItem();
this.netClientHandler.addToSendQueue(new C02PacketUseEntity(targetEntity, C02PacketUseEntity.Action.ATTACK)); this.netClientHandler.addToSendQueue(new C02PacketUseEntity(targetEntity, C02PacketUseEntity.Action.ATTACK));

View File

@ -87,10 +87,7 @@ import org.lwjgl.util.glu.Project;
import rip.athena.client.Athena; import rip.athena.client.Athena;
import rip.athena.client.events.types.render.RenderEvent; import rip.athena.client.events.types.render.RenderEvent;
import rip.athena.client.events.types.render.RenderType; import rip.athena.client.events.types.render.RenderType;
import rip.athena.client.modules.impl.mods.NoHurtCam; import rip.athena.client.modules.impl.mods.*;
import rip.athena.client.modules.impl.mods.Zoom;
import rip.athena.client.modules.impl.mods.Freelook;
import rip.athena.client.modules.impl.mods.OldAnimations;
import shadersmod.client.Shaders; import shadersmod.client.Shaders;
import shadersmod.client.ShadersRender; import shadersmod.client.ShadersRender;
@ -941,8 +938,13 @@ public class EntityRenderer implements IResourceManagerReloadListener
if (this.mc.gameSettings.viewBobbing) if (this.mc.gameSettings.viewBobbing)
{ {
MinimalBobbing module = (MinimalBobbing) Athena.INSTANCE.getModuleManager().get(MinimalBobbing.class);
if(Athena.INSTANCE.getModuleManager().get(MinimalBobbing.class).isToggled() && module.screenBobbing) {
} else {
this.setupViewBobbing(partialTicks); this.setupViewBobbing(partialTicks);
} }
//this.setupViewBobbing(partialTicks);
}
float f1 = this.mc.thePlayer.prevTimeInPortal + (this.mc.thePlayer.timeInPortal - this.mc.thePlayer.prevTimeInPortal) * partialTicks; float f1 = this.mc.thePlayer.prevTimeInPortal + (this.mc.thePlayer.timeInPortal - this.mc.thePlayer.prevTimeInPortal) * partialTicks;
@ -1040,8 +1042,12 @@ public class EntityRenderer implements IResourceManagerReloadListener
if (this.mc.gameSettings.viewBobbing) if (this.mc.gameSettings.viewBobbing)
{ {
MinimalBobbing module = (MinimalBobbing) Athena.INSTANCE.getModuleManager().get(MinimalBobbing.class);
if(Athena.INSTANCE.getModuleManager().get(MinimalBobbing.class).isToggled() && module.handBobbing) {
} else {
this.setupViewBobbing(p_renderHand_1_); this.setupViewBobbing(p_renderHand_1_);
} }
}
flag = this.mc.getRenderViewEntity() instanceof EntityLivingBase && ((EntityLivingBase)this.mc.getRenderViewEntity()).isPlayerSleeping(); flag = this.mc.getRenderViewEntity() instanceof EntityLivingBase && ((EntityLivingBase)this.mc.getRenderViewEntity()).isPlayerSleeping();
boolean flag1 = !ReflectorForge.renderFirstPersonHand(this.mc.renderGlobal, p_renderHand_1_, p_renderHand_2_); boolean flag1 = !ReflectorForge.renderFirstPersonHand(this.mc.renderGlobal, p_renderHand_1_, p_renderHand_2_);
@ -1080,8 +1086,13 @@ public class EntityRenderer implements IResourceManagerReloadListener
if (this.mc.gameSettings.viewBobbing) if (this.mc.gameSettings.viewBobbing)
{ {
MinimalBobbing module = (MinimalBobbing) Athena.INSTANCE.getModuleManager().get(MinimalBobbing.class);
if(Athena.INSTANCE.getModuleManager().get(MinimalBobbing.class).isToggled() && module.handBobbing) {
} else {
this.setupViewBobbing(p_renderHand_1_); this.setupViewBobbing(p_renderHand_1_);
} }
//this.setupViewBobbing(p_renderHand_1_);
}
} }
} }

View File

@ -484,6 +484,10 @@ public class WorldRenderer
return this.color((int)(p_181666_1_ * 255.0F), (int)(p_181666_2_ * 255.0F), (int)(p_181666_3_ * 255.0F), (int)(p_181666_4_ * 255.0F)); return this.color((int)(p_181666_1_ * 255.0F), (int)(p_181666_2_ * 255.0F), (int)(p_181666_3_ * 255.0F), (int)(p_181666_4_ * 255.0F));
} }
public WorldRenderer color(int colorHex) {
return this.color(colorHex >> 16 & 255, colorHex >> 8 & 255, colorHex & 255, colorHex >> 24 & 255);
}
public WorldRenderer color(int p_181669_1_, int p_181669_2_, int p_181669_3_, int p_181669_4_) public WorldRenderer color(int p_181669_1_, int p_181669_2_, int p_181669_3_, int p_181669_4_)
{ {
if (this.needsUpdate) if (this.needsUpdate)

View File

@ -23,6 +23,8 @@ import net.minecraft.world.World;
import optifine.Config; import optifine.Config;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import rip.athena.client.Athena;
import rip.athena.client.modules.impl.other.NickHider;
import rip.athena.client.socket.SocketClient; import rip.athena.client.socket.SocketClient;
import shadersmod.client.Shaders; import shadersmod.client.Shaders;
@ -348,6 +350,7 @@ public abstract class Render<T extends Entity>
*/ */
protected void renderLivingLabel(T entityIn, String str, double x, double y, double z, int maxDistance) protected void renderLivingLabel(T entityIn, String str, double x, double y, double z, int maxDistance)
{ {
double d0 = entityIn.getDistanceSqToEntity(this.renderManager.livingPlayer); double d0 = entityIn.getDistanceSqToEntity(this.renderManager.livingPlayer);
if (d0 <= (double)(maxDistance * maxDistance)) if (d0 <= (double)(maxDistance * maxDistance))

View File

@ -31,6 +31,7 @@ import org.apache.logging.log4j.Logger;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import rip.athena.client.Athena; import rip.athena.client.Athena;
import rip.athena.client.events.types.render.RenderEntityEvent; import rip.athena.client.events.types.render.RenderEntityEvent;
import rip.athena.client.modules.impl.other.NickHider;
import rip.athena.client.modules.impl.other.Settings; import rip.athena.client.modules.impl.other.Settings;
import rip.athena.client.modules.impl.render.CustomHitColor; import rip.athena.client.modules.impl.render.CustomHitColor;
import shadersmod.client.Shaders; import shadersmod.client.Shaders;
@ -553,8 +554,8 @@ public abstract class RendererLivingEntity<T extends EntityLivingBase> extends R
{ {
Settings settings = (Settings) Athena.INSTANCE.getModuleManager().get(Settings.class); Settings settings = (Settings) Athena.INSTANCE.getModuleManager().get(Settings.class);
if (this.canRenderName(entity) || settings.F5Nametags && entity instanceof EntityPlayer && entity == Minecraft.getMinecraft().thePlayer) if (this.canRenderName(entity) || settings.F5Nametags && entity instanceof EntityPlayer && entity == Minecraft.getMinecraft().thePlayer) {
{
double d0 = entity.getDistanceSqToEntity(this.renderManager.livingPlayer); double d0 = entity.getDistanceSqToEntity(this.renderManager.livingPlayer);
float f = entity.isSneaking() ? NAME_TAG_RANGE_SNEAK : NAME_TAG_RANGE; float f = entity.isSneaking() ? NAME_TAG_RANGE_SNEAK : NAME_TAG_RANGE;

View File

@ -75,6 +75,7 @@ import net.minecraft.world.LockCode;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldSettings; import net.minecraft.world.WorldSettings;
import rip.athena.client.Athena; import rip.athena.client.Athena;
import rip.athena.client.events.types.entity.AttackEntityEvent;
import rip.athena.client.events.types.entity.PlayerInteractEvent; import rip.athena.client.events.types.entity.PlayerInteractEvent;
import rip.athena.client.events.types.entity.PlayerTickEvent; import rip.athena.client.events.types.entity.PlayerTickEvent;

View File

@ -5,6 +5,7 @@ import net.minecraft.client.Minecraft;
import org.json.JSONException; import org.json.JSONException;
import org.lwjgl.Sys; import org.lwjgl.Sys;
import org.lwjgl.opengl.Display; import org.lwjgl.opengl.Display;
import rip.athena.client.account.AccountManager;
import rip.athena.client.config.save.ConfigManager; import rip.athena.client.config.save.ConfigManager;
import rip.athena.client.events.EventBus; import rip.athena.client.events.EventBus;
import rip.athena.client.events.SubscribeEvent; import rip.athena.client.events.SubscribeEvent;
@ -13,6 +14,7 @@ import rip.athena.client.gui.hud.HUDManager;
import rip.athena.client.gui.notifications.NotificationManager; import rip.athena.client.gui.notifications.NotificationManager;
import rip.athena.client.macros.MacroManager; import rip.athena.client.macros.MacroManager;
import rip.athena.client.modules.ModuleManager; import rip.athena.client.modules.ModuleManager;
import rip.athena.client.modules.impl.other.AimTrainer;
import rip.athena.client.requests.ContentType; import rip.athena.client.requests.ContentType;
import rip.athena.client.requests.WebRequest; import rip.athena.client.requests.WebRequest;
import rip.athena.client.requests.WebRequestResult; import rip.athena.client.requests.WebRequestResult;
@ -49,6 +51,7 @@ public class Athena {
public static final File MAIN_DIR = Paths.get(Minecraft.getMinecraft().mcDataDir.getAbsolutePath(), "settings").toFile(); public static final File MAIN_DIR = Paths.get(Minecraft.getMinecraft().mcDataDir.getAbsolutePath(), "settings").toFile();
public static final File CONFIGS_DIR = Paths.get(MAIN_DIR.getAbsolutePath(), "configs").toFile(); public static final File CONFIGS_DIR = Paths.get(MAIN_DIR.getAbsolutePath(), "configs").toFile();
public static final File ACCOUNTS_DIR = new File(MAIN_DIR.getAbsolutePath(), "accounts.json");
private final PrefixedLogger log = new PrefixedLogger("Athena"); private final PrefixedLogger log = new PrefixedLogger("Athena");
@ -57,6 +60,7 @@ public class Athena {
private final String clientBuild = "230601"; private final String clientBuild = "230601";
private NotificationManager notificationManager; private NotificationManager notificationManager;
private AccountManager accountManager;
private ConfigManager configManager; private ConfigManager configManager;
private ModuleManager moduleManager; private ModuleManager moduleManager;
private ThemeManager themeManager; private ThemeManager themeManager;
@ -80,12 +84,21 @@ public class Athena {
MAIN_DIR.mkdir(); MAIN_DIR.mkdir();
} }
if(!ACCOUNTS_DIR.exists()) {
try {
ACCOUNTS_DIR.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
if(SocketClient.isClientRunning()) { if(SocketClient.isClientRunning()) {
JOptionPane.showMessageDialog(null, "Port 1337 already in use."); JOptionPane.showMessageDialog(null, "Port 1337 already in use.");
System.exit(0); System.exit(0);
} }
this.configManager = new ConfigManager(CONFIGS_DIR); this.configManager = new ConfigManager(CONFIGS_DIR);
this.accountManager = new AccountManager();
this.moduleManager = new ModuleManager(); this.moduleManager = new ModuleManager();
this.themeManager = new ThemeManager(); this.themeManager = new ThemeManager();
this.macroManager = new MacroManager(); this.macroManager = new MacroManager();

View File

@ -0,0 +1,77 @@
package rip.athena.client.account;
import rip.athena.client.utils.animations.simple.SimpleAnimation;
import rip.athena.client.utils.time.TimerUtil;
/**
* @author Athena Development
* @project Athena-Client
* @date 6/10/2023
*/
public class Account {
private AccountType accountType;
private String username, uuid, token;
private String info;
private TimerUtil timer;
public SimpleAnimation opacityAnimation = new SimpleAnimation(0.0F);
public boolean isDone;
public Account(AccountType accountType, String username, String uuid, String token) {
this.accountType = accountType;
this.username = username;
this.uuid = uuid;
this.token = token;
this.info = "";
this.timer = new TimerUtil();
this.isDone = true;
}
public AccountType getAccountType() {
return accountType;
}
public void setAccountType(AccountType accountType) {
this.accountType = accountType;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
public TimerUtil getTimer() {
return timer;
}
}

View File

@ -0,0 +1,157 @@
package rip.athena.client.account;
import fr.litarvan.openauth.microsoft.MicrosoftAuthResult;
import fr.litarvan.openauth.microsoft.MicrosoftAuthenticationException;
import fr.litarvan.openauth.microsoft.MicrosoftAuthenticator;
import net.minecraft.client.Minecraft;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.Session;
import rip.athena.client.Athena;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.PrintWriter;
import java.util.ArrayList;
/**
* @project Athena-Client
* @author Athena Development
* @date 6/10/2023
*/
public class AccountManager {
private Minecraft mc = Minecraft.getMinecraft();
private ArrayList<Account> accounts = new ArrayList<>();
public boolean isFirstLogin = false;
private Account currentAccount;
public AccountManager() {
if(Athena.ACCOUNTS_DIR.length() == 0) {
isFirstLogin = true;
}
this.load();
this.login(currentAccount);
}
public void save() {
ArrayList<String> toSave = new ArrayList<>();
for (Account a : Athena.INSTANCE.getAccountManager().getAccounts()) {
toSave.add("Account:" + a.getAccountType().toString() + ":" + a.getUsername() + ":" + a.getUuid() + ":" + a.getToken());
}
toSave.add("Current:" + getCurrentAccount().getUsername());
try {
PrintWriter pw = new PrintWriter(Athena.ACCOUNTS_DIR);
for (String str : toSave) {
pw.println(str);
}
pw.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
public void load() {
ArrayList<String> lines = new ArrayList<String>();
try {
BufferedReader reader = new BufferedReader(new FileReader(Athena.ACCOUNTS_DIR));
String line = reader.readLine();
while (line != null) {
lines.add(line);
line = reader.readLine();
}
reader.close();
} catch (Exception e) {
e.printStackTrace();
}
for (String s : lines) {
String[] args = s.split(":");
if (s.toLowerCase().startsWith("account:")) {
AccountType accountType = AccountType.MICROSOFT;
if(args[1].equals("MICROSOFT")) {
accountType = AccountType.MICROSOFT;
}
if(args[1].equals("SESSION")) {
accountType = AccountType.SESSION;
}
if(args[1].equals("CRACKED")) {
accountType = AccountType.CRACKED;
}
accounts.add(new Account(accountType, args[2], args[3], args[4]));
}
if (s.toLowerCase().startsWith("current:")) {
setCurrentAccount(getAccountByUsername(args[1]));
}
}
}
private void login(Account a) {
if(a == null) {
return;
}
if(a.getAccountType().equals(AccountType.MICROSOFT)) {
MicrosoftAuthenticator authenticator = new MicrosoftAuthenticator();
a.setInfo("Loading...");
try {
MicrosoftAuthResult acc = authenticator.loginWithRefreshToken(a.getToken());
mc.session = new Session(acc.getProfile().getName(), acc.getProfile().getId(), acc.getAccessToken(), "legacy");
a.setInfo("Success");
} catch (MicrosoftAuthenticationException e) {
e.printStackTrace();
a.setInfo("Error");
}
}
if(a.getAccountType().equals(AccountType.SESSION)) {
a.setInfo("Loading...");
try {
mc.session = new Session(a.getUsername(), a.getUuid(), a.getToken(), "mojang");
a.setInfo("Success!");
} catch (Exception e) {
e.printStackTrace();
a.setInfo("Error");
}
}
if(a.getAccountType().equals(AccountType.CRACKED)) {
a.setInfo("Success");
mc.session = new Session(a.getUsername(), "0", "0", "legacy");
}
}
public Account getAccountByUsername(String name) {
return accounts.stream().filter(account -> account.getUsername().equalsIgnoreCase(name)).findFirst().orElse(null);
}
public ArrayList<Account> getAccounts() {
return accounts;
}
public Account getCurrentAccount() {
return currentAccount;
}
public void setCurrentAccount(Account currentAccount) {
this.currentAccount = currentAccount;
}
}

View File

@ -0,0 +1,10 @@
package rip.athena.client.account;
/**
* @author Athena Development
* @project Athena-Client
* @date 6/10/2023
*/
public enum AccountType {
MICROSOFT, CRACKED, SESSION;
}

View File

@ -15,7 +15,7 @@ import rip.athena.client.gui.hud.HUDElement;
import rip.athena.client.macros.Macro; import rip.athena.client.macros.Macro;
import rip.athena.client.modules.Module; import rip.athena.client.modules.Module;
import rip.athena.client.modules.impl.render.Crosshair; import rip.athena.client.modules.impl.render.Crosshair;
import rip.athena.client.theme.Theme; import rip.athena.client.theme.impl.AccentTheme;
import rip.athena.client.utils.StringUtils; import rip.athena.client.utils.StringUtils;
import rip.athena.client.utils.file.FileHandler; import rip.athena.client.utils.file.FileHandler;
import rip.athena.client.utils.input.BindType; import rip.athena.client.utils.input.BindType;
@ -147,7 +147,7 @@ public class Config {
String themeIdentifier = obj.getString("theme"); String themeIdentifier = obj.getString("theme");
for (Theme theme : Theme.values()) { for (AccentTheme theme : AccentTheme.values()) {
if (theme.name().equalsIgnoreCase(themeIdentifier)) { if (theme.name().equalsIgnoreCase(themeIdentifier)) {
Athena.INSTANCE.getThemeManager().setTheme(theme); Athena.INSTANCE.getThemeManager().setTheme(theme);
break; break;

View File

@ -136,10 +136,10 @@ public class IngameMenu extends MinecraftMenuImpl implements DrawImpl {
drawShadowDown(menu.getX(), menu.getY() + 58, menu.getWidth()); drawShadowDown(menu.getX(), menu.getY() + 58, menu.getWidth());
RoundedUtils.drawRoundedOutline(menu.getX(), menu.getY(), menu.getX() + menu.getWidth(), menu.getY() + menu.getHeight(), 32, 5, new Color(50, 50, 50, 255).getRGB()); RoundedUtils.drawRoundedOutline(menu.getX(), menu.getY(), menu.getX() + menu.getWidth(), menu.getY() + menu.getHeight(), 32, 5, Athena.INSTANCE.getThemeManager().getPrimaryTheme().getSecondColor());
RoundedUtils.drawRoundedRect(menu.getX(), menu.getY(), menu.getX() + menu.getWidth(), menu.getY() + menu.getHeight(), 32, new Color(30, 30, 30, 255).getRGB()); RoundedUtils.drawRoundedRect(menu.getX(), menu.getY(), menu.getX() + menu.getWidth(), menu.getY() + menu.getHeight(), 32, Athena.INSTANCE.getThemeManager().getPrimaryTheme().getFirstColor());
rip.athena.client.utils.font.FontManager.getNunitoBold(50).drawString(Athena.INSTANCE.getClientName().toUpperCase(), menu.getX() + 60, menu.getY() + 17, MENU_HEADER_TEXT_COLOR); rip.athena.client.utils.font.FontManager.getNunitoBold(50).drawString(Athena.INSTANCE.getClientName().toUpperCase(), menu.getX() + 60, menu.getY() + 17, Athena.INSTANCE.getThemeManager().getPrimaryTheme().getTextColor());
//DrawUtils.drawImage(new ResourceLocation("Athena/logo/pride.png"), (int) (menu.getX() + FontManager.font1.getStringWidth(Athena.INSTANCE.getClientName().toUpperCase()) + 70), (int) (menu.getY() - 10 + FontManager.font1.getHeight(Athena.INSTANCE.getClientName().toUpperCase())), 30, 30); //DrawUtils.drawImage(new ResourceLocation("Athena/logo/pride.png"), (int) (menu.getX() + FontManager.font1.getStringWidth(Athena.INSTANCE.getClientName().toUpperCase()) + 70), (int) (menu.getY() - 10 + FontManager.font1.getHeight(Athena.INSTANCE.getClientName().toUpperCase())), 30, 30);

Some files were not shown because too many files have changed in this diff Show More