namespace Minecraft.Server.FourKit.Event.Block;
using Minecraft.Server.FourKit.Block;
using Minecraft.Server.FourKit.Entity;
///
/// Called when a sign is changed by a player.
///
public class SignChangeEvent : BlockEvent, Cancellable
{
private readonly Player _player;
private readonly string[] _lines;
private bool _cancel;
internal SignChangeEvent(Block theBlock, Player thePlayer, string[] theLines)
: base(theBlock)
{
_player = thePlayer;
_lines = theLines;
_cancel = false;
}
///
/// Gets the player changing the sign involved in this event.
///
/// The Player involved in this event.
public Player getPlayer() => _player;
///
/// Gets all of the lines of text from the sign involved in this event.
///
/// The String array for the sign's lines new text.
public string[] getLines() => _lines;
///
/// Gets a single line of text from the sign involved in this event.
///
/// Index of the line to get.
/// The String containing the line of text associated with the provided index.
/// Thrown when the provided index is > 3 or < 0.
public string getLine(int index)
{
if (index < 0 || index > 3)
throw new IndexOutOfRangeException($"Line index must be between 0 and 3, got {index}");
return _lines[index];
}
///
/// Sets a single line for the sign involved in this event.
///
/// Index of the line to set.
/// Text to set.
/// Thrown when the provided index is > 3 or < 0.
public void setLine(int index, string line)
{
if (index < 0 || index > 3)
throw new IndexOutOfRangeException($"Line index must be between 0 and 3, got {index}");
_lines[index] = line;
}
///
public bool isCancelled() => _cancel;
///
public void setCancelled(bool cancel) => _cancel = cancel;
}