From 06af79e2b49a669aa9533e782f41ed7c1fd9c236 Mon Sep 17 00:00:00 2001 From: yushijinhun Date: Thu, 7 Jun 2018 22:25:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=AF=B9legcay=E8=B4=A6?= =?UTF-8?q?=E6=88=B7=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jackhuang/hmcl/auth/AuthInfo.java | 14 ++---- .../org/jackhuang/hmcl/auth/UserType.java | 49 ------------------- .../hmcl/auth/offline/OfflineAccount.java | 3 +- .../hmcl/auth/yggdrasil/GameProfile.java | 15 ------ .../hmcl/auth/yggdrasil/YggdrasilSession.java | 3 +- .../hmcl/launch/DefaultLauncher.java | 2 +- 6 files changed, 7 insertions(+), 79 deletions(-) delete mode 100644 HMCLCore/src/main/java/org/jackhuang/hmcl/auth/UserType.java diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/AuthInfo.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/AuthInfo.java index 92cfea787..2663b0b12 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/AuthInfo.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/AuthInfo.java @@ -32,19 +32,17 @@ public final class AuthInfo { private final String username; private final UUID uuid; private final String accessToken; - private final UserType userType; private final String userProperties; private final Arguments arguments; - public AuthInfo(String username, UUID uuid, String accessToken, UserType userType, String userProperties) { - this(username, uuid, accessToken, userType, userProperties, null); + public AuthInfo(String username, UUID uuid, String accessToken, String userProperties) { + this(username, uuid, accessToken, userProperties, null); } - public AuthInfo(String username, UUID uuid, String accessToken, UserType userType, String userProperties, Arguments arguments) { + public AuthInfo(String username, UUID uuid, String accessToken, String userProperties, Arguments arguments) { this.username = username; this.uuid = uuid; this.accessToken = accessToken; - this.userType = userType; this.userProperties = userProperties; this.arguments = arguments; } @@ -61,10 +59,6 @@ public final class AuthInfo { return accessToken; } - public UserType getUserType() { - return userType; - } - /** * Properties of this user. * Don't know the difference between user properties and user property map. @@ -83,6 +77,6 @@ public final class AuthInfo { } public AuthInfo withArguments(Arguments arguments) { - return new AuthInfo(username, uuid, accessToken, userType, userProperties, arguments); + return new AuthInfo(username, uuid, accessToken, userProperties, arguments); } } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/UserType.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/UserType.java deleted file mode 100644 index 06fb43cbc..000000000 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/UserType.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Hello Minecraft! Launcher. - * Copyright (C) 2018 huangyuhui - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see {http://www.gnu.org/licenses/}. - */ -package org.jackhuang.hmcl.auth; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * - * @author huangyuhui - */ -public enum UserType { - LEGACY, - MOJANG; - - public static UserType fromName(String name) { - return BY_NAME.get(name.toLowerCase()); - } - - public static UserType fromLegacy(boolean isLegacy) { - return isLegacy ? LEGACY : MOJANG; - } - - static { - HashMap byName = new HashMap<>(); - for (UserType type : values()) - byName.put(type.name().toLowerCase(), type); - BY_NAME = Collections.unmodifiableMap(byName); - } - - public static final Map BY_NAME; - -} diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/offline/OfflineAccount.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/offline/OfflineAccount.java index bccbe9dcd..83e2e68e2 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/offline/OfflineAccount.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/offline/OfflineAccount.java @@ -27,7 +27,6 @@ import java.util.UUID; import org.jackhuang.hmcl.auth.Account; import org.jackhuang.hmcl.auth.AuthInfo; import org.jackhuang.hmcl.auth.AuthenticationException; -import org.jackhuang.hmcl.auth.UserType; import org.jackhuang.hmcl.util.StringUtils; import org.jackhuang.hmcl.util.ToStringBuilder; import org.jackhuang.hmcl.util.UUIDTypeAdapter; @@ -72,7 +71,7 @@ public class OfflineAccount extends Account { if (StringUtils.isBlank(username)) throw new AuthenticationException("Username cannot be empty"); - return new AuthInfo(username, uuid, UUIDTypeAdapter.fromUUID(UUID.randomUUID()), UserType.MOJANG, "{}"); + return new AuthInfo(username, uuid, UUIDTypeAdapter.fromUUID(UUID.randomUUID()), "{}"); } @Override diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/GameProfile.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/GameProfile.java index 2da491eea..2ffefb3b9 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/GameProfile.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/GameProfile.java @@ -18,7 +18,6 @@ package org.jackhuang.hmcl.auth.yggdrasil; import com.google.gson.*; -import org.jackhuang.hmcl.auth.UserType; import org.jackhuang.hmcl.util.Immutable; import java.lang.reflect.Type; @@ -34,7 +33,6 @@ public final class GameProfile { private final UUID id; private final String name; private final PropertyMap properties; - private final boolean legacy; public GameProfile() { this(null, null); @@ -45,14 +43,9 @@ public final class GameProfile { } public GameProfile(UUID id, String name, PropertyMap properties) { - this(id, name, properties, false); - } - - public GameProfile(UUID id, String name, PropertyMap properties, boolean legacy) { this.id = id; this.name = name; this.properties = properties; - this.legacy = legacy; } public UUID getId() { @@ -70,14 +63,6 @@ public final class GameProfile { return properties; } - public boolean isLegacy() { - return legacy; - } - - public UserType getUserType() { - return UserType.fromLegacy(isLegacy()); - } - public static class Serializer implements JsonSerializer, JsonDeserializer { public static final Serializer INSTANCE = new Serializer(); diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilSession.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilSession.java index 4f99697ee..f9d00280a 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilSession.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilSession.java @@ -9,7 +9,6 @@ import java.util.Optional; import java.util.UUID; import org.jackhuang.hmcl.auth.AuthInfo; -import org.jackhuang.hmcl.auth.UserType; import org.jackhuang.hmcl.util.UUIDTypeAdapter; import com.google.gson.Gson; @@ -88,7 +87,7 @@ public class YggdrasilSession { if (user == null) throw new IllegalStateException("No user is specified"); - return new AuthInfo(selectedProfile.getName(), selectedProfile.getId(), accessToken, UserType.MOJANG, + return new AuthInfo(selectedProfile.getName(), selectedProfile.getId(), accessToken, Optional.ofNullable(user.getProperties()).map(GSON_PROPERTIES::toJson).orElse("{}")); } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java index c8162e1c9..775cee0e5 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java @@ -244,7 +244,7 @@ public class DefaultLauncher extends Launcher { pair("${profile_name}", Optional.ofNullable(options.getProfileName()).orElse("Minecraft")), pair("${version_type}", version.getType().getId()), pair("${game_directory}", repository.getRunDirectory(version.getId()).getAbsolutePath()), - pair("${user_type}", authInfo.getUserType().toString().toLowerCase()), + pair("${user_type}", "mojang"), pair("${assets_index_name}", version.getAssetIndex().getId()), pair("${user_properties}", authInfo.getUserProperties()) );