diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/PojavProfile.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/PojavProfile.java deleted file mode 100644 index 11c5dc33..00000000 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/PojavProfile.java +++ /dev/null @@ -1,65 +0,0 @@ -package net.kdt.pojavlaunch; - -import com.google.gson.JsonSyntaxException; -import java.io.File; -import java.io.IOException; -import net.kdt.pojavlaunch.authenticator.mojang.RefreshTokenTask; -import net.kdt.pojavlaunch.value.MinecraftAccount; - -public class PojavProfile -{ -/* - public static MinecraftAccount getCurrentProfileContent() throws IOException, JsonSyntaxException { - MinecraftAccount build = MinecraftAccount.load(getCurrentProfileName()); - if (build == null) { - return getTempProfileContent(); - } - return MinecraftAccount.load(getCurrentProfileName()); - } - - public static MinecraftAccount getTempProfileContent(Context ctx) { - return MinecraftAccount.parse(getPrefs(ctx).getString(PROFILE_PREF_TEMP_CONTENT, "")); - } - - public static String getCurrentProfileName() { - String name = ""; - try { - name = Tools.read(currAccFile.getAbsolutePath()); - } catch (IOException e) { - e.printStackTrace(); - } - // A dirty fix - if (!name.isEmpty() && name.startsWith(Tools.DIR_ACCOUNT_NEW) && name.endsWith(".json")) { - name = name.substring(0, name.length() - 5).replace(Tools.DIR_ACCOUNT_NEW, "").replace(".json", ""); - setCurrentProfile(name); - } - return name; - } - - public static boolean setCurrentProfile(Object obj) { - try { - if (obj instanceof MinecraftAccount) { - throw new UnsupportedOperationException("Temp account is not supported yet"); - } else if (obj instanceof String) { - String acc = (String) obj; - Tools.write(currAccFile.getAbsolutePath(), acc); - MinecraftAccount.clearTempAccount(); - } else if (obj == null) { - // pref.putString(PROFILE_PREF_FILE, ""); - } else { - throw new IllegalArgumentException("Profile must be MinecraftAccount.class, String.class or null"); - } - } catch (IOException e) { - e.printStackTrace(); - } - return false; - } - - public static boolean isFileType() { - return new File(Tools.DIR_ACCOUNT_NEW + "/" + getCurrentProfileName() + ".json").exists(); - } -*/ - public static void updateTokens(final String name) throws Throwable { - new RefreshTokenTask().run(name); - } -} diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/Tools.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/Tools.java index 3cb3c5ce..bc89a984 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/Tools.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/Tools.java @@ -193,7 +193,7 @@ public final class Tools varArgMap.put("game_assets", Tools.ASSETS_PATH); varArgMap.put("game_directory", gameDir.getAbsolutePath()); varArgMap.put("user_properties", "{}"); - varArgMap.put("user_type", profile.isMicrosoft ? "msa" : "mojang"); + varArgMap.put("user_type", "msa"); varArgMap.put("version_name", versionName); varArgMap.put("version_type", versionInfo.type); diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/microsoft/MicrosoftAuthTask.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/microsoft/MicrosoftAuthTask.java index bf5bb7b6..d924701b 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/microsoft/MicrosoftAuthTask.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/microsoft/MicrosoftAuthTask.java @@ -2,19 +2,17 @@ package net.kdt.pojavlaunch.authenticator.microsoft; import android.util.*; +import java.io.*; import java.net.*; import java.text.*; import java.util.*; -import net.kdt.pojavlaunch.*; -import net.kdt.pojavlaunch.authenticator.mojang.*; -import net.kdt.pojavlaunch.authenticator.microsoft.*; -import org.json.*; -import java.text.ParseException; -import java.io.*; +import net.kdt.pojavlaunch.*; import net.kdt.pojavlaunch.value.launcherprofiles.*; import net.kdt.pojavlaunch.value.*; +import org.json.*; + public class MicrosoftAuthTask { //private Gson gson = new Gson(); @@ -44,14 +42,12 @@ public class MicrosoftAuthTask { acc.accessToken = msa.mcToken; acc.username = msa.mcName; acc.profileId = msa.mcUuid; - acc.isMicrosoft = true; acc.msaRefreshToken = msa.msRefreshToken; } else if(msa.doesDemo) { acc.clientToken = "0"; /* FIXME */ acc.accessToken = "-1"; // Differentiate from local accounts acc.username = "demo_user"; acc.profileId = "25e00594-cf57-3f87-b3af-3f06591be252"; - acc.isMicrosoft = false; acc.msaRefreshToken = "0"; } acc.save(); diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/InvalidateTokenTask.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/InvalidateTokenTask.java deleted file mode 100644 index 80b19989..00000000 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/InvalidateTokenTask.java +++ /dev/null @@ -1,23 +0,0 @@ -package net.kdt.pojavlaunch.authenticator.mojang; - -import java.io.File; -import java.util.UUID; -import net.kdt.pojavlaunch.Tools; -import net.kdt.pojavlaunch.authenticator.mojang.yggdrasil.YggdrasilAuthenticator; -import net.kdt.pojavlaunch.value.MinecraftAccount; - -public class InvalidateTokenTask { - private YggdrasilAuthenticator authenticator = new YggdrasilAuthenticator(); - //private Gson gson = new Gson(); - private MinecraftAccount profilePath; - private String name; - - public void run(String name) throws Throwable { - this.name = name; - this.profilePath = MinecraftAccount.load(name); - this.authenticator.invalidate(profilePath.accessToken, - UUID.fromString(profilePath.isMicrosoft ? profilePath.profileId : profilePath.clientToken /* should be? */)); - new File(Tools.DIR_ACCOUNT_NEW, name + ".json").delete(); - } -} - diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/LoginTask.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/LoginTask.java deleted file mode 100644 index f5049f27..00000000 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/LoginTask.java +++ /dev/null @@ -1,36 +0,0 @@ -package net.kdt.pojavlaunch.authenticator.mojang; - -import java.io.File; -import java.util.UUID; -import net.kdt.pojavlaunch.Tools; -import net.kdt.pojavlaunch.authenticator.mojang.yggdrasil.AuthenticateResponse; -import net.kdt.pojavlaunch.authenticator.mojang.yggdrasil.YggdrasilAuthenticator; -import net.kdt.pojavlaunch.value.MinecraftAccount; - -public class LoginTask { - private YggdrasilAuthenticator authenticator = new YggdrasilAuthenticator(); - //private String TAG = "MojangAuth-login"; - - private UUID getRandomUUID() { - return UUID.randomUUID(); - } - - public MinecraftAccount run(String username, String password) throws Throwable { - AuthenticateResponse response = authenticator.authenticate(username, password, getRandomUUID()); - if (response.selectedProfile == null) { - throw new IllegalArgumentException("Can't login a demo account!\n"); - } else { - if (new File(Tools.DIR_ACCOUNT_NEW + "/" + response.selectedProfile.name + ".json").exists()) { - throw new IllegalArgumentException("This account already exist!\n"); - } else { - MinecraftAccount acc = new MinecraftAccount(); - acc.accessToken = response.accessToken; - acc.clientToken = response.clientToken.toString(); - acc.profileId = response.selectedProfile.id; - acc.username = response.selectedProfile.name; - acc.save(); - return acc; - } - } - } -} diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/RefreshTokenTask.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/RefreshTokenTask.java deleted file mode 100644 index 8c35490c..00000000 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/RefreshTokenTask.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.kdt.pojavlaunch.authenticator.mojang; - -import com.google.gson.*; -import java.util.*; -import net.kdt.pojavlaunch.*; -import net.kdt.pojavlaunch.authenticator.mojang.yggdrasil.*; -import net.kdt.pojavlaunch.value.*; -import java.io.IOException; - -public class RefreshTokenTask { - private YggdrasilAuthenticator authenticator = new YggdrasilAuthenticator(); - private MinecraftAccount profilePath; - - public void run(String name) throws Throwable { - this.profilePath = MinecraftAccount.load(name); - int responseCode = 400; - try { - responseCode = this.authenticator.validate(profilePath.accessToken).statusCode; - } catch(RuntimeException e) {} - - if (responseCode == 403) { - RefreshResponse response = this.authenticator.refresh(profilePath.accessToken, UUID.fromString(profilePath.clientToken)); - if (response == null) { - // Refresh when offline? - return; - } else if (response.selectedProfile == null) { - throw new IllegalArgumentException("Can't refresh a demo account!"); - } - - profilePath.clientToken = response.clientToken.toString(); - profilePath.accessToken = response.accessToken; - profilePath.username = response.selectedProfile.name; - profilePath.profileId = response.selectedProfile.id; - } - profilePath.save(); - } -} - diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/AuthenticateRequest.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/AuthenticateRequest.java deleted file mode 100644 index f9dce579..00000000 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/AuthenticateRequest.java +++ /dev/null @@ -1,24 +0,0 @@ -package net.kdt.pojavlaunch.authenticator.mojang.yggdrasil; - -import java.util.UUID; - -public class AuthenticateRequest { - public AgentInfo agent = new AgentInfo(); - public UUID clientToken; - public String password; - public String username; - - public static class AgentInfo { - public String name; - public int version; - } - - public AuthenticateRequest(String username, String password, UUID clientToken, String clientName, int clientVersion) { - this.username = username; - this.password = password; - this.clientToken = clientToken; - this.agent.name = clientName; - this.agent.version = clientVersion; - } -} - diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/AuthenticateResponse.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/AuthenticateResponse.java deleted file mode 100644 index 8989acd1..00000000 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/AuthenticateResponse.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.kdt.pojavlaunch.authenticator.mojang.yggdrasil; - -import java.util.UUID; - -public class AuthenticateResponse { - public String accessToken; - public Profile[] availableProfiles; - public UUID clientToken; - public Profile selectedProfile; -} - diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/ErrorResponse.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/ErrorResponse.java deleted file mode 100644 index 2fa09bd6..00000000 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/ErrorResponse.java +++ /dev/null @@ -1,8 +0,0 @@ -package net.kdt.pojavlaunch.authenticator.mojang.yggdrasil; - -public class ErrorResponse { - public String cause; - public String error; - public String errorMessage; -} - diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/NetworkResponse.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/NetworkResponse.java deleted file mode 100644 index 69b8f97f..00000000 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/NetworkResponse.java +++ /dev/null @@ -1,23 +0,0 @@ -package net.kdt.pojavlaunch.authenticator.mojang.yggdrasil; - -import java.util.*; - -public class NetworkResponse -{ - public final int statusCode; - public final Object response; - public NetworkResponse(int statusCode, Object response) { - this.statusCode = statusCode; - this.response = response; - } - - public void throwExceptionIfNeed(String msg) { - if (statusCode < 200 || statusCode >= 300) { - throw new RuntimeException(msg); - } - } - - public void throwExceptionIfNeed() { - throwExceptionIfNeed("Respone error, code: " + statusCode + ", message: " + response); - } -} diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/Profile.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/Profile.java deleted file mode 100644 index 8733ead1..00000000 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/Profile.java +++ /dev/null @@ -1,8 +0,0 @@ -package net.kdt.pojavlaunch.authenticator.mojang.yggdrasil; - -public class Profile { - public String id; - public boolean legacy; - public String name; -} - diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/RefreshRequest.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/RefreshRequest.java deleted file mode 100644 index f8b0941c..00000000 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/RefreshRequest.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.kdt.pojavlaunch.authenticator.mojang.yggdrasil; - -import java.util.UUID; - -public class RefreshRequest { - public String accessToken; - public UUID clientToken; - - public RefreshRequest(String accessToken, UUID clientToken) { - this.accessToken = accessToken; - this.clientToken = clientToken; - } -} - diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/RefreshResponse.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/RefreshResponse.java deleted file mode 100644 index b9a59795..00000000 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/RefreshResponse.java +++ /dev/null @@ -1,10 +0,0 @@ -package net.kdt.pojavlaunch.authenticator.mojang.yggdrasil; - -import java.util.UUID; - -public class RefreshResponse { - public String accessToken; - public UUID clientToken; - public Profile selectedProfile; -} - diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/YggdrasilAuthenticator.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/YggdrasilAuthenticator.java deleted file mode 100644 index 5247e146..00000000 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/authenticator/mojang/yggdrasil/YggdrasilAuthenticator.java +++ /dev/null @@ -1,124 +0,0 @@ -package net.kdt.pojavlaunch.authenticator.mojang.yggdrasil; - -import java.io.*; -import java.net.*; -import java.nio.charset.*; -import java.util.*; -import net.kdt.pojavlaunch.*; - -public class YggdrasilAuthenticator { - private static final String API_URL = "https://authserver.mojang.com/"; - private String clientName = "Minecraft"; - private int clientVersion = 1; - - private NetworkResponse makeRequest(String endpoint, Object inputObject, Class responseClass) throws IOException, Throwable { - Throwable th; - InputStream is = null; - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - String requestJson = Tools.GLOBAL_GSON.toJson(inputObject); - try { - URL url = new URL(API_URL + endpoint); - OutputStream os; - try { - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setRequestProperty("User-Agent", "Minecraft"); - conn.setRequestProperty("Content-Type", "application/json"); - conn.setRequestProperty("charset", "utf-8"); - conn.setRequestProperty("Content-Length", Integer.toString(requestJson.getBytes("UTF-8").length)); - conn.setRequestMethod("POST"); - conn.setUseCaches(false); - conn.setDoInput(true); - conn.setDoOutput(true); - conn.connect(); - os = null; - os = conn.getOutputStream(); - os.write(requestJson.getBytes(Charset.forName("UTF-8"))); - if (os != null) { - os.close(); - } - - int statusCode = conn.getResponseCode(); - if (statusCode != 200) { - is = conn.getErrorStream(); - } else { - is = conn.getInputStream(); - } - - if (is != null) { - Tools.copy(is, bos); - try { - is.close(); - } catch (Exception e) { - throw e; - } - } - - String outString = new String(bos.toByteArray(), Charset.forName("UTF-8")); - if (statusCode == 200 || statusCode == 204){ - System.out.println("Task " + endpoint + " successful"); - - if (responseClass != null) { - return new NetworkResponse(statusCode, Tools.GLOBAL_GSON.fromJson(outString, responseClass)); - } - } else { - System.out.println("Task " + endpoint + " failure"); - } - - return new NetworkResponse(statusCode, outString); - } catch (UnknownHostException e) { - if (endpoint.equals("refresh")) { - return null; - } else { - throw new RuntimeException("Can't connect to the server", e); - } - } catch (Throwable th2) { - th = th2; - if (is != null) { - try { - is.close(); - } catch (Exception e2) { - e2.addSuppressed(th2); - throw e2; - } - } - throw th; - } - } catch (Throwable th3) { - th = th3; - if (is != null) { - is.close(); - } - throw th; - } - } - - public AuthenticateResponse authenticate(String username, String password, UUID clientId) throws IOException, Throwable { - NetworkResponse obj = makeRequest("authenticate", new AuthenticateRequest(username, password, clientId, this.clientName, this.clientVersion), AuthenticateResponse.class); - /* - if (obj.statusCode != 200) { - throw new RuntimeException("Invalid username or password, status code: " + obj.statusCode); - } - */ - obj.throwExceptionIfNeed(); - return (AuthenticateResponse) obj.response; - } - - public RefreshResponse refresh(String authToken, UUID clientId) throws IOException, Throwable { - NetworkResponse obj = makeRequest("refresh", new RefreshRequest(authToken, clientId), RefreshResponse.class); - if (obj == null) { - return null; - } else { - obj.throwExceptionIfNeed(); // "Invalid username or password, status code: " + obj.statusCode); - return (RefreshResponse) obj.response; - } - } - - public NetworkResponse validate(String authToken) throws Throwable { - return makeRequest("validate", new RefreshRequest(authToken, null), null); - } - - public NetworkResponse invalidate(String authToken, UUID clientId) throws Throwable { - return makeRequest("invalidate", new RefreshRequest(authToken, clientId), null); - } -} - diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/AccountJNI.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/AccountJNI.java index 85090e95..e8ab94e7 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/AccountJNI.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/AccountJNI.java @@ -1,18 +1,14 @@ package net.kdt.pojavlaunch.uikit; import java.net.UnknownHostException; -import net.kdt.pojavlaunch.PojavProfile; import net.kdt.pojavlaunch.Tools; import net.kdt.pojavlaunch.authenticator.microsoft.MicrosoftAuthTask; -import net.kdt.pojavlaunch.authenticator.mojang.LoginTask; -import net.kdt.pojavlaunch.authenticator.mojang.yggdrasil.*; import net.kdt.pojavlaunch.value.MinecraftAccount; public class AccountJNI { public static final int TYPE_SELECTACC = 0; public static final int TYPE_MICROSOFT = 1; - public static final int TYPE_MOJANG = 2; - public static final int TYPE_OFFLINE = 3; + public static final int TYPE_OFFLINE = 2; public static volatile MinecraftAccount CURRENT_ACCOUNT; @@ -20,7 +16,6 @@ public class AccountJNI { public static String loginAccount(int type, String data // One of: // Local username - // Mojang json response // Microsoft token ) { try { @@ -28,10 +23,8 @@ public class AccountJNI { case TYPE_SELECTACC: CURRENT_ACCOUNT = MinecraftAccount.load(data); try { - if (CURRENT_ACCOUNT.isMicrosoft) { + if (CURRENT_ACCOUNT.accessToken.length() > 5) { CURRENT_ACCOUNT = new MicrosoftAuthTask().run("true", CURRENT_ACCOUNT.msaRefreshToken); - } else if (CURRENT_ACCOUNT.accessToken.length() > 5) { - PojavProfile.updateTokens(data); } CURRENT_ACCOUNT = MinecraftAccount.load(data); } catch (UnknownHostException e) { @@ -44,16 +37,6 @@ public class AccountJNI { CURRENT_ACCOUNT = new MicrosoftAuthTask().run("false", data); break; - case TYPE_MOJANG: - AuthenticateResponse response = Tools.GLOBAL_GSON.fromJson(data, AuthenticateResponse.class); - CURRENT_ACCOUNT = new MinecraftAccount(); - CURRENT_ACCOUNT.accessToken = response.accessToken; - CURRENT_ACCOUNT.clientToken = response.clientToken.toString(); - CURRENT_ACCOUNT.profileId = response.selectedProfile.id; - CURRENT_ACCOUNT.username = response.selectedProfile.name; - CURRENT_ACCOUNT.save(); - break; - case TYPE_OFFLINE: CURRENT_ACCOUNT = new MinecraftAccount(); CURRENT_ACCOUNT.username = data; diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/value/MinecraftAccount.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/value/MinecraftAccount.java index 81f8c346..c7f1e63b 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/value/MinecraftAccount.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/value/MinecraftAccount.java @@ -10,7 +10,6 @@ public class MinecraftAccount public String profileId = "00000000-0000-0000-0000-000000000000"; // authenticate UUID public String username = "Steve"; public String selectedVersion = "1.7.10"; - public boolean isMicrosoft = false; public String msaRefreshToken = "0"; public String save(String outPath) throws IOException { diff --git a/Makefile b/Makefile index 88826f68..4880f335 100644 --- a/Makefile +++ b/Makefile @@ -244,7 +244,7 @@ native: .. @cmake --build $(WORKINGDIR) --config $(CMAKE_BUILD_TYPE) -j$(JOBS) - # --target awt_headless awt_xawt libOSMesaOverride.dylib PojavLauncher + @# --target awt_headless awt_xawt libOSMesaOverride.dylib PojavLauncher @rm $(WORKINGDIR)/libawt_headless.dylib @echo 'Building PojavLauncher $(VERSION) - NATIVES - End' diff --git a/Natives/LoginViewController.m b/Natives/LoginViewController.m index d7180eba..18ae5e0f 100644 --- a/Natives/LoginViewController.m +++ b/Natives/LoginViewController.m @@ -17,8 +17,7 @@ #define TYPE_SELECTACC 0 #define TYPE_MICROSOFT 1 -#define TYPE_MOJANG 2 -#define TYPE_OFFLINE 3 +#define TYPE_OFFLINE 2 #pragma mark - LoginViewController @interface LoginViewController () { @@ -126,14 +125,12 @@ if(@available (iOS 14.0, *)) { UIAction *option1 = [UIAction actionWithTitle:@"Microsoft account" image:nil identifier:nil handler:^(__kindof UIAction * _Nonnull action) {[self loginMicrosoft];}]; - UIAction *option2 = [UIAction actionWithTitle:@"Mojang account" image:nil identifier:nil - handler:^(__kindof UIAction * _Nonnull action) {[self loginUsername:TYPE_MOJANG];}]; UIAction *option3 = [UIAction actionWithTitle:@"Demo account" image:nil identifier:nil handler:^(__kindof UIAction * _Nonnull action) {[self loginDemo:button_login];}]; UIAction *option4 = [UIAction actionWithTitle:@"Local account" image:nil identifier:nil handler:^(__kindof UIAction * _Nonnull action) {[self loginOffline:button_login];}]; UIMenu *menu = [UIMenu menuWithTitle:@"" image:nil identifier:nil - options:UIMenuOptionsDisplayInline children:@[option4, option3, option2, option1]]; + options:UIMenuOptionsDisplayInline children:@[option4, option3, option1]]; button_login.menu = menu; button_login.showsMenuAsPrimaryAction = YES; } @@ -187,7 +184,6 @@ // UIMenu } else { UIAlertController *fullAlert = [UIAlertController alertControllerWithTitle:@"Let's get you signed in." message:@"What account do you use to log into Minecraft?"preferredStyle:UIAlertControllerStyleActionSheet]; - UIAlertAction *mojang = [UIAlertAction actionWithTitle:@"Mojang account" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self loginUsername:TYPE_MOJANG];}]; UIAlertAction *microsoft = [UIAlertAction actionWithTitle:@"Microsoft account" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self loginMicrosoft];}]; UIAlertAction *offline = [UIAlertAction actionWithTitle:@"Local account" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self loginOffline:sender];}]; UIAlertAction *demo = [UIAlertAction actionWithTitle:@"Demo account" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self loginDemo:sender];}]; @@ -195,7 +191,6 @@ [self setPopoverProperties:fullAlert.popoverPresentationController sender:sender]; [self presentViewController:fullAlert animated:YES completion:nil]; [fullAlert addAction:microsoft]; - [fullAlert addAction:mojang]; [fullAlert addAction:demo]; [fullAlert addAction:offline]; [fullAlert addAction:cancel]; @@ -250,51 +245,6 @@ }); } -- (void)loginUsername:(int)type { - UIAlertController *controller = [UIAlertController alertControllerWithTitle: @"Login" - message: @(type == TYPE_MOJANG ? - "Account type: Mojang" : "Account type: Local") - preferredStyle:UIAlertControllerStyleAlert]; - [controller addTextFieldWithConfigurationHandler:^(UITextField *textField) { - if (type == TYPE_MOJANG) { - textField.placeholder = @"Email or username"; - } else { - textField.placeholder = @"Username"; - } - textField.clearButtonMode = UITextFieldViewModeWhileEditing; - textField.borderStyle = UITextBorderStyleRoundedRect; - }]; - if (type == TYPE_MOJANG) { - [controller addTextFieldWithConfigurationHandler:^(UITextField *textField) { - textField.placeholder = @"Password"; - textField.clearButtonMode = UITextFieldViewModeWhileEditing; - textField.borderStyle = UITextBorderStyleRoundedRect; - textField.secureTextEntry = YES; - }]; - } - [controller addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { - NSArray *textFields = controller.textFields; - UITextField *usernameField = textFields[0]; - - if (type == TYPE_MOJANG) { - [self loginMojangWithUsername:usernameField.text password:((UITextField *) textFields[1]).text]; - } else { - if (usernameField.text.length < 3 || usernameField.text.length > 16) { - controller.message = @"Username must be at least 3 characters and maximum 16 characters"; - [self presentViewController:controller animated:YES completion:nil]; - } else { - [self loginAccountInput:TYPE_OFFLINE data:usernameField.text]; - } - } - }]]; - [controller addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; - [self presentViewController:controller animated:YES completion:nil]; -} - -- (void)loginMojang { - [self loginUsername:TYPE_MOJANG]; -} - - (void)loginMicrosoft { NSURL *url = [NSURL URLWithString:@"https://login.live.com/oauth20_authorize.srf?client_id=00000000402b5328&response_type=code&scope=service%3A%3Auser.auth.xboxlive.com%3A%3AMBI_SSL&redirect_url=https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf"]; @@ -339,14 +289,31 @@ if ([getPreference(@"local_warn") boolValue] == YES) { UIAlertController *offlineAlert = [UIAlertController alertControllerWithTitle:@"Offline mode is now Local mode." message:@"You can continue to play installed versions, but you can no longer download Minecraft without a paid account. No support will be provided for issues with local accounts, or other means of acquiring Minecraft. See the FAQ for more information."preferredStyle:UIAlertControllerStyleActionSheet]; [self setPopoverProperties:offlineAlert.popoverPresentationController sender:sender]; - UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self loginUsername:TYPE_OFFLINE];}]; + UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self loginOffline:sender];}]; UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self accountType:sender];}]; [self presentViewController:offlineAlert animated:YES completion:nil]; [offlineAlert addAction:ok]; [offlineAlert addAction:cancel]; setPreference(@"local_warn", @NO); } else { - [self loginUsername:(TYPE_OFFLINE)]; + UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"Login" message:@"Account type: Local" preferredStyle:UIAlertControllerStyleAlert]; + [controller addTextFieldWithConfigurationHandler:^(UITextField *textField) { + textField.placeholder = @"Username"; + textField.clearButtonMode = UITextFieldViewModeWhileEditing; + textField.borderStyle = UITextBorderStyleRoundedRect; + }]; + [controller addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + NSArray *textFields = controller.textFields; + UITextField *usernameField = textFields[0]; + if (usernameField.text.length < 3 || usernameField.text.length > 16) { + controller.message = @"Username must be at least 3 characters and maximum 16 characters"; + [self presentViewController:controller animated:YES completion:nil]; + } else { + [self loginAccountInput:TYPE_OFFLINE data:usernameField.text]; + } + }]]; + [controller addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; + [self presentViewController:controller animated:YES completion:nil]; } } @@ -385,7 +352,7 @@ popoverController.delegate = self; [self presentViewController:vc animated:YES completion:nil]; } - +/* - (void)loginMojangWithUsername:(NSString*)input_username password:(NSString*)input_password { [self displayProgress:@"Logging in"]; @@ -439,7 +406,7 @@ }]; [postDataTask resume]; } - +*/ - (void)aboutLauncher { AboutLauncherViewController *vc = [[AboutLauncherViewController alloc] init]; diff --git a/Natives/UpdateHistoryViewController.m b/Natives/UpdateHistoryViewController.m index d53dc5df..a38f29ca 100644 --- a/Natives/UpdateHistoryViewController.m +++ b/Natives/UpdateHistoryViewController.m @@ -54,7 +54,8 @@ CGFloat uhcurrY = 4.0; "- Keyboard and mouse support deepened\n" "- New \"vgpu\" renderer, exports OpenGL 3.0\n" "- Custom controls UI completed\n" - "- Arc custom capes integration!" width:width]]; + "- Arc custom capes integration!\n" + "- Removed Mojang account login" width:width]]; [scrollView addSubview:[self uhContent:true size:17 text:@"Fixes" width:width]]; [scrollView addSubview:[self uhContent:false size:0 text:@"- Slight changes to error messages\n" "- Fix Makefile errors in `deploy` and `ipa`\n" diff --git a/Natives/input_bridge_v3.m b/Natives/input_bridge_v3.m index 51125eaa..e332cc26 100644 --- a/Natives/input_bridge_v3.m +++ b/Natives/input_bridge_v3.m @@ -280,7 +280,9 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSetGrabbing(JNIE [surfaceView addGestureRecognizer:((SurfaceViewController *)viewController).scrollPanGesture]; } ((SurfaceViewController *)viewController).mousePointerView.hidden = isGrabbing || !virtualMouseEnabled; - [viewController setNeedsUpdateOfPrefersPointerLocked]; + if(@available(iOS 14.0, *)) { + [viewController setNeedsUpdateOfPrefersPointerLocked]; + } }); } diff --git a/Natives/resources/Assets.car b/Natives/resources/Assets.car index f95262c0..3004606d 100644 Binary files a/Natives/resources/Assets.car and b/Natives/resources/Assets.car differ