Java Code Examples for org.bukkit.event.player.PlayerQuitEvent#setQuitMessage()
The following examples show how to use
org.bukkit.event.player.PlayerQuitEvent#setQuitMessage() .
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: PGMListener.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void removePlayerOnDisconnect(PlayerQuitEvent event) { Match match = this.mm.getMatch(event.getWorld()); if (match == null) return; if (event.getQuitMessage() != null) { MatchPlayer player = match.getPlayer(event.getPlayer()); if (player != null) { if (!vm.isVanished(player.getId())) { announceJoinOrLeave(player, false, false); } else { // Announce actual staff quit announceJoinOrLeave(player, false, true); } } event.setQuitMessage(null); } match.removePlayer(event.getPlayer()); PGM.get().getPrefixRegistry().removePlayer(event.getPlayer().getUniqueId()); }
Example 2
Source File: NickNamerPlugin.java From NickNamer with MIT License | 6 votes |
@EventHandler(priority = EventPriority.NORMAL) public void on(final PlayerQuitEvent event) { if (PlayerQuitReplacementEvent.getHandlerList().getRegisteredListeners().length > 0) { final String message = event.getQuitMessage(); Set<String> nickedPlayerNames = NickNamerAPI.getNickedPlayerNames(); String replacedMessage = NickNamerAPI.replaceNames(message, nickedPlayerNames, new NameReplacer() { @Override public String replace(String original) { Player player = Bukkit.getPlayer(original); if (player != null) { PlayerQuitReplacementEvent replacementEvent = new PlayerQuitReplacementEvent(player, Bukkit.getOnlinePlayers(), message, original, original); Bukkit.getPluginManager().callEvent(replacementEvent); if (replacementEvent.isCancelled()) { return original; } return replacementEvent.getReplacement(); } return original; } }, true); event.setQuitMessage(replacedMessage); } }
Example 3
Source File: EventListener.java From iDisguise with Creative Commons Attribution Share Alike 4.0 International | 6 votes |
@EventHandler public void onPlayerQuit(PlayerQuitEvent event) { Player player = event.getPlayer(); if(plugin.getConfiguration().MODIFY_MESSAGE_LEAVE) { if(event.getQuitMessage() != null && DisguiseManager.isDisguised(player)) { if(DisguiseManager.getDisguise(player) instanceof PlayerDisguise) { event.setQuitMessage(event.getQuitMessage().replace(player.getName(), ((PlayerDisguise)DisguiseManager.getDisguise(player)).getDisplayName())); } else { event.setQuitMessage(null); } } } if(!plugin.getConfiguration().KEEP_DISGUISE_LEAVE) { if(DisguiseManager.isDisguised(player)) { DisguiseManager.undisguise(player); } } ChannelInjector.remove(player); EntityIdList.removeEntity(player); }
Example 4
Source File: PlayerQuit.java From ZombieEscape with GNU General Public License v2.0 | 6 votes |
@EventHandler public void onQuit(PlayerQuitEvent event) { event.setQuitMessage(null); GameArena gameArena = plugin.getGameArena(); gameArena.purgePlayer(event.getPlayer()); if (gameArena.isGameRunning()) { if (gameArena.shouldEnd()) { // Possibly deduct points? gameArena.endGame(); } } Cooldowns.removeCooldowns(event.getPlayer()); Profile profile = plugin.getRemovedProfile(event.getPlayer()); new ProfileSaver(profile, plugin).runTaskAsynchronously(plugin); }
Example 5
Source File: PlayerListener.java From AuthMeReloaded with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerQuit(PlayerQuitEvent event) { Player player = event.getPlayer(); // Note: quit message can be null, despite api documentation says not if (settings.getProperty(RegistrationSettings.REMOVE_LEAVE_MESSAGE)) { event.setQuitMessage(null); } else if (settings.getProperty(RegistrationSettings.REMOVE_UNLOGGED_LEAVE_MESSAGE)) { if (listenerService.shouldCancelEvent(event)) { event.setQuitMessage(null); } } if (antiBotService.wasPlayerKicked(player.getName())) { return; } management.performQuit(player); }
Example 6
Source File: VanishManagerImpl.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGH) public void onQuit(PlayerQuitEvent event) { MatchPlayer player = matchManager.getPlayer(event.getPlayer()); // If player is vanished & joined via "vanish" subdomain. Remove vanish status on quit if (isVanished(player.getId()) && tempVanish.contains(player.getId())) { setVanished(player, false, true); // Temporary vanish status is removed before quit, // so prevent regular quit msg and forces a staff only broadcast event.setQuitMessage(null); PGMListener.announceJoinOrLeave(player, false, true, true); } }
Example 7
Source File: JoinMessageAnnouncer.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onQuit(PlayerQuitEvent event) throws EventException { event.setQuitMessage(null); final User user = userStore.getUser(event.getPlayer()); final SessionChange change = pendingQuits.getIfPresent(user); event.yield(); if(change != null) { pendingQuits.invalidate(user); announce(change); } }
Example 8
Source File: PlayerListener.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onQuit(PlayerQuitEvent pqe) { Player player = pqe.getPlayer(); if (BedwarsRel.getInstance().isBungee()) { pqe.setQuitMessage(null); } // Remove holographs if (BedwarsRel.getInstance().isHologramsEnabled() && BedwarsRel.getInstance().getHolographicInteractor() != null && BedwarsRel.getInstance() .getHolographicInteractor().getType().equalsIgnoreCase("HolographicDisplays")) { BedwarsRel.getInstance().getHolographicInteractor().unloadAllHolograms(player); } if (BedwarsRel.getInstance().statisticsEnabled()) { BedwarsRel.getInstance().getPlayerStatisticManager().unloadStatistic(player); } Game g = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player); if (g == null) { return; } g.playerLeave(player, false); }
Example 9
Source File: TeamManagerModule.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onPlayerLeave(PlayerQuitEvent event) { Player player = event.getPlayer(); event.setQuitMessage(null); for (Player player1 : Bukkit.getOnlinePlayers()) { if (!player1.equals(player)) { player1.sendMessage(new UnlocalizedChatMessage(ChatColor.YELLOW + "{0}", new LocalizedChatMessage(ChatConstant.UI_PLAYER_LEAVE, Teams.getTeamColorByPlayer(player) + player.getDisplayName() + ChatColor.YELLOW)).getMessage(player1.getLocale())); } } Bukkit.getConsoleSender().sendMessage(new UnlocalizedChatMessage(ChatColor.YELLOW + "{0}", new LocalizedChatMessage(ChatConstant.UI_PLAYER_LEAVE, Teams.getTeamColorByPlayer(player) + player.getDisplayName() + ChatColor.YELLOW)).getMessage(Locale.getDefault().toString())); removePlayer(player); }
Example 10
Source File: SilentNightListener.java From UhcCore with GNU General Public License v3.0 | 4 votes |
@EventHandler (priority = EventPriority.LOW) public void onPlayerQuit(PlayerQuitEvent e){ if (nightMode){ e.setQuitMessage(null); } }
Example 11
Source File: UserListener.java From VoxelGamesLibv2 with MIT License | 4 votes |
@EventHandler(priority = EventPriority.LOW) public void suppressQuitMessages(@Nonnull PlayerQuitEvent event) { event.setQuitMessage(null); }
Example 12
Source File: QuitEvent.java From SuperVanish with Mozilla Public License 2.0 | 4 votes |
@Override public void execute(Listener l, Event event) { try { if (event instanceof PlayerQuitEvent) { PlayerQuitEvent e = (PlayerQuitEvent) event; FileConfiguration config = plugin.getConfig(); Player p = e.getPlayer(); // if is invisible if (plugin.getVanishStateMgr().isVanished(p.getUniqueId())) { // remove action bar if (plugin.getActionBarMgr() != null && plugin.getSettings().getBoolean( "MessageOptions.DisplayActionBar")) { plugin.getActionBarMgr().removeActionBar(p); } // check auto-reappear-option boolean noMsg = false; if (plugin.getSettings().getBoolean("VanishStateFeatures.ReappearOnQuit") || plugin.getSettings().getBoolean("VanishStateFeatures.CheckPermissionOnQuit") && !CommandAction.VANISH_SELF.checkPermission(p, plugin)) { plugin.getVanishStateMgr().setVanishedState(p.getUniqueId(), p.getName(), false, null); // collision try { //noinspection deprecation p.spigot().setCollidesWithEntities(true); } catch (NoClassDefFoundError | NoSuchMethodError ignored) { } // check if it should handle the quit msg if (!config.getBoolean("MessageOptions.ReappearOnQuitHideLeaveMsg")) noMsg = true; } // check remove-quit-msg option if (!noMsg && config.getBoolean("MessageOptions.HideRealJoinQuitMessages")) { e.setQuitMessage(null); Broadcast.announceSilentQuit(p, plugin); } } // remove VanishPlayer plugin.removeVanishPlayer(plugin.getVanishPlayer(p)); } } catch (Exception er) { plugin.logException(er); } }
Example 13
Source File: JoinMessages.java From HubBasics with GNU Lesser General Public License v3.0 | 4 votes |
@EventHandler public void onQuit(PlayerQuitEvent event) { event.setQuitMessage(PlaceHolderUtil.replace(event.getPlayer(), this.quitMessage)); }