namespace Minecraft.Server.FourKit.Event.Player;
using Minecraft.Server.FourKit.Entity;
///
/// Fired when a player sends a chat message.
///
/// When the event finishes execution the server formats the final
/// output using the same format specifiers from Java.
/// %1$s is the player's display name and %2$s is the
/// message, exactly like Bukkits PlayerChatEvent.
///
public class PlayerChatEvent : PlayerEvent, Cancellable
{
private string _message;
private string _format;
private bool _cancelled;
internal PlayerChatEvent(Player player, string message) : base(player)
{
_message = message;
_format = "<%1$s> %2$s";
}
///
/// Gets the message that the player is attempting to send.
/// This message will be used with .
///
/// Message the player is attempting to send.
public string getMessage() => _message;
///
/// Sets the message that the player will send.
/// This message will be used with .
///
/// New message that the player will send.
public void setMessage(string message)
{
_message = message;
}
///
/// Gets the format used to display this chat message.
///
/// When this event finishes execution, the first format parameter
/// (%1$s) is Player.getDisplayName() and the second
/// parameter (%2$s) is getMessage().
///
/// A Java-style positional format string compatible with Bukkit.
public string getFormat() => _format;
///
/// Sets the format used to display this chat message.
///
/// When this event finishes execution, the first format parameter
/// (%1$s) is Player.getDisplayName() and the second
/// parameter (%2$s) is getMessage().
///
/// A Java-style positional format string (e.g. "<%1$s> %2$s").
/// If format is null.
public void setFormat(string format)
{
ArgumentNullException.ThrowIfNull(format);
_format = format;
}
///
public bool isCancelled() => _cancelled;
///
public void setCancelled(bool cancel)
{
_cancelled = cancel;
}
}