mirror of
https://github.com/kuroppoi/entralinked.git
synced 2026-04-25 07:36:52 -05:00
Only update id of the profile the user uses next when using the pid tool
This commit is contained in:
parent
306b9e6db6
commit
3224f6312a
|
|
@ -15,7 +15,6 @@ import com.formdev.flatlaf.extras.components.FlatTextField;
|
|||
|
||||
import entralinked.Entralinked;
|
||||
import entralinked.model.user.User;
|
||||
import entralinked.model.user.UserManager;
|
||||
import entralinked.utility.SwingUtility;
|
||||
|
||||
public class PidToolDialog {
|
||||
|
|
@ -56,8 +55,7 @@ public class PidToolDialog {
|
|||
return;
|
||||
}
|
||||
|
||||
UserManager userManager = entralinked.getUserManager();
|
||||
User user = userManager.getUser(userId.substring(0, 13));
|
||||
User user = entralinked.getUserManager().getUser(userId.substring(0, 13));
|
||||
int profileId = (int)(Long.parseLong(friendCode) & 0x7FFFFFFF);
|
||||
|
||||
// Make sure user exists
|
||||
|
|
@ -66,17 +64,9 @@ public class PidToolDialog {
|
|||
return;
|
||||
}
|
||||
|
||||
// Show warning if this user has multiple profiles
|
||||
if(user.getProfiles().size() > 1) {
|
||||
if(JOptionPane.showConfirmDialog(dialog, "Multiple profiles detected. Do you want to update all of them?\n"
|
||||
+ "This may cause error 60000 to occur on your other game cartridges.",
|
||||
"Attention", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
userManager.updateProfileIdForUser(user, profileId);
|
||||
JOptionPane.showMessageDialog(dialog, "Profile has been updated. Please restart your game and use Game Sync.");
|
||||
user.setProfileIdOverride(profileId);
|
||||
JOptionPane.showMessageDialog(dialog,
|
||||
"All done! Please restart your game and use Game Sync.\nGame profile data will be updated and saved once you do so.");
|
||||
});
|
||||
|
||||
// Create content panel
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ public class User {
|
|||
private final String password; // I debated hashing it, but.. it's a 3-digit password...
|
||||
private final Map<String, GameProfile> profiles = new HashMap<>();
|
||||
private final Map<String, Dlc> dlcOverrides = new HashMap<>();
|
||||
private int profileIdOverride; // For making it easier for the user to fix error 60000
|
||||
|
||||
public User(String id, String password) {
|
||||
this.id = id;
|
||||
|
|
@ -70,4 +71,12 @@ public class User {
|
|||
public Dlc getDlcOverride(String type) {
|
||||
return dlcOverrides.get(type);
|
||||
}
|
||||
|
||||
public void setProfileIdOverride(int profileIdOverride) {
|
||||
this.profileIdOverride = profileIdOverride;
|
||||
}
|
||||
|
||||
public int getProfileIdOverride() {
|
||||
return profileIdOverride;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -233,26 +233,6 @@ public class UserManager {
|
|||
return profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will forcibly set the profile id of all profiles of this user to the specified one.
|
||||
* Potentially a destructive operation; use with caution.
|
||||
*
|
||||
* @return {@code true} if the operation was successful, otherwise {@code false}.
|
||||
*/
|
||||
public boolean updateProfileIdForUser(User user, int profileId) {
|
||||
// Set the id of all profiles
|
||||
for(GameProfile profile : user.getProfiles()) {
|
||||
profile.setId(profileId);
|
||||
}
|
||||
|
||||
// Try to save user
|
||||
if(!saveUser(user)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if a user with the specified ID exists, otherwise {@code false}.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -119,6 +119,15 @@ public class GameSpyHandler extends SimpleChannelInboundHandler<GameSpyRequest>
|
|||
}
|
||||
}
|
||||
|
||||
// Update profile id if an override is set
|
||||
int profileIdOverride = user.getProfileIdOverride();
|
||||
|
||||
if(profileIdOverride > 0) {
|
||||
profile.setId(profileIdOverride);
|
||||
user.setProfileIdOverride(0);
|
||||
userManager.saveUser(user); // It's not too big of a deal if this fails for some reason
|
||||
}
|
||||
|
||||
// Prepare and send response
|
||||
sessionKey = secureRandom.nextInt(Integer.MAX_VALUE);
|
||||
String proof = createCredentialHash(partnerChallengeHash, authToken, serverChallenge, clientChallenge);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user