mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FIX] Duplicate profileUUID error
This commit is contained in:
parent
e5f714e0f5
commit
ae82964a24
3 changed files with 22 additions and 8 deletions
|
@ -122,7 +122,7 @@ public final class LaunchServer implements Runnable, AutoCloseable, Reconfigurab
|
|||
public LaunchServerConfig config;
|
||||
public volatile Map<String, HashedDir> updatesDirMap;
|
||||
// Updates and profiles
|
||||
private volatile List<ClientProfile> profilesList;
|
||||
private volatile Set<ClientProfile> profilesList;
|
||||
|
||||
public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, LaunchServerConfig config, LaunchServerRuntimeConfig runtimeConfig, LaunchServerConfigManager launchServerConfigManager, LaunchServerModulesManager modulesManager, KeyAgreementManager keyAgreementManager, CommandHandler commandHandler, CertificateManager certificateManager) throws IOException {
|
||||
this.dir = directories.dir;
|
||||
|
@ -297,12 +297,12 @@ public void close() throws Exception {
|
|||
logger.info("LaunchServer stopped");
|
||||
}
|
||||
|
||||
public List<ClientProfile> getProfiles() {
|
||||
public Set<ClientProfile> getProfiles() {
|
||||
return profilesList;
|
||||
}
|
||||
|
||||
public void setProfiles(List<ClientProfile> profilesList) {
|
||||
this.profilesList = Collections.unmodifiableList(profilesList);
|
||||
public void setProfiles(Set<ClientProfile> profilesList) {
|
||||
this.profilesList = Collections.unmodifiableSet(profilesList);
|
||||
}
|
||||
|
||||
public HashedDir getUpdateDir(String name) {
|
||||
|
@ -385,7 +385,7 @@ public void syncProfilesDir() throws IOException {
|
|||
|
||||
// Sort and set new profiles
|
||||
newProfies.sort(Comparator.comparing(a -> a));
|
||||
profilesList = Collections.unmodifiableList(newProfies);
|
||||
profilesList = Set.copyOf(newProfies);
|
||||
if (pingServerManager != null)
|
||||
pingServerManager.syncServers();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ProfilesResponse extends SimpleResponse {
|
||||
@Override
|
||||
|
@ -24,7 +25,7 @@ public void execute(ChannelHandlerContext ctx, Client client) {
|
|||
}
|
||||
|
||||
List<ClientProfile> profileList;
|
||||
List<ClientProfile> serverProfiles = server.getProfiles();
|
||||
Set<ClientProfile> serverProfiles = server.getProfiles();
|
||||
if (server.config.protectHandler instanceof ProfilesProtectHandler) {
|
||||
ProfilesProtectHandler protectHandler = (ProfilesProtectHandler) server.config.protectHandler;
|
||||
profileList = new ArrayList<>(4);
|
||||
|
@ -34,7 +35,7 @@ public void execute(ChannelHandlerContext ctx, Client client) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
profileList = serverProfiles;
|
||||
profileList = List.copyOf(serverProfiles);
|
||||
}
|
||||
sendResult(new ProfilesRequestEvent(profileList));
|
||||
}
|
||||
|
|
|
@ -379,7 +379,7 @@ public boolean isUpdateFastCheck() {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return title;
|
||||
return String.format("%s (%s)", title, uuid);
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
|
@ -472,6 +472,19 @@ public List<String> getCompatClasses() {
|
|||
return Collections.unmodifiableList(compatClasses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ClientProfile profile = (ClientProfile) o;
|
||||
return Objects.equals(uuid, profile.uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(uuid);
|
||||
}
|
||||
|
||||
public enum Version {
|
||||
MC125("1.2.5", 29),
|
||||
MC147("1.4.7", 51),
|
||||
|
|
Loading…
Reference in a new issue