How to kick a player from a server?

Simple question: I need to know how to kick a player from the server with a custom message such as “Flying is not allowed!”.

public void onPlayerJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    World world = player.getWorld();

I tried looking through the possible suggestions for player, but I could find anything. Could anyone take a minute to help me?

IIRC you can disable flying in the

but looks like we’re waiting for the bans API to get merged

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

Tell me, how does that conribute to the discussion?

1 Like

Edit sorry, didn’t see how old this post is. Although I am wondering if I’m doing it properly with the current build of sponge.

I’m trying to do that now myself, would this be right?

Player player = event.getUser();
player.kick(Texts.of("message here"))

Yes, that is correct.

I don’t think Player.kick is actually implemented in SpongeCommon yet so it will probably error if you try running it.

that’s actually a relief @simon816, I couldn’t figure out why it kept giving me an error lol