private static void BringPlayerToWorld( [NotNull] Player player, [NotNull] Player target, [NotNull] World world,
bool overridePermissions, bool usePlayerPosition)
{
if ( player == null )
throw new ArgumentNullException( "player" );
if ( target == null )
throw new ArgumentNullException( "target" );
if ( world == null )
throw new ArgumentNullException( "world" );
switch ( world.AccessSecurity.CheckDetailed( target.Info ) ) {
case SecurityCheckResult.Allowed:
case SecurityCheckResult.WhiteListed:
if ( world.IsFull ) {
player.Message( "Cannot bring {0}&S because world {1}&S is full.",
target.ClassyName,
world.ClassyName );
return;
}
target.StopSpectating();
if ( usePlayerPosition ) {
target.JoinWorld( world, WorldChangeReason.Bring, player.Position );
} else {
target.JoinWorld( world, WorldChangeReason.Bring );
}
break;
case SecurityCheckResult.BlackListed:
player.Message( "Cannot bring {0}&S because he/she is blacklisted on world {1}",
target.ClassyName,
world.ClassyName );
break;
case SecurityCheckResult.RankTooLow:
if ( overridePermissions ) {
target.StopSpectating();
if ( usePlayerPosition ) {
target.JoinWorld( world, WorldChangeReason.Bring, player.Position );
} else {
target.JoinWorld( world, WorldChangeReason.Bring );
}
} else {
player.Message( "Cannot bring {0}&S because world {1}&S requires {2}+&S to join.",
target.ClassyName,
world.ClassyName,
world.AccessSecurity.MinRank.ClassyName );
}
break;
// TODO: case PermissionType.RankTooHigh:
}
}