Java Code Examples for org.bukkit.event.player.PlayerQuitEvent.setQuitMessage()

The following are Jave code examples for showing how to use setQuitMessage() of the org.bukkit.event.player.PlayerQuitEvent 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: UHC   File: JoinQuitHandlers.java   Source Code and License Vote up 7 votes
@EventHandler
public void leave(final PlayerQuitEvent event) {
    if(GameState.current() != GameState.LOBBY && event.getPlayer().getGameMode() != GameMode.SPECTATOR){
        event.setQuitMessage(colour("&6" + event.getPlayer().getName() + " has quit! " +
                "They have " + UHC.getInstance().getMainConfig().getDisconnectGracePeriodSeconds() + "s to reconnect."));

        bukkitRunnable(() -> disqualified(event.getPlayer().getUniqueId(), event.getPlayer().getName(),
                event.getPlayer().getLocation(), event.getPlayer().getInventory())).runTaskLater(UHC.getInstance(),
                TimeUnit.MILLISECONDS.convert(UHC.getInstance().getMainConfig().getDisconnectGracePeriodSeconds(), TimeUnit.SECONDS));

        //Zombie Spawning
        Zombie zombie = (Zombie) event.getPlayer().getWorld().spawnEntity(event.getPlayer().getLocation(), EntityType.ZOMBIE);
        zombie.setCustomName(event.getPlayer().getName());
        zombie.setCustomNameVisible(true);
        //TODO Make no AI and invulnerable cough cough Proxi cough cough
        deadRepresentatives.put(event.getPlayer().getUniqueId(), zombie);
    }
}
 
Example 2
Project: MooProject   File: ServerListener.java   Source Code and License Vote up 6 votes
@EventHandler(priority = EventPriority.HIGHEST)
public void onLeave(PlayerQuitEvent event) {
    if(!Moo.getInstance().isConnected()) return;
    Player player = event.getPlayer();

    PlayerData data = new PlayerData();
    data.setUuid(player.getUniqueId());
    data.setLastName(player.getName());
    data.setLastIp(player.getAddress().getHostString());

    // UPDATE SERVER INFO
    Lightning.getInstance().updateServerInfo();

    // SET QUIT MESSAGE
    String playerName = MooQueries.getInstance().getGroup(player.getUniqueId()).getColor() + player.getName();
    event.setQuitMessage(LanguageManager.get("quit-message-pattern", playerName));
}
 
Example 3
Project: KingdomFactions   File: PlayerQuitEventListener.java   Source Code and License Vote up 6 votes
@EventHandler
public void onQuit(PlayerQuitEvent e) {
	e.setQuitMessage(null);
	
	KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());
	if(p.getCombatTracker().isInCombat()) {
   p.getCombatTracker().handleDisconnect();
	Bukkit.getScheduler().runTaskLater(KingdomFactionsPlugin.getInstance(), new Runnable() {
		
		@Override
		public void run() {
			ChatModule.getInstance().getChannels().forEach(channel -> channel.leave(p, false));
		    p.saveLogOut();
		}
	}, 20*2L);
	} else {
	ChatModule.getInstance().getChannels().forEach(channel -> channel.leave(p, false));
	
    p.saveLogOut();
	}
	
}
 
Example 4
Project: mczone   File: GameEvents.java   Source Code and License Vote up 6 votes
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
    event.setQuitMessage(null);
    
    if (Team.getTeam(event.getPlayer()) == null)
    	return;
    
    if (!event.getPlayer().isDead() && !Walls.winners.contains(event.getPlayer()))
    	Team.getTeam(event.getPlayer()).leave(event.getPlayer());
    
    if (State.PRE)
        return;

    for (ItemStack i : event.getPlayer().getInventory().getContents())
    	if (i != null && i.getType() != Material.AIR)
    		Config.getWorld().dropItemNaturally(event.getPlayer().getLocation(), i);
    
    if (event.getPlayer().isDead() || Walls.winners.contains(event.getPlayer()))
        return;
		

    Hive.getInstance().getDatabase().update(String.format("INSERT INTO kills (server,game_id,player,target) VALUES ('%s',%d,'%s','%s')","walls",Walls.ID,"left",event.getPlayer().getName()));
    Chat.server(event.getPlayer().getDisplayName() + "&c has left the game! What a coward!");
}
 
Example 5
Project: mczone   File: GameEvents.java   Source Code and License Vote up 6 votes
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
	event.setQuitMessage(null);
	if (SurvivalGames.getWinner() != null)
		return;
	
	Player p = event.getPlayer();
	Gamer t = Gamer.get(event.getPlayer());
	
	if (!Game.getTributes().contains(t))
		return;

	Hive.getInstance().kill(p, "quit", SurvivalGames.getGame().getGameID());
	t.setVariable("death-location", event.getPlayer().getLocation());
	Chat.server("&4[SG &6" + Gamer.get(p).getPrefix()  + t.getName() + " &6has quit the game!");
	Chat.server("&4[SG] &6There are " + (Game.getTributes().size() - 1) + " tributes remaining");
}
 
Example 6
Project: SkywarsSeries   File: PlayerLeave.java   Source Code and License Vote up 6 votes
@EventHandler
public void onLeave(PlayerQuitEvent event) {
    Player player = event.getPlayer();

    event.setQuitMessage(null);

    Game game = Skywars.getInstance().getGame(player);
    if (game != null && game.getGamePlayer(player) != null) {
        GamePlayer gamePlayer = game.getGamePlayer(player);

        if (gamePlayer.isTeamClass()) {
            if (gamePlayer.getTeam().isPlayer(player)) {
                player.damage(player.getMaxHealth()); // Kill player to make game process this as a death
            }
        } else {
            if (gamePlayer.getPlayer() == player) {
                player.damage(player.getMaxHealth()); // Kill player to make game process this as a death
            }
        }
    }
}
 
Example 7
Project: VanillaPlus   File: PlayerManager.java   Source Code and License Vote up 6 votes
@EventHandler
public void playerLeave(PlayerQuitEvent event){
	event.setQuitMessage("");
	VPPlayer player = getPlayer(event.getPlayer());
	player.setMenu(null);
	VPPLeaveEvent e = new  VPPLeaveEvent(player);
	if(getMsgPerm().has(player))
		e.setMessage(leave);
	e.save(player.save());
	player.setOffline();
	Bukkit.getServer().getPluginManager().callEvent(e);
	//TODO send removed event
	if(e.getMessage() != null)
		e.getMessage().addSReplacement(PlaceH.SENDER.get(), player).send();
	if(e.save())
		save(player, false);
}
 
Example 8
Project: Arcadia-Spigot   File: ConnectionListener.java   Source Code and License Vote up 5 votes
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
    ArcadiaAPI api = Arcadia.getPlugin(Arcadia.class).getAPI();
    Translation translation = api.getTranslationManager().fetchTranslation("common.leave-message", event.getPlayer());
    if(translation != null) {
        final String message = translation.build(event.getPlayer().getName());
        if(!message.isEmpty()) {
            event.setQuitMessage(message);
        } else {
            event.setQuitMessage(null);
        }
    }
    if(api.getGameManager().isAlive(event.getPlayer())) api.getGameManager().setAlive(event.getPlayer(), false);
    if(api.getGameManager().isSpectating(event.getPlayer())) api.getGameManager().setSpectating(event.getPlayer(), false);
}
 
Example 9
Project: ProjectAres   File: JoinMessageAnnouncer.java   Source Code and License Vote up 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 10
Project: mczone   File: ConnectEvents.java   Source Code and License Vote up 5 votes
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event) {
	event.setQuitMessage(null);
	Arena match = Arena.getArena(event.getPlayer());
	if (match == null)
		return;
	
	match.leave(event.getPlayer());
}
 
Example 11
Project: mczone   File: ConnectEvents.java   Source Code and License Vote up 5 votes
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event) {
	event.setQuitMessage(null);
	Arena match = Arena.getArena(event.getPlayer());
	if (match == null)
		return;
	
	match.leave(event.getPlayer());
}
 
Example 12
Project: Warzone   File: JoinManager.java   Source Code and License Vote up 4 votes
@EventHandler(priority = EventPriority.MONITOR)
public void onQuit(PlayerQuitEvent event) {
    event.setQuitMessage(ChatColor.GRAY + event.getPlayer().getName() + " left.");
    handleQuit(event.getPlayer());
}
 
Example 13
Project: OpenRPG   File: TriggerQuitEvent.java   Source Code and License Vote up 4 votes
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
    event.setQuitMessage(null);

    Bukkit.getPluginManager().callEvent(new QuitEvent(PlayerManager.getInstance().deregister(event.getPlayer())));
}
 
Example 14
Project: kaosEssentials   File: Core.java   Source Code and License Vote up 4 votes
@EventHandler(priority=EventPriority.LOWEST)
public void onQuitM(PlayerQuitEvent e){
	if(isSjm(e.getPlayer().getUniqueId().toString())){
		e.setQuitMessage(ChatColor.DARK_GRAY + "[" + ChatColor.RED + "- " + e.getPlayer().getName() + ChatColor.DARK_GRAY + "]");
	}else{
		e.setQuitMessage("");
	}
	for(String name : pwli){
		Bukkit.getPlayer(name).sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GOLD + "@System" + ChatColor.DARK_GRAY + "] " +
				ChatColor.GRAY + e.getPlayer().getName() + " has left");
	}
}
 
Example 15
Project: mczone   File: Events.java   Source Code and License Vote up 4 votes
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
	event.setQuitMessage(null);
}
 
Example 16
Project: ZentrelaCore   File: LoginLogoutManager.java   Source Code and License Vote up 4 votes
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
    Player p = event.getPlayer();
    logoff(p);
    event.setQuitMessage("");
}
 
Example 17
Project: Kineticraft   File: MechanicManager.java   Source Code and License Vote up 4 votes
@EventHandler
public void onPlayerQuit(PlayerQuitEvent evt) {
    evt.setQuitMessage(null);
    onLeave(evt.getPlayer());
}
 
Example 18
Project: VoxelGamesLibv2   File: UserListener.java   Source Code and License Vote up 4 votes
@EventHandler(priority = EventPriority.LOW)
public void suppressQuitMessages(@Nonnull PlayerQuitEvent event) {
    event.setQuitMessage(null);
}
 
Example 19
Project: ChatAssets   File: LogHandler.java   Source Code and License Vote up 4 votes
public static void broadcastQuitMessage(String permission, PlayerQuitEvent event) {
	event.setQuitMessage(null);
	for (String x : quitmessage) {
		Bukkit.broadcast(x, permission);
	}
}
 
Example 20
Project: Chambers   File: ProfileListener.java   Source Code and License Vote up 4 votes
@EventHandler
public void onLeave(PlayerQuitEvent event) {
	removeProfile(event);
	event.setQuitMessage(null);
}