Kicked before join

Discussion in 'Plugin Development' started by Reteckz, Mar 30, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Reteckz

    Hello,

    I'm making an auto-kick system for none-staff players, but got on this problem.
    If the system is activated, players will get kicked when they trigger the onjoin event and dont have a certain permission.

    The problem is, in chat it shows: Player left the game, Player joined the game, instead of join and then leave. They do get the kick message and a communication error, but when you press tab ingame with your staff account it still shows their name and counts them as online.

    Is there any way to fix this?

    Onjoin code:

    Code:
    @EventHandler
        public void onJoin(PlayerJoinEvent event) {
            getServer().getPluginManager().registerEvents(this, this);
            FileConfiguration config = getConfig();
            Player player = (Player) event.getPlayer();
            if(!(player.hasPermission("noentry.join"))) {
            String active = config.getString("NoEntry.Activated");
            if(active=="Yes") {
                String type = config.getString("NoEntry.Type.Using");
                String text = config.getString("NoEntry.Type."+type+"");
                player.kickPlayer(text);
            }
            }
        }
     
  2. Offline

    Chloe-chan

    I think you should set the result of the join event instead of kicking him.
     
  3. If they have permission let them on. Else event.setCanceled(true);
     
  4. Offline

    Reteckz

    Yup, but the problem would be that it would show no message.
    And a part of the plugin is that it shows you a chosen message whenever it kicks somebody ;)
     
  5. Offline

    RainoBoy97

    Use PlayerLoginEvent?
     
  6. Offline

    Cirno

    Either what RainoBoy97 suggested, PlayerLoginEvent, or you can use ProtocolLib.
     
  7. Offline

    dcgamingentral

    Reteckz

    Use this:
    Code:
    event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Message here");
    
    but you will have to use PlayerLoginEvent


    or use:
    Code:
    event.setJoinMessage("")
    on PlayerJoinEvent

    Hope this helps :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
Thread Status:
Not open for further replies.

Share This Page