namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Entity;
///
/// Fired when a player is kicked from the server.
/// If cancelled, the kick will not take place and the player remains connected.
/// Plugins may modify the kick reason and the leave message broadcast to
/// all online players.
///
public class PlayerKickEvent : PlayerEvent, Cancellable
{
private DisconnectReason _reason;
private string _leaveMessage;
private bool _cancelled;
internal PlayerKickEvent(Player playerKicked, DisconnectReason kickReason, string leaveMessage)
: base(playerKicked)
{
_reason = kickReason;
_leaveMessage = leaveMessage;
}
///
/// Gets the reason why the player is getting kicked.
///
/// The disconnect reason.
public DisconnectReason getReason() => _reason;
///
/// Sets the reason why the player is getting kicked.
///
/// The new disconnect reason.
public void setReason(DisconnectReason kickReason)
{
_reason = kickReason;
}
///
/// Gets the leave message sent to all online players.
///
/// The leave message.
public string getLeaveMessage() => _leaveMessage;
///
/// Sets the leave message sent to all online players.
///
/// The new leave message.
public void setLeaveMessage(string leaveMessage)
{
_leaveMessage = leaveMessage;
}
///
public bool isCancelled() => _cancelled;
///
public void setCancelled(bool cancel)
{
_cancelled = cancel;
}
}