[FEAT] Allow servers to limit multiple minecraft accounts per user in access control
This commit is contained in:
@@ -24,7 +24,7 @@ public class SDLinkConfig extends ModuleConfig {
|
||||
// DO NOT REMOVE TRANSIENT HERE... OTHERWISE, THE STUPID CONFIG LIBRARY
|
||||
// WILL TRY TO WRITE THESE TO THE CONFIG
|
||||
public transient static SDLinkConfig INSTANCE;
|
||||
public transient static int configVer = 13;
|
||||
public transient static int configVer = 14;
|
||||
public transient static boolean hasConfigLoaded = false;
|
||||
|
||||
@Path("general")
|
||||
|
@@ -20,6 +20,10 @@ public class AccessControl {
|
||||
@SpecComment("Does the player need to be a member of your discord to join")
|
||||
public boolean requireDiscordMembership = false;
|
||||
|
||||
@Path("allowMultipleAccounts")
|
||||
@SpecComment("Can players verify multiple Minecraft Accounts")
|
||||
public boolean allowMultipleAccounts = false;
|
||||
|
||||
@Path("requiredRoles")
|
||||
@SpecComment("Optional: The player requires any of these roles to be able to join your server")
|
||||
public List<String> requiredRoles = new ArrayList<>();
|
||||
|
@@ -5,6 +5,7 @@
|
||||
package com.hypherionmc.sdlink.core.discord.commands.slash.verification;
|
||||
|
||||
import com.hypherionmc.sdlink.core.accounts.MinecraftAccount;
|
||||
import com.hypherionmc.sdlink.core.config.SDLinkConfig;
|
||||
import com.hypherionmc.sdlink.core.database.SDLinkAccount;
|
||||
import com.hypherionmc.sdlink.core.discord.commands.slash.SDLinkSlashCommand;
|
||||
import com.hypherionmc.sdlink.core.messaging.Result;
|
||||
@@ -48,11 +49,17 @@ public class VerifyAccountCommand extends SDLinkSlashCommand {
|
||||
}
|
||||
|
||||
boolean didVerify = false;
|
||||
boolean hasRejected = false;
|
||||
|
||||
for (SDLinkAccount account : accounts) {
|
||||
if (account.getVerifyCode() == null)
|
||||
continue;
|
||||
|
||||
if (accounts.stream().anyMatch(a -> a.getDiscordID() != null && a.getDiscordID().equals(event.getMember().getId())) && !SDLinkConfig.INSTANCE.accessControl.allowMultipleAccounts) {
|
||||
event.getHook().sendMessage("Sorry, you already have a verified account and this server does not allow multiple accounts").queue();
|
||||
return;
|
||||
}
|
||||
|
||||
if (account.getVerifyCode().equalsIgnoreCase(String.valueOf(mcCode))) {
|
||||
MinecraftAccount minecraftAccount = MinecraftAccount.of(account.getUsername());
|
||||
Result result = minecraftAccount.verifyAccount(event.getMember(), event.getGuild());
|
||||
|
Reference in New Issue
Block a user