Skip to content

Commit

Permalink
Properly unlink accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
UserNugget committed Sep 14, 2024
1 parent e74b649 commit 341a239
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/net/elytrium/limboauth/socialaddon/Addon.java
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,11 @@ private void load() {
return;
}

Long playerId = SocialPlayer.DatabaseField.valueOf(dbField).getIdFor(player);
SocialPlayer.DatabaseField.valueOf(dbField).setIdFor(player, null);
boolean allUnlinked = Arrays.stream(SocialPlayer.DatabaseField.values())
.noneMatch(v -> v.getIdFor(player) != null);
SocialPlayer.DatabaseField.valueOf(dbField).setIdFor(player, playerId);

if (Settings.IMP.MAIN.UNLINK_BTN_ALL || allUnlinked) {
this.socialManager.unregisterHook(player);
Expand All @@ -548,7 +551,6 @@ private void load() {

this.socialManager.unregisterHook(dbField, player);
}
SocialPlayer.DatabaseField.valueOf(dbField).setIdFor(player, null);

this.socialManager.broadcastMessage(dbField, id, Settings.IMP.MAIN.STRINGS.UNLINK_SUCCESS);
this.server.getPlayer(player.getLowercaseNickname()).ifPresent(p ->
Expand Down Expand Up @@ -620,6 +622,7 @@ public void unregisterPlayer(String nickname) {

public void linkSocial(String lowercaseNickname, String dbField, Long id) throws SQLException {
SocialPlayer socialPlayer = this.dao.queryForId(lowercaseNickname);
System.out.println(socialPlayer);
if (socialPlayer == null) {
Settings.IMP.MAIN.AFTER_LINKAGE_COMMANDS.forEach(command ->
this.server.getCommandManager().executeAsync(p -> Tristate.TRUE, command.replace("{NICKNAME}", lowercaseNickname)));
Expand Down

0 comments on commit 341a239

Please sign in to comment.