[FEAT] Add events for Access Control Player changes
This commit is contained in:
@@ -4,9 +4,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.hypherionmc.sdlink.core.accounts;
|
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.config.SDLinkConfig;
|
||||||
import com.hypherionmc.sdlink.core.database.SDLinkAccount;
|
import com.hypherionmc.sdlink.core.database.SDLinkAccount;
|
||||||
import com.hypherionmc.sdlink.core.discord.BotController;
|
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.CacheManager;
|
||||||
import com.hypherionmc.sdlink.core.managers.RoleManager;
|
import com.hypherionmc.sdlink.core.managers.RoleManager;
|
||||||
import com.hypherionmc.sdlink.core.messaging.Result;
|
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");
|
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");
|
return Result.success("Your account has been un-verified");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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() {
|
public JDA getJDA() {
|
||||||
return this._jda;
|
return this._jda;
|
||||||
}
|
}
|
||||||
|
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user