org.bukkit.event.player.PlayerLoginEvent.Result Java Examples

The following examples show how to use org.bukkit.event.player.PlayerLoginEvent.Result. 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: PlayerConnectionListener.java    From UhcCore with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority=EventPriority.HIGHEST)
public void onPlayerLogin(PlayerLoginEvent event){
	GameManager gm = GameManager.getGameManager();

	// Player is not allowed to join so don't create UhcPlayer. (Server full, whitelist, ban, ...)
	if (event.getResult() != Result.ALLOWED){
		return;
	}
	
	try{
		boolean allowedToJoin = gm.getPlayersManager().isPlayerAllowedToJoin(event.getPlayer());

		if (allowedToJoin){
			// Create player if not existent.
			gm.getPlayersManager().getOrCreateUhcPlayer(event.getPlayer());
		}else{
			throw new UhcPlayerJoinException("An unexpected error as occured.");
		}
	}catch(final UhcPlayerJoinException e){
		event.setKickMessage(e.getMessage());
		event.setResult(Result.KICK_OTHER);
	}
}
 
Example #2
Source File: SkinApplyListener.java    From FastLogin with MIT License 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOW)
//run this on the loginEvent to let skins plugins see the skin like in normal Minecraft behaviour
public void onPlayerLogin(PlayerLoginEvent loginEvent) {
    if (loginEvent.getResult() != Result.ALLOWED) {
        return;
    }

    Player player = loginEvent.getPlayer();

    if (plugin.getConfig().getBoolean("forwardSkin")) {
        //go through every session, because player.getAddress is null
        //loginEvent.getAddress is just a InetAddress not InetSocketAddress, so not unique enough
        for (BukkitLoginSession session : plugin.getLoginSessions().values()) {
            if (session.getUsername().equals(player.getName())) {
                session.getSkin().ifPresent(skin -> applySkin(player, skin.getValue(), skin.getSignature()));
                break;
            }
        }
    }
}
 
Example #3
Source File: ModerationCommand.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onPreLogin(PlayerLoginEvent event) {
  // Format kick screen for banned players
  if (event.getResult().equals(Result.KICK_BANNED)) {
    String formatted =
        getPunishmentScreenFromName(event.getPlayer(), event.getPlayer().getName());
    if (formatted != null) {
      event.setKickMessage(formatted);
    }
  }
}
 
Example #4
Source File: PGMListener.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onPlayerLogin(final PlayerLoginEvent event) {
  // allow premiums to join when the server is full
  if (event.getResult() == Result.KICK_FULL) {
    if (event.getPlayer().hasPermission(Permissions.JOIN_FULL)) {
      event.allow();
    } else {
      event.setKickMessage(TextTranslations.translate("misc.serverFull", event.getPlayer()));
    }
  }
}
 
Example #5
Source File: EffKick.java    From Skript with GNU General Public License v3.0 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 #6
Source File: NPCMain.java    From AnnihilationPro with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOW)
public void onLogin(PlayerLoginEvent event)
{
    if(isTagged(event.getPlayer().getUniqueId()))
    {
        Boolean b = taggedPlayers.get(event.getPlayer().getUniqueId()).wasKilled();
        if(b == null)
        {
            event.setResult(Result.KICK_OTHER);
            event.setKickMessage(Lang.NPCALIVE.toString());
        }
    }
}
 
Example #7
Source File: ConnectionListener.java    From FastLogin with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerLogin(PlayerLoginEvent loginEvent) {
    removeBlacklistStatus(loginEvent.getPlayer());
    if (loginEvent.getResult() == Result.ALLOWED && !plugin.isServerFullyStarted()) {
        loginEvent.disallow(Result.KICK_OTHER, plugin.getCore().getMessage("not-started"));
    }
}
 
Example #8
Source File: PlayerLogin.java    From FunnyGuilds with Apache License 2.0 5 votes vote down vote up
@EventHandler
public void onLogin(PlayerLoginEvent event) {
    if (Bukkit.hasWhitelist()) {
        return;
    }
    
    String name = event.getPlayer().getName();
    if (name.length() < 2) {
        event.disallow(Result.KICK_OTHER, ChatUtils.colored("&cNick jest za krotki!"));
    }
    
    if (name.length() > 16) {
        event.disallow(Result.KICK_OTHER, ChatUtils.colored("&cNick jest za dlugi!"));
    }
    
    if (!name.matches(GuildRegex.LETTERS_DIGITS_UNDERSCORE.getPattern())) {
        event.disallow(Result.KICK_OTHER, ChatUtils.colored("&cNick zawiera niedozwolone znaki!"));
    }

    User user = User.get(event.getPlayer());

    if (user == null) {
        return;
    }

    BanUtils.checkIfBanShouldExpire(user);

    if (!user.isBanned()) {
        return;
    }
    
    event.disallow(Result.KICK_BANNED, BanUtils.getBanMessage(user));
}
 
Example #9
Source File: UHPluginListener.java    From KTP with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onPlayerLogin(PlayerLoginEvent ev) {
	if (this.p.isPlayerDead(ev.getPlayer().getName()) && !this.p.getConfig().getBoolean("allow-reconnect", true)) {
		ev.setResult(Result.KICK_OTHER);
		ev.setKickMessage("Vous ĂȘtes mort !");
	}
}
 
Example #10
Source File: EventListener.java    From iDisguise with Creative Commons Attribution Share Alike 4.0 International 4 votes vote down vote up
@EventHandler
public void onPlayerLogin(PlayerLoginEvent event) {
	if(!plugin.enabled()) {
		event.disallow(Result.KICK_OTHER, "Server start/reload has not finished yet");
	}
}