org.bukkit.event.player.PlayerKickEvent Java Examples
The following examples show how to use
org.bukkit.event.player.PlayerKickEvent.
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 |
/** * PlayerKickEvent Listener. * <p> * Adds processing information to the ProcessingQueue. * After KickEvent, the QuitEvent is automatically called. * * @param event Fired event */ @EventHandler(priority = EventPriority.MONITOR) public void onPlayerKick(PlayerKickEvent event) { try { if (!status.areKicksCounted() || event.isCancelled()) { return; } UUID uuid = event.getPlayer().getUniqueId(); if (BukkitAFKListener.AFK_TRACKER.isAfk(uuid)) { return; } dbSystem.getDatabase().executeTransaction(new KickStoreTransaction(uuid)); } catch (Exception e) { errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build()); } }
Example #2
Source File: PlayerListenerTest.java From AuthMeReloaded with GNU General Public License v3.0 | 6 votes |
@Test public void shouldNotCancelOrdinaryKick() { // given given(settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)).willReturn(true); String name = "Bobby"; Player player = mockPlayerWithName(name); PlayerKickEvent event = new PlayerKickEvent(player, "No longer desired here!", ""); given(antiBotService.wasPlayerKicked(name)).willReturn(true); // when listener.onPlayerKick(event); // then assertThat(event.isCancelled(), equalTo(false)); verify(antiBotService).wasPlayerKicked(name); verifyNoInteractions(management); }
Example #3
Source File: PlayerListenerTest.java From AuthMeReloaded with GNU General Public License v3.0 | 6 votes |
@Test public void shouldNotCancelKick() { // given given(settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)).willReturn(false); String name = "Bobby"; Player player = mockPlayerWithName(name); PlayerKickEvent event = new PlayerKickEvent(player, "You logged in from another location", ""); given(antiBotService.wasPlayerKicked(name)).willReturn(false); // when listener.onPlayerKick(event); // then assertThat(event.isCancelled(), equalTo(false)); verify(antiBotService).wasPlayerKicked(name); verify(management).performQuit(player); }
Example #4
Source File: PlayerBanListener.java From DiscordSRV with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onPlayerKick(PlayerKickEvent event) { Bukkit.getScheduler().scheduleSyncDelayedTask(DiscordSRV.getPlugin(), () -> { if (Bukkit.getBannedPlayers().contains(Bukkit.getOfflinePlayer(event.getPlayer().getUniqueId()))) { if (event.getPlayer() instanceof OfflinePlayer) { if (!DiscordSRV.config().getBoolean("BanSynchronizationMinecraftToDiscord")) { DiscordSRV.debug("Not handling ban for player " + event.getPlayer().getName() + " (" + event.getPlayer().getUniqueId() + ") because doing so is disabled in the config"); return; } DiscordSRV.debug("Handling ban for player " + event.getPlayer().getName() + " (" + event.getPlayer().getUniqueId() + ")"); DiscordUtil.banMember(DiscordUtil.getMemberById(DiscordSRV.getPlugin().getAccountLinkManager().getDiscordId(event.getPlayer().getUniqueId()))); } } }, 20); }
Example #5
Source File: GrapplingHookListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onLeave(PlayerKickEvent e) { if (!isEnabled()) { return; } UUID uuid = e.getPlayer().getUniqueId(); activeHooks.remove(uuid); invulnerability.remove(uuid); }
Example #6
Source File: PlayerStreamListener.java From EnchantmentsEnhance with GNU General Public License v3.0 | 5 votes |
/** * When a player gets kicked off the server, listener saves a player's data * from hashmap to file, but will not write to disk. * * @param e */ @EventHandler(priority = EventPriority.MONITOR) public void onKick(PlayerKickEvent e) { if (PlayerStatsManager.getPlayerStats(e.getPlayer().getName()) != null) { new BukkitRunnable() { @Override public void run() { PlayerStatsManager.removePlayerStats(e.getPlayer().getName()); } }.runTaskLater(Main.getMain(), 20); } }
Example #7
Source File: ExprMessage.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override @Nullable String get(final Event e) { if (e instanceof PlayerKickEvent) return ((PlayerKickEvent) e).getLeaveMessage(); else return ((PlayerQuitEvent) e).getQuitMessage(); }
Example #8
Source File: PlayerListenerTest.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
/** * #831: If a player is kicked because of "logged in from another location", the kick * should be CANCELED when single session is enabled. */ @Test public void shouldCancelKick() { // given given(settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)).willReturn(true); Player player = mock(Player.class); PlayerKickEvent event = new PlayerKickEvent(player, "You logged in from another location", ""); // when listener.onPlayerKick(event); // then assertThat(event.isCancelled(), equalTo(true)); verifyNoInteractions(player, management, antiBotService); }
Example #9
Source File: PlayerListener.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onPlayerKick(PlayerKickEvent event) { // Note #831: Especially for offline CraftBukkit, we need to catch players being kicked because of // "logged in from another location" and to cancel their kick if (settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION) && event.getReason().contains("You logged in from another location")) { event.setCancelled(true); return; } final Player player = event.getPlayer(); if (!antiBotService.wasPlayerKicked(player.getName())) { management.performQuit(player); } }
Example #10
Source File: TestPlayerProfileListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@Test public void testUnloadedPlayerKick() { Player player = server.addPlayer(); PlayerKickEvent event = new PlayerKickEvent(player, "You're not welcome anymore", "bye"); listener.onKick(event); Assertions.assertFalse(PlayerProfile.find(player).isPresent()); }
Example #11
Source File: TestPlayerProfileListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@Test public void testPlayerKick() throws InterruptedException { Player player = server.addPlayer(); PlayerProfile profile = TestUtilities.awaitProfile(player); PlayerKickEvent event = new PlayerKickEvent(player, "You're not welcome anymore", "bye"); listener.onKick(event); Assertions.assertTrue(profile.isMarkedForDeletion()); }
Example #12
Source File: EffKick.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override protected void execute(final Event e) { final String r = reason != null ? reason.getSingle(e) : ""; if (r == null) return; for (final Player p : players.getArray(e)) { if (e instanceof PlayerLoginEvent && p.equals(((PlayerLoginEvent) e).getPlayer()) && !Delay.isDelayed(e)) { ((PlayerLoginEvent) e).disallow(Result.KICK_OTHER, r); } else if (e instanceof PlayerKickEvent && p.equals(((PlayerKickEvent) e).getPlayer()) && !Delay.isDelayed(e)) { ((PlayerKickEvent) e).setLeaveMessage(r); } else { p.kickPlayer(r); } } }
Example #13
Source File: PlayerProfileListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onKick(PlayerKickEvent e) { Optional<PlayerProfile> profile = PlayerProfile.find(e.getPlayer()); // if we still have a profile of this Player in memory, delete it if (profile.isPresent()) { profile.get().markForDeletion(); } }
Example #14
Source File: EventExecutor.java From PlayerSQL with GNU General Public License v2.0 | 5 votes |
@EventHandler public void handle(PlayerKickEvent e) { Player player = e.getPlayer(); if (handled.get(player.getUniqueId()) != Lifecycle.DATA_SENT) { return; } DataSupply supply = new DataSupply();// So we magic send player data at kick event. supply.setId(player.getUniqueId()); supply.setGroup(group); if (isLocked(player.getUniqueId())) { supply.setBuf(EMPTY_ARRAY); } else { manager.lockUser(player); PlayerData dat = manager.getUserData(player, true); pending.put(player.getUniqueId(), dat); supply.setBuf(PlayerDataHelper.encode(dat)); } byte[] message = supply.encode(); if (message.length > Messenger.MAX_MESSAGE_SIZE) {// Overflow? supply.setBuf(EMPTY_ARRAY); message = supply.encode(); } player.sendPluginMessage(main, PlayerSqlProtocol.NAMESPACE, message);// BungeeCord received this before kicks }
Example #15
Source File: ListenerUntagger.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority=EventPriority.LOWEST, ignoreCancelled=true) public void onKicked(PlayerKickEvent e) { String kickReason = e.getReason(); if(isKickReasonIgnored(kickReason)) return; Player player = e.getPlayer(); ICombatManager combatManager = this.plugin.getCombatManager(); combatManager.untag(player, PlayerUntagEvent.UntagReason.KICK); }
Example #16
Source File: ExprMessage.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override void set(final Event e, final String message) { if (e instanceof PlayerKickEvent) ((PlayerKickEvent) e).setLeaveMessage(message); else ((PlayerQuitEvent) e).setQuitMessage(message); }
Example #17
Source File: PlayerQuit.java From FunnyGuilds with Apache License 2.0 | 4 votes |
@EventHandler public void onKick(PlayerKickEvent event) { quit(event.getPlayer()); }
Example #18
Source File: AutoRestarter.java From AnnihilationPro with MIT License | 4 votes |
@EventHandler(priority = EventPriority.MONITOR) public void teleportCheck(PlayerKickEvent event) { check(); }
Example #19
Source File: Bar.java From AnnihilationPro with MIT License | 4 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerKick(PlayerKickEvent event) { removeBar(event.getPlayer()); }
Example #20
Source File: AnniPlayer.java From AnnihilationPro with MIT License | 4 votes |
@EventHandler(priority = EventPriority.MONITOR) public void enderFuraceManagement(PlayerKickEvent event) { checkLeave(event.getPlayer()); }
Example #21
Source File: NPCMain.java From AnnihilationPro with MIT License | 4 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onLeave(PlayerKickEvent event) { playerLeft(event.getPlayer()); }
Example #22
Source File: FlagAntiCamping.java From HeavySpleef with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onPlayerKick(PlayerKickEvent event) { handlePlayerLeave(event); }
Example #23
Source File: PlayerManager.java From HeavySpleef with GNU General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onPlayerKick(PlayerKickEvent e) { handlePlayerLeave(e.getPlayer()); }
Example #24
Source File: JoinRequester.java From HeavySpleef with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onPlayerKick(PlayerKickEvent event) { handleQuit(event); }
Example #25
Source File: HillObjective.java From CardinalPGM with MIT License | 4 votes |
@EventHandler public void onPlayerLeave(PlayerKickEvent event) { if (capturingPlayers.contains(event.getPlayer())) capturingPlayers.remove(event.getPlayer()); }
Example #26
Source File: BossBarAPI.java From Carbon-2 with GNU Lesser General Public License v3.0 | 4 votes |
@EventHandler public void onPlayerKick(PlayerKickEvent event) { removeBars(event.getPlayer()); }
Example #27
Source File: PlayerLoginLogoutListener.java From AreaShop with GNU General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onPlayerKick(PlayerKickEvent event) { updateLastActive(event.getPlayer()); }
Example #28
Source File: PlayerQuitListener.java From PerWorldInventory with GNU General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onPlayerKick(PlayerKickEvent event) { Player player = event.getPlayer(); process.processPlayerLeave(player); }
Example #29
Source File: TimesKickedListener.java From Statz with GNU General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onKick(final PlayerKickEvent event) { final PlayerStat stat = PlayerStat.TIMES_KICKED; // Get player final Player player = event.getPlayer(); // Do general check if (!plugin.doGeneralCheck(player, stat)) return; PlayerStatSpecification specification = new TimesKickedSpecification(player.getUniqueId(), 1, player.getWorld().getName(), event.getReason()); // Update value to new stat. plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, specification.constructQuery()); }
Example #30
Source File: BossBarAPI.java From Carbon-2 with GNU Lesser General Public License v3.0 | 4 votes |
@EventHandler public void onPlayerKick(PlayerKickEvent event) { removeBars(event.getPlayer()); }