Java Code Examples for org.bukkit.event.player.PlayerKickEvent.getPlayer()

The following are Jave code examples for showing how to use getPlayer() of the org.bukkit.event.player.PlayerKickEvent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: BiteSkywars   File: PlayerListener.java   Source Code and License Vote up 6 votes
@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 Vote up 6 votes
@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: Statz   File: TimesKickedListener.java   Source Code and License Vote up 6 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;

	// 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 4
Project: BiteSkywars   File: PlayerListener.java   Source Code and License Vote up 6 votes
@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 5
Project: StarQuestCode   File: SQGlobalInfo.java   Source Code and License Vote up 6 votes
@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 6
Project: CrazyLogin   File: PlayerListener.java   Source Code and License Vote up 6 votes
@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 7
Project: BAMradio   File: WGRegionEventsListener.java   Source Code and License Vote up 6 votes
@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 8
Project: simple-survival-games   File: SSGPlayerListener.java   Source Code and License Vote up 6 votes
@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 9
Project: ZorahPractice   File: PlayerManager.java   Source Code and License Vote up 5 votes
@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 10
Project: buildinggame   File: Leave.java   Source Code and License Vote up 5 votes
/**
    * 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 11
Project: sNoHax   File: Alerter.java   Source Code and License Vote up 5 votes
@EventHandler
public void onKick(PlayerKickEvent event) {
	Player player = event.getPlayer();
	if(silent.contains(player.getName())) {
		silent.remove(player.getName());
	}
}
 
Example 12
Project: TimeVote   File: EventListener.java   Source Code and License Vote up 5 votes
@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 13
Project: defend-the-village   File: Main.java   Source Code and License Vote up 5 votes
@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 14
Project: BossbarAPI   File: BossbarAPI.java   Source Code and License Vote up 5 votes
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void PlayerKick(PlayerKickEvent event) {
	Player p = event.getPlayer();
	removeBar(p);
	FDragon.removehorligneD(p);
	FWither.removehorligneW(p);
}
 
Example 15
Project: GoogleAnalyticsPlugin   File: GoogleAnalyticsEventListener.java   Source Code and License Vote up 5 votes
@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 16
Project: CharacterCards   File: PlayerListener.java   Source Code and License Vote up 5 votes
@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 17
Project: CrazyLogin   File: PlayerListener.java   Source Code and License Vote up 5 votes
@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 18
Project: DuelMe   File: PlayerKick.java   Source Code and License Vote up 5 votes
@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);
    }
}
 
Example 19
Project: UltimateArena   File: PlayerListener.java   Source Code and License Vote up 5 votes
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerKick(PlayerKickEvent event) 
{
	Player player = event.getPlayer();
	if (plugin.isInArena(player)) 
	{
		if (plugin.isInArena(player.getLocation())) 
		{
			if (event.getReason().equals("你移动的速度实在是太快了 :( (作弊了吧?)")) 
			{
				event.setCancelled(true);
			}
		}
	}
}
 
Example 20
Project: MineKart   File: JockeyListener.java   Source Code and License Vote up 5 votes
/**
 * Handle jockeys being kicked from the game
 * 
 * @param event The player kicked event
 */
@EventHandler
public void onJockeyKick(PlayerKickEvent event) {

	Player player = event.getPlayer();
	Jockey jockey = MineKart.getInstance().getJockey(player);

	if (jockey == null) {
		return;
	}

	jockey.getRace().removeJockey(jockey);
       LangUtils.sendMessage(player, "command.leave.success");

}
 
Example 21
Project: AuthMeReloaded   File: PlayerListener.java   Source Code and License Vote up 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 22
Project: Essentials   File: BukkitPermissions.java   Source Code and License Vote up 5 votes
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerKick(PlayerKickEvent event)
{

	Player player = event.getPlayer();

	/*
	 * force remove any attachments as bukkit may not
	 */
	removeAttachment(player);
}
 
Example 23
Project: DiscoArmor   File: DiscoArmorListener.java   Source Code and License Vote up 5 votes
@EventHandler
public void onKick(PlayerKickEvent e) {
  if ((getPlugin().players.containsKey(e.getPlayer().getName())) && 
    (getPlugin().players.containsKey(e.getPlayer().getName()))) {
    Player p = e.getPlayer();
    getPlugin().players.remove(e.getPlayer().getName());
    if (getPlugin().armor.containsKey(p.getName())) {
      ItemStack[] oa = (ItemStack[])getPlugin().armor.get(p.getName());
      p.getInventory().setArmorContents(oa);
      getPlugin().armor.remove(p.getName());
    }
  }
}
 
Example 24
Project: Chambers   File: EnderpearlListener.java   Source Code and License Vote up 4 votes
@EventHandler
public void onPlayerKick(PlayerKickEvent event) {
	Player player = event.getPlayer();
	removeCooldown(player);
}
 
Example 25
Project: PerWorldInventory   File: PlayerQuitListener.java   Source Code and License Vote up 4 votes
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent event) {
    Player player = event.getPlayer();
    process.processPlayerLeave(player);
}
 
Example 26
Project: PerWorldInventory   File: PlayerQuitListener.java   Source Code and License Vote up 4 votes
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent event) {
    Player player = event.getPlayer();
    process.processPlayerLeave(player);
}
 
Example 27
Project: SwornRPG   File: PlayerListener.java   Source Code and License Vote up 4 votes
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerKick(PlayerKickEvent event)
{
	if (event.isCancelled())
		return;

	Player player = event.getPlayer();
	PlayerData data = plugin.getPlayerDataCache().getData(player);

	// Clear the previousLocation variable
	if (data.getPreviousLocation() != null)
	{
		player.teleport(data.getPreviousLocation());
		data.setPreviousLocation(null);
	}

	// Attempt to prevent invalid kicks caused by sitting in chairs.
	// This works by checking whether or not the player sat recently
	// and whether or not the kick was valid.  This only works on Spigot,
	// since the kick messages in CraftBukkit are "Nope", which can be for
	// a variety of reasons.

	if (data.isSatRecently() && event.getReason().equals("NaN in position (Hacking?)"))
	{
		// Check if their position is valid
		Location location = player.getLocation();
		if (isValid(location.getX()) && isValid(location.getY()) && isValid(location.getZ()))
		{
			plugin.getLogHandler().log("Blocked invalid kick for {0}", player.getName());
			event.setCancelled(true);
			return;
		}

		// Teleport them to spawn as a fallback
		player.teleport(player.getWorld().getSpawnLocation());

		// Were we successful?
		location = player.getLocation();
		if (isValid(location.getX()) && isValid(location.getY()) && isValid(location.getZ()))
		{
			plugin.getLogHandler().log("Corrected invalid position for {0}", player.getName());
			event.setCancelled(true);
			return;
		}
	}
}
 
Example 28
Project: EventoZero   File: EventListener.java   Source Code and License Vote up 2 votes
/**
 * Evento chamado quando um jogador é kickado do servidor
 *
 * TODO: tratar igual ao PlayerQuitEvent (exceto pela cláusula que diz
 * respeito de punições!)
 */
@EventHandler(priority = EventPriority.MONITOR)
public void whenKicked(final PlayerKickEvent event) {
    final Player sender = event.getPlayer();
    quitPlayer(sender);
}