mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 02:37:34 +02:00
Use BungeeCord event methods for kicking the player
This commit is contained in:
@ -6,13 +6,16 @@ import java.net.InetSocketAddress;
|
|||||||
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.connection.PendingConnection;
|
import net.md_5.bungee.api.connection.PendingConnection;
|
||||||
|
import net.md_5.bungee.api.event.PreLoginEvent;
|
||||||
|
|
||||||
public class BungeeLoginSource implements LoginSource {
|
public class BungeeLoginSource implements LoginSource {
|
||||||
|
|
||||||
private final PendingConnection connection;
|
private final PendingConnection connection;
|
||||||
|
private final PreLoginEvent preLoginEvent;
|
||||||
|
|
||||||
public BungeeLoginSource(PendingConnection connection) {
|
public BungeeLoginSource(PendingConnection connection, PreLoginEvent preLoginEvent) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
|
this.preLoginEvent = preLoginEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -22,7 +25,10 @@ public class BungeeLoginSource implements LoginSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void kick(String message) {
|
public void kick(String message) {
|
||||||
connection.disconnect(TextComponent.fromLegacyText(message));
|
preLoginEvent.setCancelled(true);
|
||||||
|
|
||||||
|
if (message != null)
|
||||||
|
preLoginEvent.setCancelReason(TextComponent.fromLegacyText(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,23 +6,23 @@ import com.github.games647.fastlogin.bungee.FastLoginBungee;
|
|||||||
import com.github.games647.fastlogin.bungee.event.BungeeFastLoginPreLoginEvent;
|
import com.github.games647.fastlogin.bungee.event.BungeeFastLoginPreLoginEvent;
|
||||||
import com.github.games647.fastlogin.core.StoredProfile;
|
import com.github.games647.fastlogin.core.StoredProfile;
|
||||||
import com.github.games647.fastlogin.core.shared.JoinManagement;
|
import com.github.games647.fastlogin.core.shared.JoinManagement;
|
||||||
|
|
||||||
import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent;
|
import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent;
|
||||||
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.PendingConnection;
|
import net.md_5.bungee.api.connection.PendingConnection;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.AsyncEvent;
|
import net.md_5.bungee.api.event.PreLoginEvent;
|
||||||
import net.md_5.bungee.connection.InitialHandler;
|
import net.md_5.bungee.connection.InitialHandler;
|
||||||
|
|
||||||
public class AsyncPremiumCheck extends JoinManagement<ProxiedPlayer, CommandSender, BungeeLoginSource>
|
public class AsyncPremiumCheck extends JoinManagement<ProxiedPlayer, CommandSender, BungeeLoginSource>
|
||||||
implements Runnable {
|
implements Runnable {
|
||||||
|
|
||||||
private final FastLoginBungee plugin;
|
private final FastLoginBungee plugin;
|
||||||
private final AsyncEvent<?> preLoginEvent;
|
private final PreLoginEvent preLoginEvent;
|
||||||
|
|
||||||
private final PendingConnection connection;
|
private final PendingConnection connection;
|
||||||
|
|
||||||
public AsyncPremiumCheck(FastLoginBungee plugin, AsyncEvent<?> preLoginEvent, PendingConnection connection) {
|
public AsyncPremiumCheck(FastLoginBungee plugin, PreLoginEvent preLoginEvent, PendingConnection connection) {
|
||||||
super(plugin.getCore(), plugin.getCore().getAuthPluginHook());
|
super(plugin.getCore(), plugin.getCore().getAuthPluginHook());
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@ -37,7 +37,7 @@ public class AsyncPremiumCheck extends JoinManagement<ProxiedPlayer, CommandSend
|
|||||||
InitialHandler initialHandler = (InitialHandler) connection;
|
InitialHandler initialHandler = (InitialHandler) connection;
|
||||||
String username = initialHandler.getLoginRequest().getData();
|
String username = initialHandler.getLoginRequest().getData();
|
||||||
try {
|
try {
|
||||||
super.onLogin(username, new BungeeLoginSource(connection));
|
super.onLogin(username, new BungeeLoginSource(connection, preLoginEvent));
|
||||||
} finally {
|
} finally {
|
||||||
preLoginEvent.completeIntent(plugin);
|
preLoginEvent.completeIntent(plugin);
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,10 @@ import com.github.games647.craftapi.model.Profile;
|
|||||||
import com.github.games647.craftapi.resolver.RateLimitException;
|
import com.github.games647.craftapi.resolver.RateLimitException;
|
||||||
import com.github.games647.fastlogin.core.StoredProfile;
|
import com.github.games647.fastlogin.core.StoredProfile;
|
||||||
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
|
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
|
||||||
|
import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent;
|
|
||||||
import net.md_5.bungee.config.Configuration;
|
import net.md_5.bungee.config.Configuration;
|
||||||
|
|
||||||
public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
|
public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
|
||||||
|
Reference in New Issue
Block a user