mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-19 08:46:09 -04:00
移除对legcay账户的支持
This commit is contained in:
parent
6782602141
commit
06af79e2b4
@ -32,19 +32,17 @@ public final class AuthInfo {
|
|||||||
private final String username;
|
private final String username;
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
private final String accessToken;
|
private final String accessToken;
|
||||||
private final UserType userType;
|
|
||||||
private final String userProperties;
|
private final String userProperties;
|
||||||
private final Arguments arguments;
|
private final Arguments arguments;
|
||||||
|
|
||||||
public AuthInfo(String username, UUID uuid, String accessToken, UserType userType, String userProperties) {
|
public AuthInfo(String username, UUID uuid, String accessToken, String userProperties) {
|
||||||
this(username, uuid, accessToken, userType, userProperties, null);
|
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.username = username;
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
this.userType = userType;
|
|
||||||
this.userProperties = userProperties;
|
this.userProperties = userProperties;
|
||||||
this.arguments = arguments;
|
this.arguments = arguments;
|
||||||
}
|
}
|
||||||
@ -61,10 +59,6 @@ public final class AuthInfo {
|
|||||||
return accessToken;
|
return accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserType getUserType() {
|
|
||||||
return userType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Properties of this user.
|
* Properties of this user.
|
||||||
* Don't know the difference between user properties and user property map.
|
* 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) {
|
public AuthInfo withArguments(Arguments arguments) {
|
||||||
return new AuthInfo(username, uuid, accessToken, userType, userProperties, arguments);
|
return new AuthInfo(username, uuid, accessToken, userProperties, arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Hello Minecraft! Launcher.
|
|
||||||
* Copyright (C) 2018 huangyuhui <huanghongxun2008@126.com>
|
|
||||||
*
|
|
||||||
* 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<String, UserType> byName = new HashMap<>();
|
|
||||||
for (UserType type : values())
|
|
||||||
byName.put(type.name().toLowerCase(), type);
|
|
||||||
BY_NAME = Collections.unmodifiableMap(byName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Map<String, UserType> BY_NAME;
|
|
||||||
|
|
||||||
}
|
|
@ -27,7 +27,6 @@ import java.util.UUID;
|
|||||||
import org.jackhuang.hmcl.auth.Account;
|
import org.jackhuang.hmcl.auth.Account;
|
||||||
import org.jackhuang.hmcl.auth.AuthInfo;
|
import org.jackhuang.hmcl.auth.AuthInfo;
|
||||||
import org.jackhuang.hmcl.auth.AuthenticationException;
|
import org.jackhuang.hmcl.auth.AuthenticationException;
|
||||||
import org.jackhuang.hmcl.auth.UserType;
|
|
||||||
import org.jackhuang.hmcl.util.StringUtils;
|
import org.jackhuang.hmcl.util.StringUtils;
|
||||||
import org.jackhuang.hmcl.util.ToStringBuilder;
|
import org.jackhuang.hmcl.util.ToStringBuilder;
|
||||||
import org.jackhuang.hmcl.util.UUIDTypeAdapter;
|
import org.jackhuang.hmcl.util.UUIDTypeAdapter;
|
||||||
@ -72,7 +71,7 @@ public class OfflineAccount extends Account {
|
|||||||
if (StringUtils.isBlank(username))
|
if (StringUtils.isBlank(username))
|
||||||
throw new AuthenticationException("Username cannot be empty");
|
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
|
@Override
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package org.jackhuang.hmcl.auth.yggdrasil;
|
package org.jackhuang.hmcl.auth.yggdrasil;
|
||||||
|
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
import org.jackhuang.hmcl.auth.UserType;
|
|
||||||
import org.jackhuang.hmcl.util.Immutable;
|
import org.jackhuang.hmcl.util.Immutable;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
@ -34,7 +33,6 @@ public final class GameProfile {
|
|||||||
private final UUID id;
|
private final UUID id;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final PropertyMap properties;
|
private final PropertyMap properties;
|
||||||
private final boolean legacy;
|
|
||||||
|
|
||||||
public GameProfile() {
|
public GameProfile() {
|
||||||
this(null, null);
|
this(null, null);
|
||||||
@ -45,14 +43,9 @@ public final class GameProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GameProfile(UUID id, String name, PropertyMap properties) {
|
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.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
this.legacy = legacy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
@ -70,14 +63,6 @@ public final class GameProfile {
|
|||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLegacy() {
|
|
||||||
return legacy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserType getUserType() {
|
|
||||||
return UserType.fromLegacy(isLegacy());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Serializer implements JsonSerializer<GameProfile>, JsonDeserializer<GameProfile> {
|
public static class Serializer implements JsonSerializer<GameProfile>, JsonDeserializer<GameProfile> {
|
||||||
|
|
||||||
public static final Serializer INSTANCE = new Serializer();
|
public static final Serializer INSTANCE = new Serializer();
|
||||||
|
@ -9,7 +9,6 @@ import java.util.Optional;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.jackhuang.hmcl.auth.AuthInfo;
|
import org.jackhuang.hmcl.auth.AuthInfo;
|
||||||
import org.jackhuang.hmcl.auth.UserType;
|
|
||||||
import org.jackhuang.hmcl.util.UUIDTypeAdapter;
|
import org.jackhuang.hmcl.util.UUIDTypeAdapter;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
@ -88,7 +87,7 @@ public class YggdrasilSession {
|
|||||||
if (user == null)
|
if (user == null)
|
||||||
throw new IllegalStateException("No user is specified");
|
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("{}"));
|
Optional.ofNullable(user.getProperties()).map(GSON_PROPERTIES::toJson).orElse("{}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ public class DefaultLauncher extends Launcher {
|
|||||||
pair("${profile_name}", Optional.ofNullable(options.getProfileName()).orElse("Minecraft")),
|
pair("${profile_name}", Optional.ofNullable(options.getProfileName()).orElse("Minecraft")),
|
||||||
pair("${version_type}", version.getType().getId()),
|
pair("${version_type}", version.getType().getId()),
|
||||||
pair("${game_directory}", repository.getRunDirectory(version.getId()).getAbsolutePath()),
|
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("${assets_index_name}", version.getAssetIndex().getId()),
|
||||||
pair("${user_properties}", authInfo.getUserProperties())
|
pair("${user_properties}", authInfo.getUserProperties())
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user