com.velocitypowered.api.event.connection.PostLoginEvent Java Examples
The following examples show how to use
com.velocitypowered.api.event.connection.PostLoginEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlayerEvents.java From AntiVPN with MIT License | 5 votes |
public PlayerEvents(Object plugin, ProxyServer proxy) { this.proxy = proxy; events.add( VelocityEvents.subscribe(plugin, proxy, PreLoginEvent.class, PostOrder.LATE) .handler(this::cachePlayer) ); events.add( VelocityEvents.subscribe(plugin, proxy, PostLoginEvent.class, PostOrder.FIRST) .handler(this::checkPlayer) ); }
Example #2
Source File: PlayerOnlineListener.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
@Subscribe(order = PostOrder.LAST) public void onPostLogin(PostLoginEvent event) { try { actOnLogin(event); } catch (Exception e) { errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build()); } }
Example #3
Source File: PlayerOnlineListener.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
public void actOnLogin(PostLoginEvent event) { Player player = event.getPlayer(); UUID playerUUID = player.getUniqueId(); String playerName = player.getUsername(); InetAddress address = player.getRemoteAddress().getAddress(); long time = System.currentTimeMillis(); Session session = new Session(playerUUID, serverInfo.getServerUUID(), time, null, null); session.putRawData(SessionKeys.NAME, playerName); session.putRawData(SessionKeys.SERVER_NAME, "Proxy Server"); sessionCache.cacheSession(playerUUID, session); Database database = dbSystem.getDatabase(); boolean gatheringGeolocations = config.isTrue(DataGatheringSettings.GEOLOCATIONS); if (gatheringGeolocations) { database.executeTransaction( new GeoInfoStoreTransaction(playerUUID, address, time, geolocationCache::getCountry) ); } database.executeTransaction(new PlayerRegisterTransaction(playerUUID, () -> time, playerName)); processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_JOIN)); if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) { processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName)); } UUID serverUUID = serverInfo.getServerUUID(); JSONCache.invalidateMatching(DataID.SERVER_OVERVIEW); JSONCache.invalidate(DataID.GRAPH_ONLINE, serverUUID); JSONCache.invalidate(DataID.SERVERS); JSONCache.invalidate(DataID.SESSIONS); }
Example #4
Source File: UpdateListener.java From ViaVersion with MIT License | 5 votes |
@Subscribe public void onJoin(PostLoginEvent e) { if (e.getPlayer().hasPermission("viaversion.update") && Via.getConfig().isCheckForUpdates()) { UpdateUtil.sendUpdateMessage(e.getPlayer().getUniqueId()); } }
Example #5
Source File: PlayerEvents.java From AntiVPN with MIT License | 4 votes |
private void tryKickPlayer(String message, Player player, PostLoginEvent event) { player.disconnect(LegacyComponentSerializer.legacy().deserialize(message, '&')); }
Example #6
Source File: LoginSessionHandler.java From Velocity with MIT License | 4 votes |
private void finishLogin(ConnectedPlayer player) { Optional<RegisteredServer> toTry = player.getNextServerToTry(); if (!toTry.isPresent()) { player.disconnect(VelocityMessages.NO_AVAILABLE_SERVERS); return; } int threshold = server.getConfiguration().getCompressionThreshold(); if (threshold >= 0) { mcConnection.write(new SetCompression(threshold)); mcConnection.setCompressionThreshold(threshold); } VelocityConfiguration configuration = server.getConfiguration(); UUID playerUniqueId = player.getUniqueId(); if (configuration.getPlayerInfoForwardingMode() == PlayerInfoForwarding.NONE) { playerUniqueId = UuidUtils.generateOfflinePlayerUuid(player.getUsername()); } ServerLoginSuccess success = new ServerLoginSuccess(); success.setUsername(player.getUsername()); success.setUuid(playerUniqueId); mcConnection.write(success); mcConnection.setAssociation(player); mcConnection.setState(StateRegistry.PLAY); server.getEventManager().fire(new LoginEvent(player)) .thenAcceptAsync(event -> { if (mcConnection.isClosed()) { // The player was disconnected return; } Optional<Component> reason = event.getResult().getReason(); if (reason.isPresent()) { player.disconnect(reason.get()); } else { if (!server.registerConnection(player)) { player.disconnect(VelocityMessages.ALREADY_CONNECTED); return; } mcConnection.setSessionHandler(new InitialConnectSessionHandler(player)); server.getEventManager().fire(new PostLoginEvent(player)) .thenRun(() -> player.createConnectionRequest(toTry.get()).fireAndForget()); } }, mcConnection.eventLoop()); }