org.spongepowered.api.event.network.ClientConnectionEvent Java Examples
The following examples show how to use
org.spongepowered.api.event.network.ClientConnectionEvent.
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: PlayerOnlineListener.java From Plan with GNU Lesser General Public License v3.0 | 6 votes |
private void actOnQuitEvent(ClientConnectionEvent.Disconnect event) { long time = System.currentTimeMillis(); Player player = event.getTargetEntity(); String playerName = player.getName(); UUID playerUUID = player.getUniqueId(); UUID serverUUID = serverInfo.getServerUUID(); JSONCache.invalidate(DataID.SERVER_OVERVIEW, serverUUID); JSONCache.invalidate(DataID.GRAPH_PERFORMANCE, serverUUID); SpongeAFKListener.AFK_TRACKER.loggedOut(playerUUID, time); nicknameCache.removeDisplayName(playerUUID); boolean banned = isBanned(player.getProfile()); dbSystem.getDatabase().executeTransaction(new BanStatusTransaction(playerUUID, () -> banned)); sessionCache.endSession(playerUUID, time) .ifPresent(endedSession -> dbSystem.getDatabase().executeTransaction(new SessionEndTransaction(endedSession))); if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) { processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName)); } }
Example #2
Source File: PlayerDisconnectListener.java From EagleFactions with MIT License | 6 votes |
@Listener(order = Order.POST) public void onDisconnect(ClientConnectionEvent.Disconnect event, @Root Player player) { if (super.getPlugin().getPVPLogger().isActive() && EagleFactionsPlugin.getPlugin().getPVPLogger().isPlayerBlocked(player)) { player.damage(1000, DamageSource.builder().type(DamageTypes.ATTACK).build()); super.getPlugin().getPVPLogger().removePlayer(player); } EagleFactionsPlugin.REGEN_CONFIRMATION_MAP.remove(player.getUniqueId()); final Optional<Faction> optionalFaction = getPlugin().getFactionLogic().getFactionByPlayerUUID(player.getUniqueId()); optionalFaction.ifPresent(faction -> getPlugin().getFactionLogic().setLastOnline(faction, Instant.now())); //TODO: Unload player cache... FactionsCache.removePlayer(player.getUniqueId()); }
Example #3
Source File: PlayerEventHandler.java From GriefDefender with MIT License | 6 votes |
@Listener(order= Order.LAST) public void onPlayerQuit(ClientConnectionEvent.Disconnect event) { final Player player = event.getTargetEntity(); if (!SpongeImpl.getServer().isServerRunning() || !GriefDefenderPlugin.getInstance().claimsEnabledForWorld(player.getWorld().getUniqueId())) { return; } GDTimings.PLAYER_QUIT_EVENT.startTimingIfSync(); UUID playerID = player.getUniqueId(); GDPlayerData playerData = this.dataStore.getOrCreatePlayerData(player.getWorld(), playerID); if (this.worldEditProvider != null) { this.worldEditProvider.revertVisuals(player, playerData, null); this.worldEditProvider.removePlayer(player); } playerData.onDisconnect(); PaginationUtil.getInstance().removeActivePageData(player.getUniqueId()); if (playerData.getClaims().isEmpty()) { this.dataStore.clearCachedPlayerData(player.getWorld().getUniqueId(), playerID); } GDCallbackHolder.getInstance().onPlayerDisconnect(player); GDTimings.PLAYER_QUIT_EVENT.stopTimingIfSync(); }
Example #4
Source File: PlayerEventHandler.java From GriefDefender with MIT License | 6 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onPlayerLogin(ClientConnectionEvent.Login event) { GDTimings.PLAYER_LOGIN_EVENT.startTimingIfSync(); User player = event.getTargetUser(); if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(event.getToTransform().getExtent().getUniqueId())) { GDTimings.PLAYER_LOGIN_EVENT.stopTimingIfSync(); return; } final WorldProperties worldProperties = event.getToTransform().getExtent().getProperties(); final UUID playerUniqueId = player.getUniqueId(); final GDClaimManager claimWorldManager = this.dataStore.getClaimWorldManager(worldProperties.getUniqueId()); final Instant dateNow = Instant.now(); for (Claim claim : claimWorldManager.getWorldClaims()) { if (claim.getType() != ClaimTypes.ADMIN && claim.getOwnerUniqueId().equals(playerUniqueId)) { claim.getData().setDateLastActive(dateNow); for (Claim subdivision : ((GDClaim) claim).children) { subdivision.getData().setDateLastActive(dateNow); } ((GDClaim) claim).getInternalClaimData().setRequiresSave(true); ((GDClaim) claim).getInternalClaimData().save(); } } GDTimings.PLAYER_LOGIN_EVENT.stopTimingIfSync(); }
Example #5
Source File: VirtualChestPlugin.java From VirtualChest with GNU Lesser General Public License v3.0 | 6 votes |
@Listener public void onClientConnectionJoin(ClientConnectionEvent.Join event) { Server server = Sponge.getServer(); if (server.getOnlineMode()) { // prefetch the profile when a player joins the server // TODO: maybe we should also prefetch player profiles in offline mode GameProfile profile = event.getTargetEntity().getProfile(); server.getGameProfileManager().fill(profile).thenRun(() -> { String message = "Successfully loaded the game profile for {} (player {})"; this.logger.debug(message, profile.getUniqueId(), profile.getName().orElse("null")); }); } }
Example #6
Source File: PlayerEventHandler.java From GriefDefender with MIT License | 6 votes |
@Listener(order = Order.FIRST) public void onPlayerJoin(ClientConnectionEvent.Join event) { GDTimings.PLAYER_JOIN_EVENT.startTimingIfSync(); Player player = event.getTargetEntity(); if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(player.getWorld().getUniqueId())) { GDTimings.PLAYER_JOIN_EVENT.stopTimingIfSync(); return; } UUID playerID = player.getUniqueId(); final GDPlayerData playerData = this.dataStore.getOrCreatePlayerData(player.getWorld(), playerID); final GDClaim claim = this.dataStore.getClaimAtPlayer(playerData, player.getLocation()); if (claim.isInTown()) { playerData.inTown = true; } GDTimings.PLAYER_JOIN_EVENT.stopTimingIfSync(); }
Example #7
Source File: SpongePingCounter.java From Plan with GNU Lesser General Public License v3.0 | 6 votes |
@Listener public void onPlayerJoin(ClientConnectionEvent.Join joinEvent) { Player player = joinEvent.getTargetEntity(); Long pingDelay = config.get(TimeSettings.PING_PLAYER_LOGIN_DELAY); if (pingDelay >= TimeUnit.HOURS.toMillis(2L)) { return; } runnableFactory.create("Add Player to Ping list", new AbsRunnable() { @Override public void run() { if (player.isOnline()) { addPlayer(player); } } }).runTaskLater(TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS)); }
Example #8
Source File: UCListener.java From UltimateChat with GNU General Public License v3.0 | 6 votes |
@Listener public void onJoin(ClientConnectionEvent.Join e, @Getter("getTargetEntity") Player p) { if (!UChat.get().getConfig().root().general.persist_channels) { UChat.get().getDefChannel(p.getWorld().getName()).addMember(p); } if (p.hasPermission("uchat.auto-msgtoggle")) { UChat.get().msgTogglePlayers.remove(p.getName()); } if (UChat.get().getUCJDA() != null && !p.hasPermission(UChat.get().getConfig().root().discord.vanish_perm)) { Task.builder().async().execute(() -> UChat.get().getUCJDA().sendRawToDiscord(UChat.get().getLang().get("discord.join").replace("{player}", p.getName()))); } if (UChat.get().getConfig().root().general.spy_enabled_onjoin && p.hasPermission("uchat.cmd.spy") && !UChat.get().isSpy.contains(p.getName())) { UChat.get().isSpy.add(p.getName()); UChat.get().getLang().sendMessage(p, "cmd.spy.enabled"); } }
Example #9
Source File: UCListener.java From UltimateChat with GNU General Public License v3.0 | 6 votes |
@Listener public void onQuit(ClientConnectionEvent.Disconnect e, @Getter("getTargetEntity") Player p) { if (!UChat.get().getConfig().root().general.persist_channels) { UChat.get().getPlayerChannel(p).removeMember(p); } UChat.get().tellPlayers.remove(p.getName()); UChat.get().tellPlayers.entrySet().removeIf(k -> k.getValue().equals(p.getName())); UChat.get().tempTellPlayers.remove(p.getName()); UChat.get().tempTellPlayers.entrySet().removeIf(k -> k.getValue().equals(p.getName())); UChat.get().respondTell.remove(p.getName()); UChat.get().respondTell.entrySet().removeIf(k -> k.getValue().equals(p.getName())); UChat.get().tempChannels.remove(p.getName()); UChat.get().tempChannels.entrySet().removeIf(k -> k.getValue().equals(p.getName())); UChat.get().command.remove(p.getName()); if (UChat.get().getUCJDA() != null && UChat.get().getUCJDA().JDAAvailable() && !p.hasPermission(UChat.get().getConfig().root().discord.vanish_perm)) { Task.builder().async().execute(() -> UChat.get().getUCJDA().sendRawToDiscord(UChat.get().getLang().get("discord.leave").replace("{player}", p.getName()))); } }
Example #10
Source File: SpongeConnectionListener.java From LuckPerms with MIT License | 6 votes |
@Listener(order = Order.LAST) @IsCancelled(Tristate.UNDEFINED) public void onClientAuthMonitor(ClientConnectionEvent.Auth e) { /* Listen to see if the event was cancelled after we initially handled the connection If the connection was cancelled here, we need to do something to clean up the data that was loaded. */ // Check to see if this connection was denied at LOW. if (this.deniedAsyncLogin.remove(e.getProfile().getUniqueId())) { // This is a problem, as they were denied at low priority, but are now being allowed. if (e.isCancelled()) { this.plugin.getLogger().severe("Player connection was re-allowed for " + e.getProfile().getUniqueId()); e.setCancelled(true); } } }
Example #11
Source File: DefaultListener.java From UltimateCore with MIT License | 6 votes |
@Listener(order = Order.EARLY) public void onJoin(ClientConnectionEvent.Join event) { Player p = event.getTargetEntity(); //Player file PlayerDataFile config = new PlayerDataFile(event.getTargetEntity().getUniqueId()); CommentedConfigurationNode node = config.get(); node.getNode("lastconnect").setValue(System.currentTimeMillis()); String ip = event.getTargetEntity().getConnection().getAddress().getAddress().toString().replace("/", ""); node.getNode("lastip").setValue(ip); config.save(node); //Ipcache file GlobalDataFile file = new GlobalDataFile("ipcache"); CommentedConfigurationNode node2 = file.get(); node2.getNode(ip, "name").setValue(p.getName()); node2.getNode(ip, "uuid").setValue(p.getUniqueId().toString()); file.save(node2); }
Example #12
Source File: LoginListener.java From ChangeSkin with MIT License | 6 votes |
@Listener public void onPlayerPreLogin(ClientConnectionEvent.Auth preLoginEvent) { SkinStorage storage = core.getStorage(); GameProfile profile = preLoginEvent.getProfile(); UUID playerUUID = profile.getUniqueId(); UserPreference preferences = storage.getPreferences(playerUUID); Optional<SkinModel> optSkin = preferences.getTargetSkin(); if (optSkin.isPresent()) { SkinModel targetSkin = optSkin.get(); if (!preferences.isKeepSkin()) { targetSkin = core.checkAutoUpdate(targetSkin); } plugin.getApi().applyProperties(profile, targetSkin); save(preferences); } else { String playerName = profile.getName().get(); if (!core.getConfig().getBoolean("restoreSkins") || !refetchSkin(playerName, preferences)) { setDefaultSkin(preferences, profile); } } }
Example #13
Source File: JailListener.java From UltimateCore with MIT License | 6 votes |
@Listener public void onJoin(ClientConnectionEvent.Join event) { Player p = event.getTargetEntity(); UltimateUser up = UltimateCore.get().getUserService().getUser(p); if (up.get(JailKeys.JAIL).isPresent()) { if (Modules.JAIL.get().getConfig().get().get().getNode("teleport-on-join").getBoolean()) { JailData data = up.get(JailKeys.JAIL).get(); Jail jail = GlobalData.get(JailKeys.JAILS).get().stream().filter(j -> j.getName().equalsIgnoreCase(data.getJail())).findAny().orElse(null); if (jail != null && jail.getLocation().isPresent()) { Teleportation tp = UltimateCore.get().getTeleportService().createTeleportation(p, Arrays.asList(p), jail.getLocation().get(), tel -> { }, (tel, reason) -> { }, false, true); tp.start(); } } } }
Example #14
Source File: ConnectionmessagesListener.java From UltimateCore with MIT License | 5 votes |
@Listener public void onQuit(ClientConnectionEvent.Disconnect e) { Player p = e.getTargetEntity(); ModuleConfig config = Modules.CONNECTIONMESSAGES.get().getConfig().get(); //Quit message if (!config.get().getNode("quit", "enable").getBoolean()) { e.setMessageCancelled(true); } if (config.get().getNode("quit", "enable-edit").getBoolean()) { Text jmessage = Messages.toText(config.get().getNode("quit", "format").getString()); jmessage = VariableUtil.replaceVariables(jmessage, p); e.setMessage(jmessage); } }
Example #15
Source File: FlagGui.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Listener public void onPlayerLogout(ClientConnectionEvent.Disconnect event) { Player p = event.getTargetEntity(); if (p.getName().equals(this.player.getName())) { close(true); } }
Example #16
Source File: TablistListener.java From UltimateCore with MIT License | 5 votes |
@Listener public void onQuit(ClientConnectionEvent.Disconnect event) { TablistModule module = (TablistModule) Modules.TABLIST.get(); NamesHandler runnable = module.getRunnable(); runnable.removeCache(event.getTargetEntity().getUniqueId()); Sponge.getScheduler().createTaskBuilder().delayTicks(20L).execute(runnable::update).submit(UltimateCore.get()); }
Example #17
Source File: TablistListener.java From UltimateCore with MIT License | 5 votes |
@Listener public void onJoin(ClientConnectionEvent.Join event) { Sponge.getScheduler().createTaskBuilder().delayTicks(20L).execute(() -> { TablistModule module = (TablistModule) Modules.TABLIST.get(); NamesHandler runnable = module.getRunnable(); runnable.update(); }).submit(UltimateCore.get()); }
Example #18
Source File: ServerlistListener.java From UltimateCore with MIT License | 5 votes |
@Listener(order = Order.LATE) public void onJoin(ClientConnectionEvent.Join event) { try { Player p = event.getTargetEntity(); ModuleConfig config = Modules.SERVERLIST.get().getConfig().get(); //Join motd if (config.get().getNode("joinmessage", "enable").getBoolean()) { List<String> joinmsgs = config.get().getNode("joinmessage", "joinmessages").getList(TypeToken.of(String.class)); Text joinmsg = VariableUtil.replaceVariables(Messages.toText(joinmsgs.get(random.nextInt(joinmsgs.size()))), p); p.sendMessage(joinmsg); } } catch (ObjectMappingException e) { ErrorLogger.log(e, "Failed to construct join message."); } }
Example #19
Source File: ItemFlagGui.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Listener public void onPlayerLogout(ClientConnectionEvent.Disconnect event) { Player p = event.getTargetEntity(); if (p.getName().equals(this.player.getName())) { close(true); } }
Example #20
Source File: PlayerConnectionListener.java From Nations with MIT License | 5 votes |
@Listener public void onPlayerJoin(ClientConnectionEvent.Join event) { if (event.getTargetEntity() instanceof Player) { Player player = event.getTargetEntity(); Nation nation = DataHandler.getNationOfPlayer(player.getUniqueId()); if (nation != null) nation.getMessageChannel().addMember(player); player.setMessageChannel(MessageChannel.TO_ALL); if (player.hasPermission("nations.admin.spychat")) DataHandler.getSpyChannel().addMember(player); } }
Example #21
Source File: SpongeMain.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Listener public void onQuit(ClientConnectionEvent.Disconnect event) { Player player = event.getTargetEntity(); FawePlayer fp = FawePlayer.wrap(player); fp.unregister(); Fawe.get().unregister(player.getName()); }
Example #22
Source File: MobFlagGui.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Listener public void onPlayerLogout(ClientConnectionEvent.Disconnect event) { Player p = event.getTargetEntity(); if (p.getName().equals(this.player.getName())) { close(true); } }
Example #23
Source File: PlayerDisconnectListener.java From EssentialCmds with MIT License | 5 votes |
@Listener public void onPlayerDisconnect(ClientConnectionEvent.Disconnect event) { Player player = event.getTargetEntity(); String disconnectMessage = Utils.getDisconnectMessage(); if (disconnectMessage != null && !disconnectMessage.equals("")) { if (disconnectMessage.equals("none")) { event.setMessageCancelled(true); } else { disconnectMessage = disconnectMessage.replaceAll("@p", player.getName()); Text newMessage = TextSerializers.formattingCode('&').deserialize(disconnectMessage); event.setMessage(newMessage); } } if (EssentialCmds.afkList.containsKey(player.getUniqueId())) { EssentialCmds.afkList.remove(player.getUniqueId()); } Utils.savePlayerInventory(player, player.getWorld().getUniqueId()); }
Example #24
Source File: NickListener.java From UltimateCore with MIT License | 5 votes |
@Listener public void onJoin(ClientConnectionEvent.Join event) { UltimateUser up = UltimateCore.get().getUserService().getUser(event.getTargetEntity()); if (up.get(NickKeys.NICKNAME).isPresent()) { event.getTargetEntity().offer(Keys.DISPLAY_NAME, up.get(NickKeys.NICKNAME).get()); } }
Example #25
Source File: MailListener.java From UltimateCore with MIT License | 5 votes |
@Listener public void onJoin(ClientConnectionEvent.Join event) { UltimateUser up = UltimateCore.get().getUserService().getUser(event.getTargetEntity()); int unreadCount = up.get(MailKeys.UNREAD_MAIL).get(); if (unreadCount == 0) return; event.getTargetEntity().sendMessage(Messages.getFormatted(event.getTargetEntity(), "mail.command.mail.newmail", "%count%", unreadCount).toBuilder().onHover(TextActions.showText(Messages.getFormatted(event.getTargetEntity(), "mail.command.mail.newmail.hover"))).onClick(TextActions.runCommand("/mail read")).build()); }
Example #26
Source File: FlyListeners.java From UltimateCore with MIT License | 5 votes |
@Listener public void onJoin(ClientConnectionEvent.Join event) { Player p = event.getTargetEntity(); UltimateUser user = UltimateCore.get().getUserService().getUser(p); if (p.hasPermission(FlyPermissions.UC_FLY_FLY_BASE.get()) && user.get(FlyKeys.FLY).orElse(false)) { if (p.getLocation().add(0, -1, 0).getBlockType().equals(BlockTypes.AIR)) { p.offer(Keys.CAN_FLY, true); p.offer(Keys.IS_FLYING, true); } } }
Example #27
Source File: VanishListener.java From UltimateCore with MIT License | 5 votes |
@Listener(order = Order.LAST) public void onJoin(ClientConnectionEvent.Join event) { Player p = event.getTargetEntity(); UltimateUser up = UltimateCore.get().getUserService().getUser(p); if (up.get(VanishKeys.VANISH).get()) { p.offer(Keys.VANISH, true); p.offer(Keys.VANISH_PREVENTS_TARGETING, true); p.offer(Keys.VANISH_IGNORES_COLLISION, true); p.offer(Keys.IS_SILENT, true); Messages.send(p, "vanish.onjoin"); } }
Example #28
Source File: PlayerJoinListener.java From EagleFactions with MIT License | 5 votes |
@Listener(order = Order.POST) public void onPlayerJoin(final ClientConnectionEvent.Join event, final @Root Player player) { CompletableFuture.runAsync(() -> { if (player.hasPermission(PluginPermissions.VERSION_NOTIFY) && !VersionChecker.isLatest(PluginInfo.VERSION)) player.sendMessage(Text.of(PluginInfo.PLUGIN_PREFIX, TextColors.GREEN, Messages.A_NEW_VERSION_OF + " ", TextColors.AQUA, "Eagle Factions", TextColors.GREEN, " " + Messages.IS_AVAILABLE)); //Create player file and set power if player does not exist. if (!super.getPlugin().getPlayerManager().getFactionPlayer(player.getUniqueId()).isPresent()) super.getPlugin().getPlayerManager().addPlayer(player.getUniqueId(), player.getName()); //Maybe we could add loadCache method instead? // super.getPlugin().getPlayerManager().addPlayer(player.getUniqueId(), player.getName()); // super.getPlugin().getPlayerManager().updatePlayerName(player.getUniqueId(), player.getName()); super.getPlugin().getPowerManager().startIncreasingPower(player.getUniqueId()); //Check if the world that player is connecting to is already in the config file if (!this.protectionConfig.getDetectedWorldNames().contains(player.getWorld().getName())) this.protectionConfig.addWorld(player.getWorld().getName()); //Send motd final Optional<Faction> optionalPlayerFaction = super.getPlugin().getFactionLogic().getFactionByPlayerUUID(player.getUniqueId()); if(optionalPlayerFaction.isPresent() && !optionalPlayerFaction.get().getMessageOfTheDay().equals("")) { player.sendMessage(Text.of(PluginInfo.PLUGIN_PREFIX, MessageLoader.parseMessage(Messages.FACTION_MESSAGE_OF_THE_DAY, TextColors.RESET, ImmutableMap.of(Placeholders.FACTION_NAME, Text.of(TextColors.GOLD, optionalPlayerFaction.get().getName()))), Text.of(optionalPlayerFaction.get().getMessageOfTheDay()))); } }); }
Example #29
Source File: PlayerConnectionListener.java From Nations with MIT License | 5 votes |
@Listener public void onPlayerLeave(ClientConnectionEvent.Disconnect event) { if (event.getTargetEntity() instanceof Player) { Player player = (Player) event.getTargetEntity(); DataHandler.removeFirstPoint(player.getUniqueId()); DataHandler.removeSecondPoint(player.getUniqueId()); Nation nation = DataHandler.getNationOfPlayer(player.getUniqueId()); if (nation != null) nation.getMessageChannel().removeMember(player); DataHandler.getSpyChannel().removeMember(player); } }
Example #30
Source File: SpongeMain.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Listener public void onQuit(ClientConnectionEvent.Disconnect event) { Player player = event.getTargetEntity(); FawePlayer fp = FawePlayer.wrap(player); fp.unregister(); Fawe.get().unregister(player.getName()); }