1.15.2 PlakerKickEvent bug? Not able to set message

Discussion in 'Spigot Plugin Development' started by Maxx_Qc, Jan 24, 2020.

  1. Hey guys, so I'm actually having a problem with my plugin. I don't know if it's a bug on my side (some events interferring or something) but the PlayerKickEvent.setLeaveMessage() doesn't appear to work.

    Code (Text):

    @EventHandler
    public void onLeave(PlayerQuitEvent event)
    {
       event.setQuitMessage(Helper.colorize("&8[&c-&8] &7" + event.getPlayer().getName()));
    }

    @EventHandler
    public void onKick(PlayerKickEvent event)
    {
       event.setLeaveMessage(Helper.colorize("&8[&c-&8] &7" + event.getPlayer().getName() + " &8(Kicked for " + event.getReason() + ")"));
    }
    When I kick a player, the PlayerQuitEvent's message appears but not the PlayerKickEvent. I would like to show the kick reason.

    Thanks y'all :)
     
  2. setLeaveMessage(): Sets the leave message send to all online players
    setReason(): Sets the reason why the player is getting kicked

    So you have to use the setReason() method :)
     
  3. I think you do not understand my request.
    My goal is to set the leave message, not to change the reason.
    When a player is kicked, I want every players to see in the chat (Player left the game (Kicked for: reason))
    Since it's not working I'm going to use a work-a-round but I just wanted to know if that's a normal behavior or a bug.
     
  4. I would add the player to an arraylist when kicked, and then on the quit event do something like this
    Code (Text):
    if(list.contains(p (or their UUID eitherway)) {
    Kick message
    remove from list
    } else {
    quit message
    }