Pre Join event cancelmessage

Hey,

how do I set a special kickmessage, in the PreJoinEvent of Sponge?
Like bukkit with e.result? But this doesn’t work.

Please help

PT400C

Use ClientConnectionEvent.Auth for your event, then call setCancelled(true) and setMessage(kickMessage).

Hey,

this works, but the Message is everytime: “You are not allowed to log in to this server”.
How can I change it to my message?

please help me :smiley:

PT400C

Try adding setMessageCancelled(false) as well.

Where? Is the sequence nessacary?

Please help! :smiley:

PT400C

It shouldn’t matter where you put it. In general, the order in which you call setter methods on events doesn’t matter.

Nope :frowning: This doesn’t work. Why? Here is the code:

`@Listener
public void onClientAuth(ClientConnectionEvent.Auth event) {

    event.setCancelled(true);
    event.setMessageCancelled(true);
    event.setMessage(Text.builder("2323").build());
         
}`

Please help :slight_smile:

PT400C

Whoops - setMessageCancelled needs to be false. Sorry.

In case you’re curious, here’s the code that fires the event.