@EventHandler(order = Order.EARLIEST) public void onPlayerLeave(PlayerLeaveEvent event) { BridgePlayer player = EntityFactory.createPlayer(event.getPlayer()); final String leaveMessage = event.getMessage().asString(); if (event instanceof PlayerKickEvent) { PlayerKickEvent kickEvent = (PlayerKickEvent) event; final String kickMessage = kickEvent.getKickReason().asString(); org.bukkit.event.player.PlayerKickEvent kick = new org.bukkit.event.player.PlayerKickEvent(player, kickMessage, leaveMessage); kick.setCancelled(event.isCancelled()); Bukkit.getPluginManager().callEvent(kick); if (!kickMessage.equals(kick.getReason())) { kickEvent.setKickReason(kick.getReason()); } if (!leaveMessage.equals(kick.getLeaveMessage())) { kickEvent.setMessage(kick.getLeaveMessage()); } kickEvent.setCancelled(kick.isCancelled()); } else { org.bukkit.event.player.PlayerQuitEvent quit = new org.bukkit.event.player.PlayerQuitEvent(player, leaveMessage); Bukkit.getPluginManager().callEvent(quit); } }
/** * Called when a player leaves a server * * @param event Relevant event details */ @EventHandler(event = PlayerLeaveEvent.class) public void onPlayerQuit(PlayerLeaveEvent event) { plugin.getWorldEdit().markExpire(plugin.wrapPlayer(event.getPlayer())); }