[FEAT] Add events for Access Control Player changes

This commit is contained in:
2024-03-17 13:44:56 +02:00
parent 921a109338
commit 9248a302a6
3 changed files with 44 additions and 9 deletions

View File

@@ -4,9 +4,11 @@
*/
package com.hypherionmc.sdlink.core.accounts;
import com.hypherionmc.craterlib.core.event.CraterEventBus;
import com.hypherionmc.sdlink.core.config.SDLinkConfig;
import com.hypherionmc.sdlink.core.database.SDLinkAccount;
import com.hypherionmc.sdlink.core.discord.BotController;
import com.hypherionmc.sdlink.core.events.VerificationEvent;
import com.hypherionmc.sdlink.core.managers.CacheManager;
import com.hypherionmc.sdlink.core.managers.RoleManager;
import com.hypherionmc.sdlink.core.messaging.Result;
@@ -218,6 +220,8 @@ public class MinecraftAccount {
}
}
CraterEventBus.INSTANCE.postEvent(new VerificationEvent.PlayerVerified(this));
return Result.success("Your account has been verified");
}
@@ -249,6 +253,8 @@ public class MinecraftAccount {
}
}
CraterEventBus.INSTANCE.postEvent(new VerificationEvent.PlayerUnverified(this));
return Result.success("Your account has been un-verified");
}

View File

@@ -203,15 +203,6 @@ public class BotController {
}
}
/**
* Ensure that whitelisting is set up properly, so the bot can use the feature
*/
public void checkWhiteListing() {
if (SDLinkConfig.INSTANCE.accessControl.enabled && !SDLinkPlatform.minecraftHelper.checkWhitelisting().isError()) {
getLogger().error("SDLink Access Control is enabled, but so is whitelisting on your server. You need to disable whitelisting to use the AccessControl feature");
}
}
public JDA getJDA() {
return this._jda;
}

View File

@@ -0,0 +1,38 @@
package com.hypherionmc.sdlink.core.events;
import com.hypherionmc.craterlib.core.event.CraterEvent;
import com.hypherionmc.sdlink.core.accounts.MinecraftAccount;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* @author HypherionSA
* Events that get triggered when the bot verification list changes
*/
public class VerificationEvent {
@Getter
@RequiredArgsConstructor
public static class PlayerVerified extends CraterEvent {
private final MinecraftAccount account;
@Override
public boolean canCancel() {
return false;
}
}
@Getter
@RequiredArgsConstructor
public static class PlayerUnverified extends CraterEvent {
private final MinecraftAccount account;
@Override
public boolean canCancel() {
return false;
}
}
}