public void Unmute( [NotNull] Player player, bool announce, bool raiseEvents )
{
if ( player == null )
throw new ArgumentNullException( "player" );
// Check if player is trying to unmute self
if ( player.Info == this ) {
PlayerOpException.ThrowCannotTargetSelf( player, this, "unmute" );
}
lock ( actionLock ) {
TimeSpan timeLeft = TimeMutedLeft;
// Check if player can unmute in general
if ( !player.Can( Permission.Mute ) ) {
PlayerOpException.ThrowPermissionMissing( player, this, "unmute", Permission.Mute );
}
// Check if player has sufficient rank permissions
if ( !player.Can( Permission.Mute, Rank ) ) {
PlayerOpException.ThrowPermissionLimit( player, this, "mute", Permission.Mute );
}
if ( timeLeft <= TimeSpan.Zero ) {
string msg = String.Format( "Player {0} is not currently muted.", Name );
string msgColor = String.Format( "&SPlayer {0}&S is not currently muted.", ClassyName );
throw new PlayerOpException( player, this, PlayerOpExceptionCode.NoActionNeeded, msg, msgColor );
}
// raise PlayerInfo.MuteChanging event
if ( raiseEvents ) {
if ( RaiseMuteChangingEvent( this, player, timeLeft, true, announce ) ) {
PlayerOpException.ThrowCancelled( player, this );
}
}
Unmute();
// raise PlayerInfo.MuteChanged event
if ( raiseEvents ) {
RaiseMuteChangedEvent( this, player, timeLeft, true, announce );
}
// log and announce mute publicly
Logger.Log( LogType.UserActivity,
"Player {0} was unmuted by {1} ({2} was left on the mute)",
Name, player.Name, timeLeft );
if ( announce ) {
Player target = PlayerObject;
if ( target != null ) {
target.Message( "You were unmuted by {0}", player.ClassyName );
}
Server.Message( target,
"&SPlayer {0}&S was unmuted by {1}",
ClassyName, player.ClassyName );
}
}
}