use of uk.co.notnull.proxydiscord.api.VerificationResult in project ProxyQueues by JLyne.
the class ProxyDiscordHandler method onPlayerJoinQueue.
@Subscribe
public void onPlayerJoinQueue(PlayerQueueEvent event) {
if (event.isCancelled()) {
return;
}
if (verificationManager.isPublicServer(event.getServer())) {
return;
}
VerificationResult result = verificationManager.checkVerificationStatus(event.getPlayer());
if (result.isVerified()) {
Optional<ServerConnection> currentServer = event.getPlayer().getCurrentServer();
if (currentServer.isPresent() && verificationManager.isPublicServer(currentServer.get().getServer())) {
if (plugin.getWaitingServer().isPresent()) {
event.getPlayer().createConnectionRequest(plugin.getWaitingServer().get()).fireAndForget();
}
}
return;
}
event.setCancelled(true);
RegisteredServer linkingServer = verificationManager.getLinkingServer();
RegisteredServer currentServer = event.getPlayer().getCurrentServer().map(ServerConnection::getServer).orElse(null);
if (linkingServer != null && (currentServer == null || !currentServer.equals(linkingServer))) {
event.getPlayer().createConnectionRequest(linkingServer).fireAndForget();
}
switch(result) {
case NOT_LINKED:
event.setReason(Messages.get("errors.discord-not-linked"));
break;
case LINKED_NOT_VERIFIED:
event.setReason(Messages.get("errors.discord-not-verified"));
break;
default:
event.setReason("An error has occurred.");
}
}
Aggregations