use of com.velocitypowered.api.proxy.InboundConnection in project FastLogin by games647.
the class ConnectListener method onPreLogin.
@Subscribe
public void onPreLogin(PreLoginEvent preLoginEvent, Continuation continuation) {
if (!preLoginEvent.getResult().isAllowed()) {
return;
}
InboundConnection connection = preLoginEvent.getConnection();
if (!rateLimiter.tryAcquire()) {
plugin.getLog().warn("Simple Anti-Bot join limit - Ignoring {}", connection);
return;
}
String username = preLoginEvent.getUsername();
plugin.getLog().info("Incoming login request for {} from {}", username, connection.getRemoteAddress());
Runnable asyncPremiumCheck = new AsyncPremiumCheck(plugin, connection, username, continuation, preLoginEvent);
plugin.getScheduler().runAsync(asyncPremiumCheck);
}
use of com.velocitypowered.api.proxy.InboundConnection in project Floodgate by GeyserMC.
the class VelocityListener method onPreLogin.
@Subscribe(order = PostOrder.EARLY)
public void onPreLogin(PreLoginEvent event) {
FloodgatePlayer player = null;
String kickMessage;
try {
InboundConnection connection = event.getConnection();
if (INITIAL_CONNECTION_DELEGATE != null) {
// Velocity 3.1.0 added LoginInboundConnection which is used in the login state,
// but that class doesn't have a Channel field. However, it does have
// InitialInboundConnection as a field
connection = getCastedValue(connection, INITIAL_CONNECTION_DELEGATE);
}
Object mcConnection = getValue(connection, INITIAL_MINECRAFT_CONNECTION);
Channel channel = getCastedValue(mcConnection, CHANNEL);
player = channel.attr(playerAttribute).get();
kickMessage = channel.attr(kickMessageAttribute).get();
} catch (Exception exception) {
logger.error("Failed get the FloodgatePlayer from the player's channel", exception);
kickMessage = "Failed to get the FloodgatePlayer from the players's Channel";
}
if (kickMessage != null) {
event.setResult(PreLoginEvent.PreLoginComponentResult.denied(Component.text(kickMessage)));
return;
}
if (player != null) {
event.setResult(PreLoginEvent.PreLoginComponentResult.forceOfflineMode());
playerCache.put(event.getConnection(), player);
}
}
Aggregations