* Save accounts in hmcl dir * close #1377: Add conversion button * fix YggdrasilAccount::getIdentifier() * Check whether the account exists before moving * Add server url to selected account * Add global prefix
This commit is contained in:
@@ -23,12 +23,15 @@ import javafx.beans.Observable;
|
||||
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.binding.ObjectBinding;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import org.jackhuang.hmcl.auth.yggdrasil.Texture;
|
||||
import org.jackhuang.hmcl.auth.yggdrasil.TextureType;
|
||||
import org.jackhuang.hmcl.util.ToStringBuilder;
|
||||
import org.jackhuang.hmcl.util.javafx.ObservableHelper;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -71,7 +74,23 @@ public abstract class Account implements Observable {
|
||||
public void clearCache() {
|
||||
}
|
||||
|
||||
private ObservableHelper helper = new ObservableHelper(this);
|
||||
private final BooleanProperty portable = new SimpleBooleanProperty(false);
|
||||
|
||||
public BooleanProperty portableProperty() {
|
||||
return portable;
|
||||
}
|
||||
|
||||
public boolean isPortable() {
|
||||
return portable.get();
|
||||
}
|
||||
|
||||
public void setPortable(boolean value) {
|
||||
this.portable.set(value);
|
||||
}
|
||||
|
||||
public abstract String getIdentifier();
|
||||
|
||||
private final ObservableHelper helper = new ObservableHelper(this);
|
||||
|
||||
@Override
|
||||
public void addListener(InvalidationListener listener) {
|
||||
@@ -95,12 +114,29 @@ public abstract class Account implements Observable {
|
||||
return Bindings.createObjectBinding(Optional::empty);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(portable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!(obj instanceof Account))
|
||||
return false;
|
||||
|
||||
Account another = (Account) obj;
|
||||
return isPortable() == another.isPortable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this)
|
||||
.append("username", getUsername())
|
||||
.append("character", getCharacter())
|
||||
.append("uuid", getUUID())
|
||||
.append("portable", isPortable())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +153,11 @@ public class AuthlibInjectorAccount extends YggdrasilAccount {
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return server.getUrl() + ":" + super.getIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), server.hashCode());
|
||||
@@ -163,7 +168,8 @@ public class AuthlibInjectorAccount extends YggdrasilAccount {
|
||||
if (obj == null || obj.getClass() != AuthlibInjectorAccount.class)
|
||||
return false;
|
||||
AuthlibInjectorAccount another = (AuthlibInjectorAccount) obj;
|
||||
return characterUUID.equals(another.characterUUID) && server.equals(another.server);
|
||||
return isPortable() == another.isPortable()
|
||||
&& characterUUID.equals(another.characterUUID) && server.equals(another.server);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -77,6 +77,11 @@ public class MicrosoftAccount extends OAuthAccount {
|
||||
return session.getProfile().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "microsoft:" + getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthInfo logIn() throws AuthenticationException {
|
||||
if (!authenticated) {
|
||||
@@ -163,6 +168,6 @@ public class MicrosoftAccount extends OAuthAccount {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MicrosoftAccount that = (MicrosoftAccount) o;
|
||||
return characterUUID.equals(that.characterUUID);
|
||||
return this.isPortable() == that.isPortable() && characterUUID.equals(that.characterUUID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,11 @@ public class OfflineAccount extends Account {
|
||||
return username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return username + ":" + username;
|
||||
}
|
||||
|
||||
public Skin getSkin() {
|
||||
return skin;
|
||||
}
|
||||
@@ -222,6 +227,6 @@ public class OfflineAccount extends Account {
|
||||
if (!(obj instanceof OfflineAccount))
|
||||
return false;
|
||||
OfflineAccount another = (OfflineAccount) obj;
|
||||
return username.equals(another.username);
|
||||
return isPortable() == another.isPortable() && username.equals(another.username);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +98,11 @@ public class YggdrasilAccount extends ClassicAccount {
|
||||
return session.getSelectedProfile().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return getUsername() + ":" + getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized AuthInfo logIn() throws AuthenticationException {
|
||||
if (!authenticated) {
|
||||
@@ -223,6 +228,6 @@ public class YggdrasilAccount extends ClassicAccount {
|
||||
if (obj == null || obj.getClass() != YggdrasilAccount.class)
|
||||
return false;
|
||||
YggdrasilAccount another = (YggdrasilAccount) obj;
|
||||
return characterUUID.equals(another.characterUUID);
|
||||
return isPortable() == another.isPortable() && characterUUID.equals(another.characterUUID);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user