Java Code Examples for org.bukkit.event.player.PlayerKickEvent

The following are top voted examples for showing how to use org.bukkit.event.player.PlayerKickEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: BiteSkywars   File: PlayerListener.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void onLeave(PlayerKickEvent event){
	Player p = event.getPlayer();
	SPlayer player = SPlayer.getDPlayer(p);
	Skywars.getStorage().unloadData(player);
	event.setLeaveMessage(null);
	Arena a = new ArenaManager().getArena(p);
	if(a==null){
		return;
	}
	a.leave(p);

	player.removeHolo(player);
	
	
}
 
Example 2
Project: Minetrace   File: MinetraceListener.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void onPlayerKick(PlayerKickEvent event){
	Player player = event.getPlayer();
	Location location = player.getLocation();
	
	PlayerKickObsel obsel = new PlayerKickObsel(
			new Date().getTime(),
			location.getBlockX(),
			location.getBlockY(),
			location.getBlockZ(),
			location.getWorld().getName(),
			player.getName(),
			event.getReason());
	
	JSONObselManager.getInstance().addObsel(obsel);
}
 
Example 3
Project: DiscordSRV   File: PlayerBanListener.java   Source Code and License 6 votes vote down vote up
@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 4
Project: Statz   File: TimesKickedListener.java   Source Code and License 6 votes vote down vote up
@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;

	// Update value to new stat.
	plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid",
			player.getUniqueId(), "value", 1, "world", player.getWorld().getName(), "reason", event.getReason()));

}
 
Example 5
Project: BiteSkywars   File: PlayerListener.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void onLeave(PlayerKickEvent event){
	Player p = event.getPlayer();
	SPlayer player = SPlayer.getDPlayer(p);
	Skywars.getStorage().unloadData(player);
	event.setLeaveMessage(null);
	Arena a = new ArenaManager().getArena(p);
	if(a==null){
		return;
	}
	a.leave(p);

	player.removeHolo(player);
	
	
}
 
Example 6
Project: CraftBukkit   File: PlayerConnection.java   Source Code and License 6 votes vote down vote up
public void disconnect(String s) {
    // CraftBukkit start - fire PlayerKickEvent
    String leaveMessage = EnumChatFormat.YELLOW + this.player.getName() + " left the game.";

    PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage);

    if (this.server.getServer().isRunning()) {
        this.server.getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        // Do not kick the player
        return;
    }
    // Send the possibly modified leave message
    s = event.getReason();
    // CraftBukkit end
    ChatComponentText chatcomponenttext = new ChatComponentText(s);

    this.networkManager.handle(new PacketPlayOutKickDisconnect(chatcomponenttext), new GenericFutureListener[] { new PlayerConnectionFuture(this, chatcomponenttext)});
    this.a(chatcomponenttext); // CraftBukkit - Process quit immediately
    this.networkManager.g();
}
 
Example 7
Project: Tweakkit-Server   File: PlayerConnection.java   Source Code and License 6 votes vote down vote up
public void disconnect(String s) {
    // CraftBukkit start - fire PlayerKickEvent
    String leaveMessage = EnumChatFormat.YELLOW + this.player.getName() + " left the game.";

    PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage);

    if (this.server.getServer().isRunning()) {
        this.server.getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        // Do not kick the player
        return;
    }
    // Send the possibly modified leave message
    s = event.getReason();
    // CraftBukkit end
    ChatComponentText chatcomponenttext = new ChatComponentText(s);

    this.networkManager.handle(new PacketPlayOutKickDisconnect(chatcomponenttext), new GenericFutureListener[] { new PlayerConnectionFuture(this, chatcomponenttext)});
    this.a(chatcomponenttext); // CraftBukkit - Process quit immediately
    this.networkManager.g();
}
 
Example 8
Project: StarQuestCode   File: SQGlobalInfo.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void onPlayerKick(PlayerKickEvent event) {
	Player player = event.getPlayer();
	//Retrieves important information about player
	String name = player.getName();
	String uuid = player.getUniqueId().toString();
	String ip = player.getAddress().getAddress().getHostAddress();
	Date time = new Date();
	boolean online = true;
	String world = player.getWorld().getName();
	String location = getLocation(player);
	//Upserts to database unless the player is in the do not track list
	if(!(playerIsIncognito(name))) {
		Bukkit.getScheduler().runTaskAsynchronously(this, new Runnable() {
			public void run() {
				getSQLDatabase().updatePlayerData(name, uuid, ip, time, online, world, location);
			}
		});
	}
}
 
Example 9
Project: CrazyLogin   File: PlayerListener.java   Source Code and License 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void PlayerKick(final PlayerKickEvent event) {
	final Player player = event.getPlayer();
	if (player.hasMetadata("NPC")) {
		return;
	}
	if (plugin.isUsingCustomJoinQuitMessagesEnabled()) {
		kicked.add(event.getPlayer().getName());
		event.setLeaveMessage("CRAZYLOGIN.KICK");
	}
	if (!plugin.isLoggedIn(player) && plugin.isDelayingJoinQuitMessagesEnabled()) {
		event.setLeaveMessage(null);
	}
	PlayerQuit(player, true);
	Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {

		@Override
		public void run() {
			plugin.unregisterDynamicHooks();
		}
	}, 5);
}
 
Example 10
Project: BAMradio   File: WGRegionEventsListener.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void onPlayerKick(PlayerKickEvent e)
{
    Set<ProtectedRegion> regions = playerRegions.remove(e.getPlayer());
    if (regions != null)
    {
        for(ProtectedRegion region : regions)
        {
            RegionLeaveEvent leaveEvent = new RegionLeaveEvent(region, e.getPlayer(), MovementWay.DISCONNECT);
            RegionLeftEvent leftEvent = new RegionLeftEvent(region, e.getPlayer(), MovementWay.DISCONNECT);

            BAMradio.Instance.getServer().getPluginManager().callEvent(leaveEvent);
            BAMradio.Instance.getServer().getPluginManager().callEvent(leftEvent);
        }
    }
}
 
Example 11
Project: NPlugins   File: PunishmentListener.java   Source Code and License 6 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerKick(final PlayerKickEvent event) {
    this.plugin.entering(this.getClass(), "onPlayerKick");

    String msg = this.punishmentDb.getLeaveMessages().remove(event.getPlayer().getUniqueId());
    if (msg != null) {
        if (this.plugin.isDebugEnabled()) {
            this.plugin.debug("Message not null: '" + msg + '\'');
        }
    } else {
        msg = this.plugin.getMessages().get(MessageId.player_standardKickMessage, event.getPlayer().getName())[0];
        if (this.plugin.isDebugEnabled()) {
            this.plugin.debug("Message is null, setting default: '" + msg + '\'');
        }
    }
    event.setLeaveMessage(msg);

    this.plugin.exiting(this.getClass(), "onPlayerKick");
}
 
Example 12
Project: xEssentials-deprecated-bukkit   File: MemorySafetyEvent.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void onQuit(PlayerKickEvent e) {
	if(pl.getManagers().getPlayerManager().isOnline(e.getPlayer().getName())) {
		final XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(e.getPlayer().getName());
		if(xp.isInArena()) {
			new BukkitRunnable() {

				@Override
				public void run() {
					if(!xp.getBukkitPlayer().isOnline()) {
						xp.getArena().leaveArena(xp);
						xp.setArena(null);
					}
				}
				
			}.runTaskLater(pl, 15L);
		}
	}
}
 
Example 13
Project: xEssentials-deprecated-bukkit   File: NpcReplacePlayerEvent.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void onQuit(PlayerKickEvent e) {
	if(essentialsPlayers.containsKey(e.getPlayer().getName())) {
		XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(e.getPlayer().getName());
		if(xp.isVanished()) {
			essentialsPlayers.remove(e.getPlayer().getName());
			return;
		}
		ItemStack[] items = e.getPlayer().getInventory().getContents();
		Skeleton skel = (Skeleton) e.getPlayer().getWorld().spawnEntity(e.getPlayer().getLocation(), EntityType.SKELETON);
		//lets pimp the skeleton a bit!
		turnSkelToNpc(skel, e.getPlayer().getName());
		npcs.put(skel.getUniqueId(), items);
		essentialsPlayers.remove(e.getPlayer().getName());
		NpcDespawn(skel);
	}
}
 
Example 14
Project: xEssentials-deprecated-bukkit   File: PotatoMoveEvent.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void onQuit(PlayerKickEvent e) {
	if(pl.getManagers().getPlayerManager().isOnline(e.getPlayer().getName())) {
		if(pl.getConfiguration().getDebugConfig().isEnabled()) {
			xEssentials.log("player "+ e.getPlayer().getName() +" is still online for kick event for potato event and gets removed now.", LogType.DEBUG);
		}
		XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(e.getPlayer().getName());
		if(xp instanceof XPlayer) {	
			if(xp.isPotato()) {
				xp.unvanish();
				xp.getBukkitPlayer().removePotionEffect(PotionEffectType.BLINDNESS);
				xp.getBukkitPlayer().removePotionEffect(PotionEffectType.INVISIBILITY);
				xp.getBukkitPlayer().removePotionEffect(PotionEffectType.SPEED);
				Item potato = xp.getPotato();
				potato.remove();
				xp.removePotato();
			}
		}	
	}
}
 
Example 15
Project: simple-survival-games   File: SSGPlayerListener.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void onPlayerKick(PlayerKickEvent event) {
	Player p = event.getPlayer();
	ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();
	
	// Make sure the player is not null
	if(p == null)
		return;
	
	// Make sure the event was not cancelled
	if(event.isCancelled())
		return;
	
	// Is the current in any arena
	if(am.isInArena(p)) {
		Arena arena = am.getPlayer(p).getArena();
		
		// Kick the player out of the arena
		SimpleSurvivalGames.instance.getArenaManager().kick(p);
		
		// Show a message to all players this player died
		arena.sendMessage(ChatColor.GOLD + p.getName() + ChatColor.DARK_RED + " lost connection!");
	}
}
 
Example 16
Project: AuthMeReloaded   File: PlayerListenerTest.java   Source Code and License 6 votes vote down vote up
@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 17
Project: AuthMeReloaded   File: PlayerListenerTest.java   Source Code and License 6 votes vote down vote up
@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);
    verifyZeroInteractions(management);
}
 
Example 18
Project: mczone   File: PlayerEvents.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onPlayerKick(PlayerKickEvent event) {
	for (PetInstance p : PetInstance.getList()) {
		if (p.getOwner().equalsIgnoreCase(event.getPlayer().getName())) {
			if (p.getEntity() != null) {
				p.setToSpawn(true);
				p.getEntity().remove();
			}
		}
	}
}
 
Example 19
Project: HCFCore   File: LogoutTimer.java   Source Code and License 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent event) {
    UUID uuid = event.getPlayer().getUniqueId();
    if (getRemaining(event.getPlayer().getUniqueId()) > 0L) {
        clearCooldown(uuid);
    }
}
 
Example 20
Project: HCFCore   File: StuckTimer.java   Source Code and License 5 votes vote down vote up
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent event)
{
    UUID uuid = event.getPlayer().getUniqueId();
    if (getRemaining(event.getPlayer().getUniqueId()) > 0L) {
        clearCooldown(uuid);
    }
}
 
Example 21
Project: HCFCore   File: LogoutTimer.java   Source Code and License 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent event) {
    UUID uuid = event.getPlayer().getUniqueId();
    if (getRemaining(event.getPlayer().getUniqueId()) > 0L) {
        clearCooldown(uuid);
    }
}
 
Example 22
Project: HCFCore   File: StuckTimer.java   Source Code and License 5 votes vote down vote up
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent event)
{
    UUID uuid = event.getPlayer().getUniqueId();
    if (getRemaining(event.getPlayer().getUniqueId()) > 0L) {
        clearCooldown(uuid);
    }
}
 
Example 23
Project: ZorahPractice   File: PlayerManager.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onKick(PlayerKickEvent event) {
    Player player = event.getPlayer();

    if (this.profiles.containsKey(player.getUniqueId())) {
        this.profiles.get(player.getUniqueId()).save(new GenericCallback() {
            @Override
            public void call(boolean result) {
                profiles.remove(player.getUniqueId());
            }
        });
    }
}
 
Example 24
Project: ZorahPractice   File: KitEditManager.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onKick(PlayerKickEvent event) {
    if (!this.editKits.containsKey(event.getPlayer().getUniqueId())) {
        return;
    }

    this.editKits.remove(event.getPlayer().getUniqueId());
}
 
Example 25
Project: GamePlate   File: ConnectionModule.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onKick(PlayerKickEvent event) {
    TeamModule teamModule = TeamManager.getTeamByPlayer(event.getPlayer());
    if (teamModule != null) {
        teamModule.removePlayer(event.getPlayer());
    }

    if (attachmentMap.containsKey(event.getPlayer().getUniqueId())) {
        event.getPlayer().removeAttachment(attachmentMap.get(event.getPlayer().getUniqueId()));
        attachmentMap.remove(event.getPlayer().getUniqueId());
    }
}
 
Example 26
Project: Skript   File: ExprMessage.java   Source Code and License 5 votes vote down vote up
@Override
@Nullable
String get(final Event e) {
	if (e instanceof PlayerKickEvent)
		return ((PlayerKickEvent) e).getLeaveMessage();
	else
		return ((PlayerQuitEvent) e).getQuitMessage();
}
 
Example 27
Project: Skript   File: ExprMessage.java   Source Code and License 5 votes vote down vote up
@Override
void set(final Event e, final String message) {
	if (e instanceof PlayerKickEvent)
		((PlayerKickEvent) e).setLeaveMessage(message);
	else
		((PlayerQuitEvent) e).setQuitMessage(message);
}
 
Example 28
Project: Skript   File: EffKick.java   Source Code and License 5 votes vote down vote up
@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 29
Project: SimpleFreeze   File: EssentialsHook.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onPlayerKick(PlayerKickEvent e) {
    UUID uuid = e.getPlayer().getUniqueId();
    new BukkitRunnable() {
        @Override
        public void run() {
            if (playerManager.isFrozen(uuid) && !playerManager.isFreezeAllFrozen(uuid) && (isBanned(uuid) || isBanned(e.getPlayer().getAddress().getHostName()))) {
                freezeManager.unfreeze(uuid);
            }
        }
    }.runTaskLater(this.plugin, 1L);
}
 
Example 30
Project: Pokkit   File: PlayerConnectEvents.java   Source Code and License 5 votes vote down vote up
@EventHandler(ignoreCancelled = false)
public void onPlayerKick(cn.nukkit.event.player.PlayerKickEvent event) {
	if (!canIgnore(PlayerKickEvent.getHandlerList())) {
		PlayerKickEvent bukkitEvent = new PlayerKickEvent(PokkitPlayer.toBukkit(event.getPlayer()),
				event.getReason(), event.getQuitMessage().getText());
		callCancellable(event, bukkitEvent);
		event.setQuitMessage(toNukkit(event.getQuitMessage(), bukkitEvent.getLeaveMessage(), event));
	}

	removeFromOnlinePlayers(event.getPlayer());
}
 
Example 31
Project: WhiteEggCore   File: PlayerListener.java   Source Code and License 5 votes vote down vote up
public void onKick(PlayerKickEvent event) {
    if (!WhiteEggCore.getConf().getConfig().getBoolean("setting.savePlayerData", true)) {
        return;
    }
    WhitePlayer player = WhiteEggAPI.getPlayer(event.getPlayer());
    ((WhiteEggPlayer) player).saveTask();
}
 
Example 32
Project: SurvivalCG   File: TabAPI.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void PlayerKick(PlayerKickEvent e)
{
    //cleanup
    playerTab.remove(e.getPlayer().getName());
    playerTabLast.remove(e.getPlayer().getName());
    playerTab47.remove(e.getPlayer().getName());
    playerTabLast47.remove(e.getPlayer().getName());
}
 
Example 33
Project: buildinggame   File: Leave.java   Source Code and License 5 votes vote down vote up
/**
    * Handles players getting kicked
    *
    * @param e an event representing a player getting kicked
    * @see PlayerKickEvent
    * @since 2.1.0
    */
@EventHandler
public void onPlayerKick(PlayerKickEvent e) {
	Player player = e.getPlayer();
	
	if (ArenaManager.getInstance().getArena(player) == null) {
		return;
	}
	
	Arena arena = ArenaManager.getInstance().getArena(player);
	
	arena.leave(player);
}
 
Example 34
Project: BlockParty-1.8   File: DisconnectListener.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onKick(PlayerKickEvent e) {
	if (BlockParty.inGamePlayers.containsKey(e.getPlayer().getName())) {
		BlockParty.inGamePlayers.remove(e.getPlayer().getName());
	}
	if (BlockParty.inLobbyPlayers.containsKey(e.getPlayer().getName())) {
		BlockParty.inLobbyPlayers.remove(e.getPlayer().getName());
	}
	if (BlockParty.onFloorPlayers.containsKey(e.getPlayer().getName())) {
		BlockParty.onFloorPlayers.remove(e.getPlayer().getName());
	}
	BlockParty.inventoriesToRestore.add(e.getPlayer().getPlayer().getName());
}
 
Example 35
Project: Peacecraft   File: PermsListener.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onPlayerKick(PlayerKickEvent event) {
    if(this.attachments.containsKey(event.getPlayer().getName())) {
        this.detach(event.getPlayer());
        this.attachments.remove(event.getPlayer().getName());
    }
}
 
Example 36
Project: sNoHax   File: Alerter.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onKick(PlayerKickEvent event) {
	Player player = event.getPlayer();
	if(silent.contains(player.getName())) {
		silent.remove(player.getName());
	}
}
 
Example 37
Project: TimeVote   File: EventListener.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onKick(PlayerKickEvent e) {
	Player p = e.getPlayer();

	if (TimeVoteListener.isVoting(p.getWorld().getName())) {
		TimeVoteListener.getVoteing(p.getWorld().getName()).switchWorld(p, false);
	}
}
 
Example 38
Project: defend-the-village   File: Main.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority=EventPriority.HIGHEST)
public void onKick(PlayerKickEvent ev)
{
	Player player = ev.getPlayer();
	
	if (this.am.isInGame(player)) {
		// If the player is in game, remove it to avoid get locked
		// in the arena.
		this.am.removePlayer(player);
	}
}
 
Example 39
Project: BossbarAPI   File: BossbarAPI.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void PlayerKick(PlayerKickEvent event) {
	Player p = event.getPlayer();
	removeBar(p);
	FDragon.removehorligneD(p);
	FWither.removehorligneW(p);
}
 
Example 40
Project: Almura-Server   File: PlayerConnection.java   Source Code and License 5 votes vote down vote up
public void disconnect(String s) {
    if (!this.disconnected) {
        // CraftBukkit start
        String leaveMessage = EnumChatFormat.YELLOW + this.player.getName() + " left the game.";

        PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage);

        if (this.server.getServer().isRunning()) {
            this.server.getPluginManager().callEvent(event);
        }

        if (event.isCancelled()) {
            // Do not kick the player
            return;
        }
        // Send the possibly modified leave message
        s = event.getReason();
        // CraftBukkit end

        this.player.l();
        this.sendPacket(new Packet255KickDisconnect(s));
        this.networkManager.d();

        // CraftBukkit start
        leaveMessage = event.getLeaveMessage();
        if (leaveMessage != null && leaveMessage.length() > 0) {
            this.minecraftServer.getPlayerList().sendMessage(ChatMessage.d(leaveMessage));
        }
        // CraftBukkit end

        this.minecraftServer.getPlayerList().disconnect(this.player);
        this.disconnected = true;
    }
}
 
Example 41
Project: Annihilation   File: PlayerListener.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onKick(PlayerKickEvent e) {
    if (e.getReason()
            .equals(ChatColor.RED + "ANNIHILATION-TRIGGER-KICK-01")) {
        e.setReason(ChatColor.RED
                + "You cannot join the game in this phase!");
        e.setLeaveMessage(null);
    }
}
 
Example 42
Project: StarQuestCode   File: LogoutListener.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL)
public void setFormatChat( PlayerKickEvent e ) {
    PlayerManager.unloadPlayer( e.getPlayer().getName() );
    if ( ServerData.usingConnectionMessages() ) {
        e.setLeaveMessage( null );
    }
}
 
Example 43
Project: DDCustomPlugin   File: Chat.java   Source Code and License 5 votes vote down vote up
@EventHandler (priority = EventPriority.LOW)
	public void onPlayerKick(PlayerKickEvent e) {
		e.setLeaveMessage("     " + ChatColor.DARK_RED + "" + ChatColor.BOLD + "! " + utils.getNamePrefix(e.getPlayer()) + e.getPlayer().getName() + ChatColor.WHITE +  " - " + ChatColor.RED + "" + ChatColor.ITALIC + e.getReason());
		System.out.println("! " + e.getPlayer().getName() + " " + e.getReason());
//		for (RegisteredListener list : e.getHandlers().getRegisteredListeners()) {
//			log(list.getPlugin().toString());
//		}
//		e.setCancelled(true);
	}
 
Example 44
Project: Cauldron   File: NetHandlerPlayServer.java   Source Code and License 5 votes vote down vote up
public void kickPlayerFromServer(String p_147360_1_)
{
    // CraftBukkit start
    String leaveMessage = EnumChatFormatting.YELLOW + this.playerEntity.getCommandSenderName() + " left the game.";
    PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.playerEntity), p_147360_1_, leaveMessage);

    if (this.server.getServer().isServerRunning())
    {
        this.server.getPluginManager().callEvent(event);
    }

    if (event.isCancelled())
    {
        // Do not kick the player
        return;
    }

    // Send the possibly modified leave message
    p_147360_1_ = event.getReason();
    // CraftBukkit end
    final ChatComponentText chatcomponenttext = new ChatComponentText(p_147360_1_);
    this.netManager.scheduleOutboundPacket(new S40PacketDisconnect(chatcomponenttext), new GenericFutureListener[] {new GenericFutureListener()
    {
        private static final String __OBFID = "CL_00001453";
        public void operationComplete(Future p_operationComplete_1_)
        {
            NetHandlerPlayServer.this.netManager.closeChannel(chatcomponenttext);
        }
    }});
    this.onDisconnect(chatcomponenttext); // CraftBukkit - Process quit immediately
    this.netManager.disableAutoRead();
}
 
Example 45
Project: manco2   File: CleanMemoryEvent.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH)
public void onQuit(PlayerKickEvent e) {
	if(pl.containsPlayer(e.getPlayer().getName())) {
		CratePlayer p = pl.getCratePlayer(e.getPlayer().getName());
		p.remove();
	}
}
 
Example 46
Project: Titanfall   File: TitanMenu.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onPlayerKick(PlayerKickEvent event) {
    try {
        if (this.playerName.equals(event.getPlayer().getName())) this.closeMenu(false, true);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
Example 47
Project: Titanfall   File: ClassMenu.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onPlayerKick(PlayerKickEvent event) {
    try {
        if (this.playerName.equals(event.getPlayer().getName())) this.closeMenu(false, true);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
Example 48
Project: BlockParty   File: DisconnectListener.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onKick(PlayerKickEvent e) {
	if (BlockParty.inGamePlayers.containsKey(e.getPlayer().getName())) {
		BlockParty.inGamePlayers.remove(e.getPlayer().getName());
	}
	if (BlockParty.inLobbyPlayers.containsKey(e.getPlayer().getName())) {
		BlockParty.inLobbyPlayers.remove(e.getPlayer().getName());
	}
	if (BlockParty.onFloorPlayers.containsKey(e.getPlayer().getName())) {
		BlockParty.onFloorPlayers.remove(e.getPlayer().getName());
	}
	BlockParty.inventoriesToRestore.add(e.getPlayer().getPlayer().getName());
}
 
Example 49
Project: GoogleAnalyticsPlugin   File: GoogleAnalyticsEventListener.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent event){
	if(enableEventKicked) {
		try {
			Player player = event.getPlayer();

			if(!player.hasPermission("googleanalyticsplugin.ignore")) {
				plugin.getTracker().TrackAction(getClientName(plugin, player), getClientId(player), getClientIP(player.getAddress().getAddress()), player.getName(), "Kicked", event.getReason());
			}
		}
		catch(Exception e) {
			plugin.getLogger().warning("Event Listener Error: " + e.getMessage());
		}
	}
}
 
Example 50
Project: CharacterCards   File: PlayerListener.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerKicked(PlayerKickEvent event)
   {
	Player player = event.getPlayer();
	RpChar character = plugin.getCharacterManager().getCharacter(player);
	if (character == null)
		return;
       plugin.getStorage().saveCharacter(character);
}
 
Example 51
Project: TechUtils   File: PlayerManager.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onQuit(PlayerKickEvent event) {
    final TechPlayer player = getPlayer(event.getPlayer());
    new BukkitRunnable() {

        @Override
        public void run() {
            player.destroy();
        }
    }.runTaskLater(plugin, 1);
}
 
Example 52
Project: PV-Star   File: PlayerEventListener.java   Source Code and License 5 votes vote down vote up
@EventHandler
private void onPlayerKick(PlayerKickEvent event) {

    final ArenaPlayer player = ArenaPlayer.get(event.getPlayer());
    if (player == null)
        return;

    final AbstractArena arena = player.getArena();

    if (arena != null) {
        arena.remove(player, PlayerLeaveArenaReason.KICK);
    }

    ArenaPlayer.dispose(player);
}
 
Example 53
Project: NucleusFramework   File: InternalPlayerTracker.java   Source Code and License 5 votes vote down vote up
@EventHandler
private void onPlayerKick(PlayerKickEvent event) {
    synchronized (_sync) {
        _lastLogins.remove(event.getPlayer());
        _lastWorldChange.remove(event.getPlayer());
    }
}
 
Example 54
Project: CrafterNexus   File: PlayerListener.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onKick(PlayerKickEvent e) {
    if (e.getReason()
            .equals(ChatColor.RED + "ANNIHILATION-TRIGGER-KICK-01")) {
        e.setReason(ChatColor.RED
                + "You cannot join the game in this phase!");
        e.setLeaveMessage(null);
    }
}
 
Example 55
Project: PvZ   File: Events.java   Source Code and License 5 votes vote down vote up
@EventHandler
private void onPlayerKickEvent(final PlayerKickEvent event) {
	if (!api.getGameManager().isPlayerInGame(event.getPlayer()))
		return;
	api.getTeamManager().removePlant(event.getPlayer());
	api.getTeamManager().removeZombie(event.getPlayer());
}
 
Example 56
Project: ManCo   File: CleanMemoryEvent.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH)
public void onQuit(PlayerKickEvent e) {
	if(pl.containsPlayer(e.getPlayer().getName())) {
		CratePlayer p = pl.getCratePlayer(e.getPlayer().getName());
		p.remove();
	}
}
 
Example 57
Project: RoyalIRC   File: BChatListener.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onKick(PlayerKickEvent e) {
    if (plugin.vanishLoaded() && VNPHandler.isVanished(e.getPlayer())) return;
    String message = Config.btiKick;
    final String reason = (e.getReason().isEmpty()) ? Config.defaultReason : e.getReason();
    message = replaceVars(e, message);
    message = message.replace("{message}", reason.replaceAll("\\r?\\n", " "));
    plugin.bh.sendMessage(message);
}
 
Example 58
Project: CrazyLogin   File: PlayerListener.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void PlayerKickMessage(final PlayerKickEvent event) {
	final Player player = event.getPlayer();
	if (plugin.isUsingCustomJoinQuitMessagesEnabled()) {
		if (event.getLeaveMessage() != null) {
			if (event.getLeaveMessage().equals("CRAZYLOGIN.KICK")) {
				sendDefaultPlayerKickMessage(player);
				event.setLeaveMessage(null);
			}
		}
	}
}
 
Example 59
Project: SpigotSource   File: PlayerConnection.java   Source Code and License 5 votes vote down vote up
public void disconnect(String s) {
    // CraftBukkit start - fire PlayerKickEvent
    String leaveMessage = EnumChatFormat.YELLOW + this.player.getName() + " left the game.";

    PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage);

    if (this.server.getServer().isRunning()) {
        this.server.getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        // Do not kick the player
        return;
    }
    // Send the possibly modified leave message
    s = event.getReason();
    // CraftBukkit end
    final ChatComponentText chatcomponenttext = new ChatComponentText(s);

    this.networkManager.sendPacket(new PacketPlayOutKickDisconnect(chatcomponenttext), new GenericFutureListener() {
        public void operationComplete(Future future) throws Exception { // CraftBukkit - decompile error
            PlayerConnection.this.networkManager.close(chatcomponenttext);
        }
    }, new GenericFutureListener[0]);
    this.a(chatcomponenttext); // CraftBukkit - fire quit instantly
    this.networkManager.stopReading();
    // CraftBukkit - Don't wait
    this.minecraftServer.postToMainThread(new Runnable() {
        public void run() {
            PlayerConnection.this.networkManager.handleDisconnection();
        }
    });
}
 
Example 60
Project: DuelMe   File: PlayerKick.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent e) {
    Player player = e.getPlayer();
    String playerName = player.getName();
    UUID playerUUID = player.getUniqueId();

    DuelManager dm = plugin.getDuelManager();

    if(dm.isInDuel(playerUUID)){
        dm.endDuel(player);
    }
}