Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public static class STRINGS {
public String LINK_CMD_USAGE = "{PRFX} Send '!account link {NICKNAME}' to our Social Bot{NL} VK: vk.com/123{NL} DS: Bot#0000{NL} TG: @bot";
@Placeholders({"{NICKNAME}"})
public String LINK_WRONG_CODE = "{PRFX} Wrong code, run '!account link {NICKNAME}' again";
public String LINK_CONFIRM = "{PRFX} Type the command again to confirm the account linking. DO NOT TYPE IF ANOTHER PLAYER HAS SENT YOU THIS COMMAND.";
public String LINK_SUCCESS_GAME = "{PRFX} Social was successfully linked";
public String LINK_SUCCESS = "✅ Social was successfully linked{NL}Use '!keyboard' to show keyboard";
public String LINK_ALREADY = "Account is already linked";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@

package net.elytrium.limboauth.socialaddon.command;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
import com.velocitypowered.api.proxy.Player;
import java.sql.SQLException;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;

import net.elytrium.commons.config.Placeholders;
import net.elytrium.limboauth.socialaddon.Addon;
import net.elytrium.limboauth.socialaddon.Settings;
Expand All @@ -31,6 +35,8 @@ public class ValidateLinkCommand implements SimpleCommand {

private final Addon addon;

private final Cache<String, Boolean> confirmLinking = CacheBuilder.newBuilder().expireAfterWrite(15, TimeUnit.SECONDS).build();

public ValidateLinkCommand(Addon addon) {
this.addon = addon;
}
Expand All @@ -51,6 +57,12 @@ public void execute(Invocation invocation) {
Integer validCode = this.addon.getCode(username);
if (validCode != null) {
if (validCode == Integer.parseInt(args[0])) {
if (confirmLinking.getIfPresent(username) == null) {
confirmLinking.put(username, true);
source.sendMessage(Addon.getSerializer().deserialize(Settings.IMP.MAIN.STRINGS.LINK_CONFIRM));
return;
}
confirmLinking.invalidate(username);
Addon.TempAccount tempAccount = this.addon.getTempAccount(username);
this.addon.linkSocial(username, tempAccount.getDbField(), tempAccount.getId());
this.addon.getSocialManager().registerHook(tempAccount.getDbField(), tempAccount.getId());
Expand Down