[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
|
// DO NOT REMOVE TRANSIENT HERE... OTHERWISE, THE STUPID CONFIG LIBRARY
|
||||||
// WILL TRY TO WRITE THESE TO THE CONFIG
|
// WILL TRY TO WRITE THESE TO THE CONFIG
|
||||||
public transient static SDLinkConfig INSTANCE;
|
public transient static SDLinkConfig INSTANCE;
|
||||||
public transient static int configVer = 13;
|
public transient static int configVer = 14;
|
||||||
public transient static boolean hasConfigLoaded = false;
|
public transient static boolean hasConfigLoaded = false;
|
||||||
|
|
||||||
@Path("general")
|
@Path("general")
|
||||||
|
@@ -20,6 +20,10 @@ public class AccessControl {
|
|||||||
@SpecComment("Does the player need to be a member of your discord to join")
|
@SpecComment("Does the player need to be a member of your discord to join")
|
||||||
public boolean requireDiscordMembership = false;
|
public boolean requireDiscordMembership = false;
|
||||||
|
|
||||||
|
@Path("allowMultipleAccounts")
|
||||||
|
@SpecComment("Can players verify multiple Minecraft Accounts")
|
||||||
|
public boolean allowMultipleAccounts = false;
|
||||||
|
|
||||||
@Path("requiredRoles")
|
@Path("requiredRoles")
|
||||||
@SpecComment("Optional: The player requires any of these roles to be able to join your server")
|
@SpecComment("Optional: The player requires any of these roles to be able to join your server")
|
||||||
public List<String> requiredRoles = new ArrayList<>();
|
public List<String> requiredRoles = new ArrayList<>();
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
package com.hypherionmc.sdlink.core.discord.commands.slash.verification;
|
package com.hypherionmc.sdlink.core.discord.commands.slash.verification;
|
||||||
|
|
||||||
import com.hypherionmc.sdlink.core.accounts.MinecraftAccount;
|
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.database.SDLinkAccount;
|
||||||
import com.hypherionmc.sdlink.core.discord.commands.slash.SDLinkSlashCommand;
|
import com.hypherionmc.sdlink.core.discord.commands.slash.SDLinkSlashCommand;
|
||||||
import com.hypherionmc.sdlink.core.messaging.Result;
|
import com.hypherionmc.sdlink.core.messaging.Result;
|
||||||
@@ -48,11 +49,17 @@ public class VerifyAccountCommand extends SDLinkSlashCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean didVerify = false;
|
boolean didVerify = false;
|
||||||
|
boolean hasRejected = false;
|
||||||
|
|
||||||
for (SDLinkAccount account : accounts) {
|
for (SDLinkAccount account : accounts) {
|
||||||
if (account.getVerifyCode() == null)
|
if (account.getVerifyCode() == null)
|
||||||
continue;
|
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))) {
|
if (account.getVerifyCode().equalsIgnoreCase(String.valueOf(mcCode))) {
|
||||||
MinecraftAccount minecraftAccount = MinecraftAccount.of(account.getUsername());
|
MinecraftAccount minecraftAccount = MinecraftAccount.of(account.getUsername());
|
||||||
Result result = minecraftAccount.verifyAccount(event.getMember(), event.getGuild());
|
Result result = minecraftAccount.verifyAccount(event.getMember(), event.getGuild());
|
||||||
|
Reference in New Issue
Block a user