Exemplo n.º 1
0
        internal static Player FindPlayerMatches(Player player, string namePart, SearchOptions options) {
            // Repeat last-used player name
            if (namePart == "-") {
                if (player.LastUsedPlayerName != null) {
                    namePart = player.LastUsedPlayerName;
                } else {
                    player.Message("Cannot repeat player name: you haven't used any names yet.");
                    return null;
                }
            }

            // in case someone tries to use the "!" prefix in an online-only search
            if (namePart.Length > 0 && namePart[0] == '!')
                namePart = namePart.Substring(1);

            // Make sure player name is valid
            if (!Player.ContainsValidCharacters(namePart)) {
                player.MessageInvalidPlayerName(namePart);
                return null;
            }

            Player[] matches = Server.FindPlayers(player, namePart, options);
            if (matches.Length == 0) {
                player.MessageNoPlayer(namePart);
                return null;
            } else if (matches.Length > 1) {
                player.MessageManyMatches("player", matches);
                return null;
            } else {
                player.LastUsedPlayerName = matches[0].Name;
                return matches[0];
            }
        }
Exemplo n.º 2
0
        public static PlayerInfo FindByPartialNameOrPrintMatches( [NotNull] Player player, [NotNull] string partialName ) {
            if( player == null ) throw new ArgumentNullException( "player" );
            if( partialName == null ) throw new ArgumentNullException( "partialName" );
            CheckIfLoaded();
            if( partialName == "-" ) {
                if( player.LastUsedPlayerName != null ) {
                    partialName = player.LastUsedPlayerName;
                } else {
                    player.Message( "Cannot repeat player name: you haven't used any names yet." );
                    return null;
                }
            }
            if( !Player.ContainsValidCharacters( partialName ) ) {
                player.MessageInvalidPlayerName( partialName );
                return null;
            }
            PlayerInfo target = FindExact( partialName );
            if( target == null ) {
                PlayerInfo[] targets = FindByPartialName( partialName ).ToArray();
                if( targets.Length == 0 ) {
                    player.MessageNoPlayer( partialName );
                    return null;

                } else if( targets.Length > 1 ) {
                    Array.Sort( targets, new PlayerInfoComparer( player ) );
                    player.MessageManyMatches( "player", targets );
                    return null;
                }
                target = targets[0];
            }
            player.LastUsedPlayerName = target.Name;
            return target;
        }
Exemplo n.º 3
0
        internal static void Warn(Player player, Command cmd)
        {
            string name = cmd.Next();

            if (name == null)
            {
                player.Message("No player specified.");
                return;
            }

            Player target = Server.FindPlayerOrPrintMatches(player, name, false, true);

            if (target == null)
            {
                player.MessageNoPlayer(name);
                return;
            }

            if (player.Can(Permission.Warn, target.Info.Rank))
            {
                target.Info.IsHidden = false;
                if (target.Info.Warn(player.Name))
                {
                    Server.Message("{0}&S has been warned by {1}",
                                      target.ClassyName, player.ClassyName);
                    Scheduler.NewTask(t => target.Info.UnWarn()).RunOnce(TimeSpan.FromMinutes(15));
                }
                else
                {
                    try
                    {
                        Player targetPlayer = target;
                        target.Kick(player, "Auto Kick (2 warnings or more)", LeaveReason.Kick, true, true, true);
                    }
                    catch (PlayerOpException ex)
                    {
                        player.Message(ex.MessageColored);
                        if (ex.ErrorCode == PlayerOpExceptionCode.ReasonRequired)
                            return;
                    }
                }
            }
            else
            {
                player.Message("You can only warn players ranked {0}&S or lower",
                                player.Info.Rank.GetLimit(Permission.Warn).ClassyName);
                player.Message("{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName);
            }
        }
Exemplo n.º 4
0
        internal static void UnWarn(Player player, Command cmd)
        {
            string name = cmd.Next();
            if (name == null)
            {
                player.Message("No player specified.");
                return;
            }

            Player target = Server.FindPlayerOrPrintMatches(player, name, false, true);

            if (target == null)
            {
                player.MessageNoPlayer(name);
                return;
            }

            if (player.Can(Permission.Warn, target.Info.Rank))
            {
                if (target.Info.UnWarn())
                {
                    Server.Message("{0}&S had their warning removed by {1}.", target.ClassyName, player.ClassyName);
                }
                else
                {
                    player.Message("{0}&S does not have a warning.", target.ClassyName);
                }
            }
            else
            {
                player.Message("You can only unwarn players ranked {0}&S or lower",
                                player.Info.Rank.GetLimit(Permission.Warn).ClassyName);
                player.Message("{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName);
            }
        }
Exemplo n.º 5
0
        internal static void High5(Player player, Command cmd)
        {
            string targetName = cmd.Next();

            if (targetName == null)
            {
                cdHigh5.PrintUsage(player);
                return;
            }

            Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);

            if (target == null)
            {
                player.MessageNoPlayer(targetName);
                return;
            }
            if (target == player)
            {
                player.Message("You cannot high five yourself.");
                return;
            }
            else
            {
                if (target.IsOnline)
                {
                    Server.Players.Message("{0}&S was just &chigh fived &Sby {1}&S", target.ClassyName, player.ClassyName);
                    target.Message("{0}&S high fived you.", player.ClassyName);
                }
                else
                {
                    player.Message("Player {0}&S is not online.", target.ClassyName);
                }
            }
        }
Exemplo n.º 6
0
        static void TeleportHandler( Player player, CommandReader cmd ) {
            string name = cmd.Next();
            if( name == null ) {
                CdTeleport.PrintUsage( player );
                return;
            }

            if( cmd.Next() != null ) {
                cmd.Rewind();
                int x, y, z;
                if( cmd.NextInt( out x ) && cmd.NextInt( out y ) && cmd.NextInt( out z ) ) {

                    if( x <= -1024 || x >= 1024 || y <= -1024 || y >= 1024 || z <= -1024 || z >= 1024 ) {
                        player.Message( "Coordinates are outside the valid range!" );

                    } else {
                        player.TeleportTo( new Position {
                            X = (short)(x * 32 + 16),
                            Y = (short)(y * 32 + 16),
                            Z = (short)(z * 32 + 16),
                            R = player.Position.R,
                            L = player.Position.L
                        } );
                    }
                } else {
                    CdTeleport.PrintUsage( player );
                }

            } else {
                if( name == "-" ) {
                    if( player.LastUsedPlayerName != null ) {
                        name = player.LastUsedPlayerName;
                    } else {
                        player.Message( "Cannot repeat player name: you haven't used any names yet." );
                        return;
                    }
                }
                Player[] matches = Server.FindPlayers( player, name, false, true, true );
                if( matches.Length == 1 ) {
                    Player target = matches[0];
                    World targetWorld = target.World;
                    if( targetWorld == null ) PlayerOpException.ThrowNoWorld( target );

                    if( targetWorld == player.World ) {
                        player.TeleportTo( target.Position );

                    } else {
                        switch( targetWorld.AccessSecurity.CheckDetailed( player.Info ) ) {
                            case SecurityCheckResult.Allowed:
                            case SecurityCheckResult.WhiteListed:
                                if( targetWorld.IsFull ) {
                                    player.Message( "Cannot teleport to {0}&S because world {1}&S is full.",
                                                    target.ClassyName,
                                                    targetWorld.ClassyName );
                                    return;
                                }
                                player.StopSpectating();
                                player.JoinWorld( targetWorld, WorldChangeReason.Tp, target.Position );
                                break;
                            case SecurityCheckResult.BlackListed:
                                player.Message( "Cannot teleport to {0}&S because you are blacklisted on world {1}",
                                                target.ClassyName,
                                                targetWorld.ClassyName );
                                break;
                            case SecurityCheckResult.RankTooLow:
                                player.Message( "Cannot teleport to {0}&S because world {1}&S requires {2}+&S to join.",
                                                target.ClassyName,
                                                targetWorld.ClassyName,
                                                targetWorld.AccessSecurity.MinRank.ClassyName );
                                break;
                        }
                    }

                } else if( matches.Length > 1 ) {
                    player.MessageManyMatches( "player", matches );

                } else {
                    player.MessageNoPlayer( name );
                }
            }
        }
Exemplo n.º 7
0
        static void RankHandler( Player player, CommandReader cmd ) {
            string name = cmd.Next();
            string newRankName = cmd.Next();

            // Check arguments
            if( name == null || newRankName == null ) {
                CdRank.PrintUsage( player );
                player.Message( "See &H/Ranks&S for list of ranks." );
                return;
            }

            // Parse rank name
            Rank newRank = RankManager.FindRank( newRankName );
            if( newRank == null ) {
                player.MessageNoRank( newRankName );
                return;
            }

            if( name == "-" ) {
                if( player.LastUsedPlayerName != null ) {
                    name = player.LastUsedPlayerName;
                } else {
                    player.Message( "Cannot repeat player name: you haven't used any names yet." );
                    return;
                }
            }
            PlayerInfo targetInfo;

            // Find player by name
            if( name.StartsWith( "!" ) ) {
                name = name.Substring( 1 );
                Player target = Server.FindPlayerExact( player, name, false );
                if( target == null ) {
                    player.MessageNoPlayer( name );
                    return;
                }
                targetInfo = target.Info;
            } else {
                targetInfo = PlayerDB.FindPlayerInfoExact( name );
            }

            // Handle non-existent players
            if( targetInfo == null ) {
                if( !player.Can( Permission.EditPlayerDB ) ) {
                    player.MessageNoPlayer( name );
                    return;
                }
                if( !Player.IsValidName( name ) ) {
                    player.MessageInvalidPlayerName( name );
                    CdRank.PrintUsage( player );
                    return;
                }
                if( cmd.IsConfirmed ) {
                    if( newRank > RankManager.DefaultRank ) {
                        targetInfo = PlayerDB.AddFakeEntry( name, RankChangeType.Promoted );
                    } else {
                        targetInfo = PlayerDB.AddFakeEntry( name, RankChangeType.Demoted );
                    }
                } else {
                    Logger.Log( LogType.UserActivity,
                                "Rank: Asked {0} to confirm adding unrecognized name \"{1}\" to the database.",
                                player.Name, name );
                    player.Confirm( cmd,
                                    "Warning: Player \"{0}\" is not in the database (possible typo). Type the full name or",
                                    name );
                    return;
                }
            }

            try {
                player.LastUsedPlayerName = targetInfo.Name;
                targetInfo.ChangeRank( player, newRank, cmd.NextAll(), true, true, false );
            } catch( PlayerOpException ex ) {
                player.Message( ex.MessageColored );
            }
        }
Exemplo n.º 8
0
        internal static void RealmBuild(Player player, Command cmd, string worldName, string name, string NameIfRankIsName)
        {
            // Print information about the current realm
            if (worldName == null)
            {
                if (player.World == null)
                {
                    player.Message("When calling /wbuild from console, you must specify a realm name.");
                }
                else
                {
                    player.Message(player.World.BuildSecurity.GetDescription(player.World, "realm", "modified"));
                }
                return;
            }

            // Find a realm by name
            World realm = WorldManager.FindWorldOrPrintMatches(player, worldName);

            if (realm == null)
            {
                return;
            }


            if (name == null)
            {
                player.Message(realm.BuildSecurity.GetDescription(realm, "realm", "modified"));
                return;
            }

            bool changesWereMade = false;

            do
            {
                if (name.Length < 2)
                {
                    continue;
                }
                // Whitelisting individuals
                if (name.StartsWith("+"))
                {
                    PlayerInfo info;
                    if (!PlayerDB.FindPlayerInfo(name.Substring(1), out info))
                    {
                        player.Message("More than one player found matching \"{0}\"", name.Substring(1));
                        continue;
                    }
                    else if (info == null)
                    {
                        player.MessageNoPlayer(name.Substring(1));
                        continue;
                    }



                    if (realm.BuildSecurity.CheckDetailed(info) == SecurityCheckResult.Allowed)
                    {
                        player.Message("{0}&S is already allowed to build in {1}&S (by rank)",
                                       info.ClassyName, realm.ClassyName);
                        continue;
                    }

                    Player target = info.PlayerObject;
                    if (target == player)
                    {
                        target = null;                   // to avoid duplicate messages
                    }
                    switch (realm.BuildSecurity.Include(info))
                    {
                    case PermissionOverride.Deny:
                        if (realm.BuildSecurity.Check(info))
                        {
                            player.Message("{0}&S is no longer barred from building in {1}",
                                           info.ClassyName, realm.ClassyName);
                            if (target != null)
                            {
                                target.Message("You can now build in realm {0}&S (removed from blacklist by {1}&S).",
                                               realm.ClassyName, player.ClassyName);
                            }
                        }
                        else
                        {
                            player.Message("{0}&S was removed from the build blacklist of {1}&S. " +
                                           "Player is still NOT allowed to build (by rank).",
                                           info.ClassyName, realm.ClassyName);
                            if (target != null)
                            {
                                target.Message("You were removed from the build blacklist of realm {0}&S by {1}&S. " +
                                               "You are still NOT allowed to build (by rank).",
                                               player.ClassyName, realm.ClassyName);
                            }
                        }
                        Logger.Log(LogType.UserActivity, "{0} removed {1} from the build blacklist of {2}",
                                   player.Name, info.Name, realm.Name);
                        changesWereMade = true;
                        break;

                    case PermissionOverride.None:
                        player.Message("{0}&S is now allowed to build in {1}",
                                       info.ClassyName, realm.ClassyName);
                        if (target != null)
                        {
                            target.Message("You can now build in realm {0}&S (whitelisted by {1}&S).",
                                           realm.ClassyName, player.ClassyName);
                        }
                        Logger.Log(LogType.UserActivity, "{0} added {1} to the build whitelist on realm {2}",
                                   player.Name, info.Name, realm.Name);
                        break;

                    case PermissionOverride.Allow:
                        player.Message("{0}&S is already on the build whitelist of {1}",
                                       info.ClassyName, realm.ClassyName);
                        break;
                    }

                    // Blacklisting individuals
                }
                else if (name.StartsWith("-"))
                {
                    PlayerInfo info;
                    if (!PlayerDB.FindPlayerInfo(name.Substring(1), out info))
                    {
                        player.Message("More than one player found matching \"{0}\"", name.Substring(1));
                        continue;
                    }
                    else if (info == null)
                    {
                        player.MessageNoPlayer(name.Substring(1));
                        continue;
                    }

                    if (realm.BuildSecurity.CheckDetailed(info) == SecurityCheckResult.RankTooHigh ||
                        realm.BuildSecurity.CheckDetailed(info) == SecurityCheckResult.RankTooLow)
                    {
                        player.Message("{0}&S is already barred from building in {1}&S (by rank)",
                                       info.ClassyName, realm.ClassyName);
                        continue;
                    }

                    Player target = info.PlayerObject;
                    if (target == player)
                    {
                        target = null;                   // to avoid duplicate messages
                    }
                    switch (realm.BuildSecurity.Exclude(info))
                    {
                    case PermissionOverride.Deny:
                        player.Message("{0}&S is already on build blacklist of {1}",
                                       info.ClassyName, realm.ClassyName);
                        break;

                    case PermissionOverride.None:
                        player.Message("{0}&S is now barred from building in {1}",
                                       info.ClassyName, realm.ClassyName);
                        if (target != null)
                        {
                            target.Message("&WYou were barred by {0}&W from building in realm {1}",
                                           player.ClassyName, realm.ClassyName);
                        }
                        Logger.Log(LogType.UserActivity, "{0} added {1} to the build blacklist on realm {2}",
                                   player.Name, info.Name, realm.Name);
                        changesWereMade = true;
                        break;

                    case PermissionOverride.Allow:
                        if (realm.BuildSecurity.Check(info))
                        {
                            player.Message("{0}&S is no longer on the build whitelist of {1}&S. " +
                                           "Player is still allowed to build (by rank).",
                                           info.ClassyName, realm.ClassyName);
                            if (target != null)
                            {
                                target.Message("You were removed from the build whitelist of realm {0}&S by {1}&S. " +
                                               "You are still allowed to build (by rank).",
                                               player.ClassyName, realm.ClassyName);
                            }
                        }
                        else
                        {
                            player.Message("{0}&S is no longer allowed to build in {1}",
                                           info.ClassyName, realm.ClassyName);
                            if (target != null)
                            {
                                target.Message("&WYou can no longer build in realm {0}&W (removed from whitelist by {1}&W).",
                                               realm.ClassyName, player.ClassyName);
                            }
                        }
                        Logger.Log(LogType.UserActivity, "{0} removed {1} from the build whitelist on realm {2}",
                                   player.Name, info.Name, realm.Name);
                        changesWereMade = true;
                        break;
                    }

                    // Setting minimum rank
                }
                else
                {
                    Rank rank = RankManager.FindRank(name);
                    if (rank == null)
                    {
                        player.MessageNoRank(name);
                    }
                    else if (!player.Info.Rank.AllowSecurityCircumvention &&
                             realm.BuildSecurity.MinRank > rank &&
                             realm.BuildSecurity.MinRank > player.Info.Rank)
                    {
                        player.Message("&WYou must be ranked {0}&W+ to lower build restrictions for realm {1}",
                                       realm.BuildSecurity.MinRank.ClassyName, realm.ClassyName);
                    }
                    else
                    {
                        // list players who are redundantly blacklisted
                        var          exceptionList    = realm.BuildSecurity.ExceptionList;
                        PlayerInfo[] noLongerExcluded = exceptionList.Excluded.Where(excludedPlayer => excludedPlayer.Rank < rank).ToArray();
                        if (noLongerExcluded.Length > 0)
                        {
                            player.Message("Following players no longer need to be blacklisted on realm {0}&S: {1}",
                                           realm.ClassyName,
                                           noLongerExcluded.JoinToClassyString());
                        }

                        // list players who are redundantly whitelisted
                        PlayerInfo[] noLongerIncluded = exceptionList.Included.Where(includedPlayer => includedPlayer.Rank >= rank).ToArray();
                        if (noLongerIncluded.Length > 0)
                        {
                            player.Message("Following players no longer need to be whitelisted on realm {0}&S: {1}",
                                           realm.ClassyName,
                                           noLongerIncluded.JoinToClassyString());
                        }

                        // apply changes
                        realm.BuildSecurity.MinRank = rank;
                        changesWereMade             = true;
                        if (realm.BuildSecurity.MinRank == RankManager.LowestRank)
                        {
                            Server.Message("{0}&S allowed anyone to build on realm {1}",
                                           player.ClassyName, realm.ClassyName);
                        }
                        else
                        {
                            Server.Message("{0}&S allowed only {1}+&S to build in realm {2}",
                                           player.ClassyName, realm.BuildSecurity.MinRank.ClassyName, realm.ClassyName);
                        }
                        Logger.Log(LogType.UserActivity, "{0} set build rank for realm {1} to {2}+",
                                   player.Name, realm.Name, realm.BuildSecurity.MinRank.Name);
                    }
                }
            } while ((name = cmd.Next()) != null);

            if (changesWereMade)
            {
                WorldManager.SaveWorldList();
            }
        }
Exemplo n.º 9
0
        public static void RankHandler( Player player, Command cmd )
        {
            string name = cmd.Next();
            string newRankName = cmd.Next();

            // Check arguments
            if( name == null || newRankName == null ) {
                CdRank.PrintUsage( player );
                player.Message( "See &H/Ranks&S for list of ranks." );
                return;
            }

            // Parse rank name
            Rank newRank = RankManager.FindRank( newRankName );
            if( newRank == null ) {
                player.MessageNoRank( newRankName );
                return;
            }

            // Parse player name
            if( name == "-" ) {
                if( player.LastUsedPlayerName != null ) {
                    name = player.LastUsedPlayerName;
                } else {
                    player.Message( "Cannot repeat player name: you haven't used any names yet." );
                    return;
                }
            }
            PlayerInfo targetInfo = PlayerDB.FindPlayerInfoExact( name );

            if( targetInfo == null ) {
                if( !player.Can( Permission.EditPlayerDB ) ) {
                    player.MessageNoPlayer( name );
                    return;
                }
                if( !Player.IsValidName( name ) ) {
                    player.MessageInvalidPlayerName( name );
                    CdRank.PrintUsage( player );
                    return;
                }
                if( cmd.IsConfirmed ) {
                    if( newRank > RankManager.DefaultRank ) {
                        targetInfo = PlayerDB.AddFakeEntry( name, RankChangeType.Promoted );
                    } else {
                        targetInfo = PlayerDB.AddFakeEntry( name, RankChangeType.Demoted );
                    }
                } else {
                    player.Confirm( cmd,
                                    "Warning: Player \"{0}\" is not in the database (possible typo). Type the full name or",
                                    name );
                    return;
                }
            }

            try {
                player.LastUsedPlayerName = targetInfo.Name;

                //reset temprank values
                if (targetInfo.isTempRanked)
                {
                    targetInfo.isTempRanked = false;
                    targetInfo.tempRankTime = TimeSpan.FromSeconds(0);
                }
                targetInfo.ChangeRank( player, newRank, cmd.NextAll(), true, true, false );
            } catch( PlayerOpException ex ) {
                player.Message( ex.MessageColored );
            }
        }
Exemplo n.º 10
0
 internal static void Give(Player player, Command cmd)
 {
     string targetName = cmd.Next();
     if (targetName == null)
     {
         player.Message("&WPlease insert a playername");
         return;
     }
     Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);
     if (target == null)
     {
         player.MessageNoPlayer(targetName);
         return;
     }
     if (target == player)
     {
         player.Message("&WYou cannot give yourself something.");
         return;
     }
     string item = cmd.Next();
     if (item == null)
     {
         player.Message("&WPlease insert an item.");
         return;
     }
     string itemnumber = cmd.Next();
     if (itemnumber == null)
     {
         player.Message("&WPlease insert the item number.");
         return;
     }
     else
     {
         Server.Players.CanSee(target).Message("{0} &egave {1} &e{2} {3}.", player.ClassyName, target.ClassyName, itemnumber, item);
     }
 }
Exemplo n.º 11
0
        static void TPHandler2(Player player, Command cmd)
        {
            string name = cmd.Next();
            if (name == null)
            {

                return;
            }

            if (cmd.Next() != null)
            {
                cmd.Rewind();
                int x, y, z;
                if (cmd.NextInt(out x) && cmd.NextInt(out y) && cmd.NextInt(out z))
                {

                    if (x <= -1024 || x >= 1024 || y <= -1024 || y >= 1024 || z <= -1024 || z >= 1024)
                    {
                        player.Message("Coordinates are outside the valid range!");

                    }
                    else
                    {
                        player.TeleportTo(new Position
                        {
                            X = (short)(x * 32 + 16),
                            Y = (short)(y * 32 + 16),
                            Z = (short)(z * 32 + 16),
                            R = player.Position.R,
                            L = player.Position.L
                        });
                    }
                }
                else
                {
                    return;
                }

            }
            else
            {
                Player[] matches = Server.FindPlayers(player, name, true);
                if (matches.Length == 1)
                {
                    Player target = matches[0];
                    World targetWorld = target.World;
                    if (targetWorld == null) PlayerOpException.ThrowNoWorld(target);

                    if (targetWorld == player.World)
                    {
                        player.TeleportTo(target.Position);

                    }
                    else
                    {
                        switch (targetWorld.AccessSecurity.CheckDetailed(player.Info))
                        {
                            case SecurityCheckResult.Allowed:
                            case SecurityCheckResult.WhiteListed:
                                if (targetWorld.IsFull)
                                {
                                    player.Message("Cannot teleport to {0}&S because world {1}&S is full.",
                                                    target.ClassyName,
                                                    targetWorld.ClassyName);
                                    return;
                                }
                                player.StopSpectating();
                                player.JoinWorld(targetWorld, WorldChangeReason.Tp, target.Position);
                                break;
                            case SecurityCheckResult.BlackListed:
                                player.Message("Cannot teleport to {0}&S because you are blacklisted on world {1}",
                                                target.ClassyName,
                                                targetWorld.ClassyName);
                                break;
                            case SecurityCheckResult.RankTooLow:
                                player.Message("Cannot teleport to {0}&S because world {1}&S requires {2}+&S to join.",
                                                target.ClassyName,
                                                targetWorld.ClassyName,
                                                targetWorld.AccessSecurity.MinRank.ClassyName);
                                break;
                            // TODO: case PermissionType.RankTooHigh:
                        }
                    }

                }
                else if (matches.Length > 1)
                {
                    player.MessageManyMatches("player", matches);

                }
                else
                {
                    // Try to guess if player typed "/TP" instead of "/Join"
                    World[] worlds = WorldManager.FindWorlds(player, name);

                    if (worlds.Length == 1)
                    {
                        player.LastUsedWorldName = worlds[0].Name;
                        player.StopSpectating();
                        player.ParseMessage("/Join " + worlds[0].Name, false);
                    }
                    else
                    {
                        player.MessageNoPlayer(name);
                    }
                }
            }
        }
Exemplo n.º 12
0
 internal static void High5Handler(Player player, Command cmd)
 {
     string targetName = cmd.Next();
     if (targetName == null){
         cdHigh5.PrintUsage(player);
         return;
     }
     Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);
     if (target == null){
         player.MessageNoPlayer(targetName);
         return;
     }
     if (target == player) {
         player.Message("You cannot high five yourself.");
         return;
     }
     Server.Players.CanSee(target).Except(target).Message("{0}&S was just &chigh fived &Sby {1}&S", target.ClassyName, player.ClassyName);
     IRC.IRCAnnounceCustom(String.Format("{0}&S was just &chigh fived &Sby {1}&S", target.ClassyName, player.ClassyName));
     target.Message("{0}&S high fived you.", player.ClassyName);
 }
Exemplo n.º 13
0
        static void SetSpawnHandler(Player player, Command cmd)
        {
            string playerName = cmd.Next();
            if (playerName == null)
            {
                player.World.Map.Spawn = player.Position;
                player.TeleportTo(player.World.Map.Spawn);
                player.Send(PacketWriter.MakeAddEntity(255, player.ListName, player.Position));
                player.Message("New spawn point saved.");
                Logger.Log(LogType.UserActivity, "{0} changed the spawned point.",
                            player.Name);

            }
            else if (player.Can(Permission.Bring))
            {
                Player[] infos = player.World.FindPlayers(player, playerName);
                if (infos.Length == 1)
                {
                    Player target = infos[0];
                    if (player.Can(Permission.Bring, target.Info.Rank))
                    {
                        target.Send(PacketWriter.MakeAddEntity(255, target.ListName, player.Position));
                    }
                    else
                    {
                        player.Message("You can only set spawn of players ranked {0}&S or lower.",
                                        player.Info.Rank.GetLimit(Permission.Bring).ClassyName);
                        player.Message("{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName);
                    }

                }
                else if (infos.Length > 0)
                {
                    player.MessageManyMatches("player", infos);

                }
                else
                {
                    infos = Server.FindPlayers(player, playerName, true);
                    if (infos.Length > 0)
                    {
                        player.Message("You can only set spawn of players on the same world as you.");
                    }
                    else
                    {
                        player.MessageNoPlayer(playerName);
                    }
                }
            }
            else
            {
                player.MessageNoAccess(CdRealm);
            }
        }
Exemplo n.º 14
0
        static void Tempban(Player player, Command cmd)
        {
            string targetName = cmd.Next();
            string timeString = cmd.Next();
            TimeSpan duration;

            try
            {
                // validate command parameters
                if (targetName == null || !Player.IsValidName(targetName) ||
                    timeString == null || !timeString.TryParseMiniTimespan(out duration) ||
                    duration <= TimeSpan.Zero)
                {
                    player.Message("Invalid input");
                    return;
                }
            }
            catch (OverflowException)
            {
                player.Message("TempBan: Given duration is too long.");
                return;
            }

            // find the target
            Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);

            if (target == null)
            {
                player.MessageNoPlayer(targetName);
                return;
            };

            if (target == player)
            {
                player.Message("Trying to T-Ban yourself? Fail!");
                return;
            }

            // check permissions
            if (!player.Can(Permission.BanIP, target.Info.Rank))
            {
                player.Message("You can only Temp-Ban players ranked {0}&S or lower.",
                                player.Info.Rank.GetLimit(Permission.BanIP).ClassyName);
                player.Message("{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName);
                return;
            }

            // do the banning
            if (target.Info.Tempban(player.Name, duration))
            {
                PlayerInfo targets = PlayerDB.FindPlayerInfoOrPrintMatches(player, targetName);
                if (targets == null) return;
                string reason = cmd.NextAll();
                try
                {
                    Player targetPlayer = targets.PlayerObject;
                    targets.Ban(player, "You were Banned for " + timeString + " Seconds", true, true);

                }
                catch (PlayerOpException ex)
                {
                    player.Message(ex.MessageColored);

                }

                Scheduler.NewTask(t => target.Info.Unban(player, "Tempban Expired", true, true)).RunOnce(duration);
                Server.Message(target,
                                "&SPlayer {0}&S was Banned by {1}&S for {2}",
                                target.ClassyName, player.ClassyName, duration.ToMiniString());
                Logger.Log(LogType.UserActivity, "Player {0} was Banned by {1} for {2}",
                            target.Name, player.Name, duration.ToMiniString());
            }
            else
            {
                player.Message("Player {0}&S is already Banned by {1}&S for {2:0} more.",
                                target.ClassyName,
                                target.Info.MutedBy,
                                target.Info.MutedUntil.Subtract(DateTime.UtcNow).ToMiniString());
            }
        }
Exemplo n.º 15
0
 private static void SetClickHandler(Player player, Command cmd)
 {
     string targetName = cmd.Next();
     if (String.IsNullOrEmpty(targetName))
     {
         CdSetClickDistance.PrintUsage(player);
         return;
     }
     Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);
     if (target == null)
     {
         player.MessageNoPlayer(targetName);
         return;
     }
     if (!target.ClassiCube)
     {
         player.Message("Click distance can only be changed for people playing on ClassiCube");
         return;
     }
     string number = cmd.Next();
     if (number == "normal")
     {
         target.Send(PacketWriter.MakeSetClickDistance(160));
         player.Message("Player {0}&s's click distance was set to normal.", target.ClassyName);
         target.hasCustomClickDistance = false;
         return;
     }
     int distance;
     if (String.IsNullOrEmpty(number) || !Int32.TryParse(number, out distance))
     {
         CdSetClickDistance.PrintUsage(player);
         return;
     }
     if (distance > 20 || distance < 1)
     {
         player.Message("Accepted values are between 1 and 20!");
         return;
     }
     int adjustedDistance = (32 * distance);
     target.Send(PacketWriter.MakeSetClickDistance(adjustedDistance));
     target.hasCustomClickDistance = true;
     player.Message("Player {0}&s's click distance was set to {1} blocks.", target.ClassyName, distance);
 }
Exemplo n.º 16
0
 static void BrofistHandler(Player player, Command cmd)
 {
     string targetName = cmd.Next();
     if (targetName == null)
     {
         player.Message("Enter a playername.");
         return;
     }
     Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);
     if (target == null)
     {
         player.MessageNoPlayer(targetName);
         return;
     }
     if (target == player)
     {
         Server.Players.CanSee(target).Except(target).Message("{1}&S just tried to &8Brofist &Sthemsleves...", target.ClassyName, player.ClassyName);
         IRC.PlayerSomethingMessage(player, "brofisted", target, null);
         player.Message("&SYou just tried to &8Brofist &Syourself... That's sad...");
         return;
     }
     Server.Players.CanSee(target).Except(target).Message("{1}&S gave {0}&S a &8Brofist&S.", target.ClassyName, player.ClassyName);
     IRC.PlayerSomethingMessage(player, "brofisted", target, null);
     target.Message("{0}&S's fist met yours for a &8Brofist&S.", player.ClassyName);
 }
Exemplo n.º 17
0
        static void Tempban(Player player, Command cmd)
        {
            string targetName = cmd.Next();
            string timeString = cmd.Next();
            TimeSpan duration;
            try{
                if (String.IsNullOrEmpty(targetName) || String.IsNullOrEmpty(timeString) ||
                !timeString.TryParseMiniTimespan(out duration) || duration <= TimeSpan.Zero)
                {
                    CdTempBan.PrintUsage(player);
                    return;
                }
            }catch (OverflowException){
                player.Message("TempBan: Given duration is too long.");
                return;
            }

            // find the target
            PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches(player, targetName);

            if (target == null){
                player.MessageNoPlayer(targetName);
                return;
            };

            if (target.Name == player.Name){
                player.Message("Trying to T-Ban yourself? Fail!");
                return;
            }

            // check permissions
            if (!player.Can(Permission.BanIP, target.Rank)){
                player.Message("You can only Temp-Ban players ranked {0}&S or lower.",
                                player.Info.Rank.GetLimit(Permission.BanIP).ClassyName);
                player.Message("{0}&S is ranked {1}", target.ClassyName, target.Rank.ClassyName);
                return;
            }

            // do the banning
            if (target.Tempban(player.Name, duration)){
                string reason = cmd.NextAll();
                try{
                    Player targetPlayer = target.PlayerObject;
                    target.Ban(player, "You were Banned for " + timeString, false, true);
                    Server.TempBans.Add(targetPlayer);
                }
                catch (PlayerOpException ex){
                    player.Message(ex.MessageColored);
                }
                Scheduler.NewTask(t => Untempban(player, target)).RunOnce(duration);
                Server.Message("&SPlayer {0}&S was Banned by {1}&S for {2}",
                                target.ClassyName, player.ClassyName, duration.ToMiniString());
                if (reason.Length > 0) Server.Message("&Wreason: {0}", reason);
                Logger.Log(LogType.UserActivity, "Player {0} was Banned by {1} for {2}",
                            target.Name, player.Name, duration.ToMiniString());
            }else{
                player.Message("Player {0}&S is already Banned by {1}&S for {2:0} more.",
                                target.ClassyName,
                                target.BannedBy,
                                target.BannedUntil.Subtract(DateTime.UtcNow).ToMiniString());
            }
        }
Exemplo n.º 18
0
        public static PlayerInfo FindPlayerInfoOrPrintMatches([NotNull] Player player, [NotNull] string partialName)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (partialName == null)
            {
                throw new ArgumentNullException("partialName");
            }
            CheckIfLoaded();

            // If name starts with '!', return matches for online players only
            if (partialName.Length > 1 && partialName[0] == '!')
            {
                partialName = partialName.Substring(1);
                Player targetPlayer = Server.FindPlayerOrPrintMatches(player, partialName, false, true);
                if (targetPlayer != null)
                {
                    return(targetPlayer.Info);
                }
                else
                {
                    player.Message("No online players found matching \"{0}\"", partialName);
                    return(null);
                }
            }

            // Repeat last-used player name
            if (partialName == "-")
            {
                if (player.LastUsedPlayerName != null)
                {
                    partialName = player.LastUsedPlayerName;
                }
                else
                {
                    player.Message("Cannot repeat player name: you haven't used any names yet.");
                    return(null);
                }
            }

            // Make sure player name is valid
            if (!Player.ContainsValidCharacters(partialName))
            {
                player.MessageInvalidPlayerName(partialName);
                return(null);
            }

            // Search for exact matches first
            PlayerInfo target = FindPlayerInfoExact(partialName);

            // If no exact match was found, look for partial matches
            if (target == null)
            {
                PlayerInfo[] targets = FindPlayers(partialName);
                if (targets.Length == 0)
                {
                    // No matches
                    player.MessageNoPlayer(partialName);
                    return(null);
                }
                else if (targets.Length > 1)
                {
                    // More than one match
                    Array.Sort(targets, new PlayerInfoComparer(player));
                    player.MessageManyMatches("player", targets.Take(25).ToArray());
                    return(null);
                } // else: one match!
                target = targets[0];
            }

            // If a single name has been found, set it as LastUsedPlayerName
            player.LastUsedPlayerName = target.Name;
            return(target);
        }
Exemplo n.º 19
0
        internal static void RealmAccess(Player player, Command cmd, string worldName, string name)
        {
            // Print information about the current realm
            if (worldName == null)
            {
                if (player.World == null)
                {
                    player.Message("Error.");
                }
                else
                {
                    player.Message(player.World.AccessSecurity.GetDescription(player.World, "realm", "accessed"));
                }
                return;
            }

            // Find a realm by name
            World realm = WorldManager.FindWorldOrPrintMatches(player, worldName);

            if (realm == null)
            {
                return;
            }



            if (name == null)
            {
                player.Message(realm.AccessSecurity.GetDescription(realm, "realm", "accessed"));
                return;
            }
            if (realm == WorldManager.MainWorld)
            {
                player.Message("The main realm cannot have access restrictions.");
                return;
            }

            bool changesWereMade = false;

            do
            {
                if (name.Length < 2)
                {
                    continue;
                }
                // Whitelisting individuals
                if (name.StartsWith("+"))
                {
                    PlayerInfo info;
                    if (!PlayerDB.FindPlayerInfo(name.Substring(1), out info))
                    {
                        player.Message("More than one player found matching \"{0}\"", name.Substring(1));
                        continue;
                    }
                    else if (info == null)
                    {
                        player.MessageNoPlayer(name.Substring(1));
                        continue;
                    }

                    // prevent players from whitelisting themselves to bypass protection


                    if (realm.AccessSecurity.CheckDetailed(info) == SecurityCheckResult.Allowed)
                    {
                        player.Message("{0}&S is already allowed to access {1}&S (by rank)",
                                       info.ClassyName, realm.ClassyName);
                        continue;
                    }

                    Player target = info.PlayerObject;
                    if (target == player)
                    {
                        target = null;                   // to avoid duplicate messages
                    }
                    switch (realm.AccessSecurity.Include(info))
                    {
                    case PermissionOverride.Deny:
                        if (realm.AccessSecurity.Check(info))
                        {
                            player.Message("{0}&S is unbanned from Realm {1}",
                                           info.ClassyName, realm.ClassyName);
                            if (target != null)
                            {
                                target.Message("You are now unbanned from Realm {0}&S (removed from blacklist by {1}&S).",
                                               realm.ClassyName, player.ClassyName);
                            }
                        }
                        else
                        {
                            player.Message("{0}&S was unbanned from Realm {1}&S. " +
                                           "Player is still NOT allowed to join (by rank).",
                                           info.ClassyName, realm.ClassyName);
                            if (target != null)
                            {
                                target.Message("You were Unbanned from Realm {0}&S by {1}&S. " +
                                               "You are still NOT allowed to join (by rank).",
                                               player.ClassyName, realm.ClassyName);
                            }
                        }
                        Logger.Log(LogType.UserActivity, "{0} removed {1} from the access blacklist of {2}",
                                   player.Name, info.Name, realm.Name);
                        changesWereMade = true;
                        break;

                    case PermissionOverride.None:
                        player.Message("{0}&S is now allowed to access {1}",
                                       info.ClassyName, realm.ClassyName);
                        if (target != null)
                        {
                            target.Message("You can now access realm {0}&S (whitelisted by {1}&S).",
                                           realm.ClassyName, player.ClassyName);
                        }
                        Logger.Log(LogType.UserActivity, "{0} added {1} to the access whitelist on realm {2}",
                                   player.Name, info.Name, realm.Name);
                        changesWereMade = true;
                        break;

                    case PermissionOverride.Allow:
                        player.Message("{0}&S is already on the access whitelist of {1}",
                                       info.ClassyName, realm.ClassyName);
                        break;
                    }

                    // Blacklisting individuals
                }
                else if (name.StartsWith("-"))
                {
                    PlayerInfo info;
                    if (!PlayerDB.FindPlayerInfo(name.Substring(1), out info))
                    {
                        player.Message("More than one player found matching \"{0}\"", name.Substring(1));
                        continue;
                    }
                    else if (info == null)
                    {
                        player.MessageNoPlayer(name.Substring(1));
                        continue;
                    }

                    if (realm.AccessSecurity.CheckDetailed(info) == SecurityCheckResult.RankTooHigh ||
                        realm.AccessSecurity.CheckDetailed(info) == SecurityCheckResult.RankTooLow)
                    {
                        player.Message("{0}&S is already barred from accessing {1}&S (by rank)",
                                       info.ClassyName, realm.ClassyName);
                        continue;
                    }

                    Player target = info.PlayerObject;
                    if (target == player)
                    {
                        target = null;                   // to avoid duplicate messages
                    }
                    switch (realm.AccessSecurity.Exclude(info))
                    {
                    case PermissionOverride.Deny:
                        player.Message("{0}&S is already banned from Realm {1}",
                                       info.ClassyName, realm.ClassyName);
                        break;

                    case PermissionOverride.None:
                        player.Message("{0}&S is now banned from accessing {1}",
                                       info.ClassyName, realm.ClassyName);
                        if (target != null)
                        {
                            target.Message("&WYou were banned by {0}&W from accessing realm {1}",
                                           player.ClassyName, realm.ClassyName);
                        }
                        Logger.Log(LogType.UserActivity, "{0} added {1} to the access blacklist on realm {2}",
                                   player.Name, info.Name, realm.Name);
                        changesWereMade = true;
                        break;

                    case PermissionOverride.Allow:
                        if (realm.AccessSecurity.Check(info))
                        {
                            player.Message("{0}&S is no longer on the access whitelist of {1}&S. " +
                                           "Player is still allowed to join (by rank).",
                                           info.ClassyName, realm.ClassyName);
                            if (target != null)
                            {
                                target.Message("You were banned from Realm {0}&S by {1}&S. " +
                                               "You are still allowed to join (by rank).",
                                               player.ClassyName, realm.ClassyName);
                            }
                        }
                        else
                        {
                            player.Message("{0}&S is no longer allowed to access {1}",
                                           info.ClassyName, realm.ClassyName);
                            if (target != null)
                            {
                                target.Message("&WYou were banned from Realm {0}&W (Banned by {1}&W).",
                                               realm.ClassyName, player.ClassyName);
                            }
                        }
                        Logger.Log(LogType.UserActivity, "{0} removed {1} from the access whitelist on realm {2}",
                                   player.Name, info.Name, realm.Name);
                        changesWereMade = true;
                        break;
                    }

                    // Setting minimum rank
                }
                else
                {
                    Rank rank = RankManager.FindRank(name);
                    if (rank == null)
                    {
                        player.MessageNoRank(name);
                    }

                    else
                    {
                        // list players who are redundantly blacklisted
                        var          exceptionList    = realm.AccessSecurity.ExceptionList;
                        PlayerInfo[] noLongerExcluded = exceptionList.Excluded.Where(excludedPlayer => excludedPlayer.Rank < rank).ToArray();
                        if (noLongerExcluded.Length > 0)
                        {
                            player.Message("Following players no longer need to be blacklisted to be barred from {0}&S: {1}",
                                           realm.ClassyName,
                                           noLongerExcluded.JoinToClassyString());
                        }

                        // list players who are redundantly whitelisted
                        PlayerInfo[] noLongerIncluded = exceptionList.Included.Where(includedPlayer => includedPlayer.Rank >= rank).ToArray();
                        if (noLongerIncluded.Length > 0)
                        {
                            player.Message("Following players no longer need to be whitelisted to access {0}&S: {1}",
                                           realm.ClassyName,
                                           noLongerIncluded.JoinToClassyString());
                        }

                        // apply changes
                        realm.AccessSecurity.MinRank = rank;
                        changesWereMade = true;
                        if (realm.AccessSecurity.MinRank == RankManager.LowestRank)
                        {
                            Server.Message("{0}&S made the realm {1}&S accessible to everyone.",
                                           player.ClassyName, realm.ClassyName);
                        }
                        else
                        {
                            Server.Message("{0}&S made the realm {1}&S accessible only by {2}+",
                                           player.ClassyName, realm.ClassyName,
                                           realm.AccessSecurity.MinRank.ClassyName);
                        }
                        Logger.Log(LogType.UserActivity, "{0} set access rank for realm {1} to {2}+",
                                   player.Name, realm.Name, realm.AccessSecurity.MinRank.Name);
                    }
                }
            } while ((name = cmd.Next()) != null);

            if (changesWereMade)
            {
                var playersWhoCantStay = realm.Players.Where(p => !p.CanJoin(realm));
                foreach (Player p in playersWhoCantStay)
                {
                    p.Message("&WYou are no longer allowed to join realm {0}", realm.ClassyName);
                    p.JoinWorld(WorldManager.MainWorld, WorldChangeReason.PermissionChanged);
                }

                WorldManager.SaveWorldList();
            }
        }
Exemplo n.º 20
0
        internal static void RealmAccess(Player player, Command cmd, string worldName, string name)
        {
            // Print information about the current realm
            if (worldName == null)
            {
                if (player.World == null)
                {
                    player.Message("Error.");
                }
                else
                {
                    player.Message(player.World.AccessSecurity.GetDescription(player.World, "realm", "accessed"));
                }
                return;
            }

            // Find a realm by name
            World realm = WorldManager.FindWorldOrPrintMatches(player, worldName);
            if (realm == null) return;

            if (name == null)
            {
                player.Message(realm.AccessSecurity.GetDescription(realm, "realm", "accessed"));
                return;
            }
            if (realm == WorldManager.MainWorld)
            {
                player.Message("The main realm cannot have access restrictions.");
                return;
            }

            bool changesWereMade = false;
            do
            {
                if (name.Length < 2) continue;
                // Whitelisting individuals
                if (name.StartsWith("+"))
                {
                    PlayerInfo info;
                    if (!PlayerDB.FindPlayerInfo(name.Substring(1), out info))
                    {
                        player.Message("More than one player found matching \"{0}\"", name.Substring(1));
                        continue;

                    }
                    else if (info == null)
                    {
                        player.MessageNoPlayer(name.Substring(1));
                        continue;
                    }

                    // prevent players from whitelisting themselves to bypass protection

                    if (realm.AccessSecurity.CheckDetailed(info) == SecurityCheckResult.Allowed)
                    {
                        player.Message("{0}&S is already allowed to access {1}&S (by rank)",
                                        info.ClassyName, realm.ClassyName);
                        continue;
                    }

                    Player target = info.PlayerObject;
                    if (target == player) target = null; // to avoid duplicate messages

                    switch (realm.AccessSecurity.Include(info))
                    {
                        case PermissionOverride.Deny:
                            if (realm.AccessSecurity.Check(info))
                            {
                                player.Message("{0}&S is unbanned from Realm {1}",
                                                info.ClassyName, realm.ClassyName);
                                if (target != null)
                                {
                                    target.Message("You are now unbanned from Realm {0}&S (removed from blacklist by {1}&S).",
                                                    realm.ClassyName, player.ClassyName);
                                }
                            }
                            else
                            {
                                player.Message("{0}&S was unbanned from Realm {1}&S. " +
                                                "Player is still NOT allowed to join (by rank).",
                                                info.ClassyName, realm.ClassyName);
                                if (target != null)
                                {
                                    target.Message("You were Unbanned from Realm {0}&S by {1}&S. " +
                                                    "You are still NOT allowed to join (by rank).",
                                                    player.ClassyName, realm.ClassyName);
                                }
                            }
                            Logger.Log(LogType.UserActivity, "{0} removed {1} from the access blacklist of {2}",
                                        player.Name, info.Name, realm.Name);
                            changesWereMade = true;
                            break;

                        case PermissionOverride.None:
                            player.Message("{0}&S is now allowed to access {1}",
                                            info.ClassyName, realm.ClassyName);
                            if (target != null)
                            {
                                target.Message("You can now access realm {0}&S (whitelisted by {1}&S).",
                                                realm.ClassyName, player.ClassyName);
                            }
                            Logger.Log(LogType.UserActivity, "{0} added {1} to the access whitelist on realm {2}",
                                        player.Name, info.Name, realm.Name);
                            changesWereMade = true;
                            break;

                        case PermissionOverride.Allow:
                            player.Message("{0}&S is already on the access whitelist of {1}",
                                            info.ClassyName, realm.ClassyName);
                            break;
                    }

                    // Blacklisting individuals
                }
                else if (name.StartsWith("-"))
                {
                    PlayerInfo info;
                    if (!PlayerDB.FindPlayerInfo(name.Substring(1), out info))
                    {
                        player.Message("More than one player found matching \"{0}\"", name.Substring(1));
                        continue;
                    }
                    else if (info == null)
                    {
                        player.MessageNoPlayer(name.Substring(1));
                        continue;
                    }

                    if (realm.AccessSecurity.CheckDetailed(info) == SecurityCheckResult.RankTooHigh ||
                        realm.AccessSecurity.CheckDetailed(info) == SecurityCheckResult.RankTooLow)
                    {
                        player.Message("{0}&S is already barred from accessing {1}&S (by rank)",
                                        info.ClassyName, realm.ClassyName);
                        continue;
                    }

                    Player target = info.PlayerObject;
                    if (target == player) target = null; // to avoid duplicate messages

                    switch (realm.AccessSecurity.Exclude(info))
                    {
                        case PermissionOverride.Deny:
                            player.Message("{0}&S is already banned from Realm {1}",
                                            info.ClassyName, realm.ClassyName);
                            break;

                        case PermissionOverride.None:
                            player.Message("{0}&S is now banned from accessing {1}",
                                            info.ClassyName, realm.ClassyName);
                            if (target != null)
                            {
                                target.Message("&WYou were banned by {0}&W from accessing realm {1}",
                                                player.ClassyName, realm.ClassyName);
                            }
                            Logger.Log(LogType.UserActivity, "{0} added {1} to the access blacklist on realm {2}",
                                        player.Name, info.Name, realm.Name);
                            changesWereMade = true;
                            break;

                        case PermissionOverride.Allow:
                            if (realm.AccessSecurity.Check(info))
                            {
                                player.Message("{0}&S is no longer on the access whitelist of {1}&S. " +
                                                "Player is still allowed to join (by rank).",
                                                info.ClassyName, realm.ClassyName);
                                if (target != null)
                                {
                                    target.Message("You were banned from Realm {0}&S by {1}&S. " +
                                                    "You are still allowed to join (by rank).",
                                                    player.ClassyName, realm.ClassyName);
                                }
                            }
                            else
                            {
                                player.Message("{0}&S is no longer allowed to access {1}",
                                                info.ClassyName, realm.ClassyName);
                                if (target != null)
                                {
                                    target.Message("&WYou were banned from Realm {0}&W (Banned by {1}&W).",
                                                    realm.ClassyName, player.ClassyName);
                                }
                            }
                            Logger.Log(LogType.UserActivity, "{0} removed {1} from the access whitelist on realm {2}",
                                        player.Name, info.Name, realm.Name);
                            changesWereMade = true;
                            break;
                    }

                    // Setting minimum rank
                }
                else
                {
                    Rank rank = RankManager.FindRank(name);
                    if (rank == null)
                    {
                        player.MessageNoRank(name);

                    }

                    else
                    {
                        // list players who are redundantly blacklisted
                        var exceptionList = realm.AccessSecurity.ExceptionList;
                        PlayerInfo[] noLongerExcluded = exceptionList.Excluded.Where(excludedPlayer => excludedPlayer.Rank < rank).ToArray();
                        if (noLongerExcluded.Length > 0)
                        {
                            player.Message("Following players no longer need to be blacklisted to be barred from {0}&S: {1}",
                                            realm.ClassyName,
                                            noLongerExcluded.JoinToClassyString());
                        }

                        // list players who are redundantly whitelisted
                        PlayerInfo[] noLongerIncluded = exceptionList.Included.Where(includedPlayer => includedPlayer.Rank >= rank).ToArray();
                        if (noLongerIncluded.Length > 0)
                        {
                            player.Message("Following players no longer need to be whitelisted to access {0}&S: {1}",
                                            realm.ClassyName,
                                            noLongerIncluded.JoinToClassyString());
                        }

                        // apply changes
                        realm.AccessSecurity.MinRank = rank;
                        changesWereMade = true;
                        if (realm.AccessSecurity.MinRank == RankManager.LowestRank)
                        {
                            Server.Message("{0}&S made the realm {1}&S accessible to everyone.",
                                              player.ClassyName, realm.ClassyName);
                        }
                        else
                        {
                            Server.Message("{0}&S made the realm {1}&S accessible only by {2}+",
                                              player.ClassyName, realm.ClassyName,
                                              realm.AccessSecurity.MinRank.ClassyName);
                        }
                        Logger.Log(LogType.UserActivity, "{0} set access rank for realm {1} to {2}+",
                                    player.Name, realm.Name, realm.AccessSecurity.MinRank.Name);
                    }
                }
            } while ((name = cmd.Next()) != null);

            if (changesWereMade)
            {
                var playersWhoCantStay = realm.Players.Where(p => !p.CanJoin(realm));
                foreach (Player p in playersWhoCantStay)
                {
                    p.Message("&WYou are no longer allowed to join realm {0}", realm.ClassyName);
                    p.JoinWorld(WorldManager.MainWorld, WorldChangeReason.PermissionChanged);
                }

                WorldManager.SaveWorldList();
            }
        }
Exemplo n.º 21
0
 public static void UndoAllHandler(Player player, Command cmd)
 {
     string targetName = cmd.Next();
     if (targetName == null)
     {
         CdUndoAll.PrintUsage(player);
     }
     PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches(player, targetName);
     if (target == null)
     {
         player.MessageNoPlayer(targetName);
         return;
     }
     UndoPlayerHandler2(player, new Command("/undox " + target.Name + " 10000000"));
 }
Exemplo n.º 22
0
        internal static void RealmBuild(Player player, Command cmd, string worldName, string name, string NameIfRankIsName)
        {
            // Print information about the current realm
            if (worldName == null)
            {
                if (player.World == null)
                {
                    player.Message("When calling /wbuild from console, you must specify a realm name.");
                }
                else
                {
                    player.Message(player.World.BuildSecurity.GetDescription(player.World, "realm", "modified"));
                }
                return;
            }

            // Find a realm by name
            World realm = WorldManager.FindWorldOrPrintMatches(player, worldName);
            if (realm == null) return;

            if (name == null)
            {
                player.Message(realm.BuildSecurity.GetDescription(realm, "realm", "modified"));
                return;
            }

            bool changesWereMade = false;
            do
            {
                if (name.Length < 2) continue;
                // Whitelisting individuals
                if (name.StartsWith("+"))
                {
                    PlayerInfo info;
                    if (!PlayerDB.FindPlayerInfo(name.Substring(1), out info))
                    {
                        player.Message("More than one player found matching \"{0}\"", name.Substring(1));
                        continue;
                    }
                    else if (info == null)
                    {
                        player.MessageNoPlayer(name.Substring(1));
                        continue;
                    }

                    if (realm.BuildSecurity.CheckDetailed(info) == SecurityCheckResult.Allowed)
                    {
                        player.Message("{0}&S is already allowed to build in {1}&S (by rank)",
                                        info.ClassyName, realm.ClassyName);
                        continue;
                    }

                    Player target = info.PlayerObject;
                    if (target == player) target = null; // to avoid duplicate messages

                    switch (realm.BuildSecurity.Include(info))
                    {
                        case PermissionOverride.Deny:
                            if (realm.BuildSecurity.Check(info))
                            {
                                player.Message("{0}&S is no longer barred from building in {1}",
                                                info.ClassyName, realm.ClassyName);
                                if (target != null)
                                {
                                    target.Message("You can now build in realm {0}&S (removed from blacklist by {1}&S).",
                                                    realm.ClassyName, player.ClassyName);
                                }
                            }
                            else
                            {
                                player.Message("{0}&S was removed from the build blacklist of {1}&S. " +
                                                "Player is still NOT allowed to build (by rank).",
                                                info.ClassyName, realm.ClassyName);
                                if (target != null)
                                {
                                    target.Message("You were removed from the build blacklist of realm {0}&S by {1}&S. " +
                                                    "You are still NOT allowed to build (by rank).",
                                                    player.ClassyName, realm.ClassyName);
                                }
                            }
                            Logger.Log(LogType.UserActivity, "{0} removed {1} from the build blacklist of {2}",
                                        player.Name, info.Name, realm.Name);
                            changesWereMade = true;
                            break;

                        case PermissionOverride.None:
                            player.Message("{0}&S is now allowed to build in {1}",
                                            info.ClassyName, realm.ClassyName);
                            if (target != null)
                            {
                                target.Message("You can now build in realm {0}&S (whitelisted by {1}&S).",
                                                realm.ClassyName, player.ClassyName);
                            }
                            Logger.Log(LogType.UserActivity, "{0} added {1} to the build whitelist on realm {2}",
                                        player.Name, info.Name, realm.Name);
                            break;

                        case PermissionOverride.Allow:
                            player.Message("{0}&S is already on the build whitelist of {1}",
                                            info.ClassyName, realm.ClassyName);
                            break;
                    }

                    // Blacklisting individuals
                }
                else if (name.StartsWith("-"))
                {
                    PlayerInfo info;
                    if (!PlayerDB.FindPlayerInfo(name.Substring(1), out info))
                    {
                        player.Message("More than one player found matching \"{0}\"", name.Substring(1));
                        continue;
                    }
                    else if (info == null)
                    {
                        player.MessageNoPlayer(name.Substring(1));
                        continue;
                    }

                    if (realm.BuildSecurity.CheckDetailed(info) == SecurityCheckResult.RankTooHigh ||
                        realm.BuildSecurity.CheckDetailed(info) == SecurityCheckResult.RankTooLow)
                    {
                        player.Message("{0}&S is already barred from building in {1}&S (by rank)",
                                        info.ClassyName, realm.ClassyName);
                        continue;
                    }

                    Player target = info.PlayerObject;
                    if (target == player) target = null; // to avoid duplicate messages

                    switch (realm.BuildSecurity.Exclude(info))
                    {
                        case PermissionOverride.Deny:
                            player.Message("{0}&S is already on build blacklist of {1}",
                                            info.ClassyName, realm.ClassyName);
                            break;

                        case PermissionOverride.None:
                            player.Message("{0}&S is now barred from building in {1}",
                                            info.ClassyName, realm.ClassyName);
                            if (target != null)
                            {
                                target.Message("&WYou were barred by {0}&W from building in realm {1}",
                                                player.ClassyName, realm.ClassyName);
                            }
                            Logger.Log(LogType.UserActivity, "{0} added {1} to the build blacklist on realm {2}",
                                        player.Name, info.Name, realm.Name);
                            changesWereMade = true;
                            break;

                        case PermissionOverride.Allow:
                            if (realm.BuildSecurity.Check(info))
                            {
                                player.Message("{0}&S is no longer on the build whitelist of {1}&S. " +
                                                "Player is still allowed to build (by rank).",
                                                info.ClassyName, realm.ClassyName);
                                if (target != null)
                                {
                                    target.Message("You were removed from the build whitelist of realm {0}&S by {1}&S. " +
                                                    "You are still allowed to build (by rank).",
                                                    player.ClassyName, realm.ClassyName);
                                }
                            }
                            else
                            {
                                player.Message("{0}&S is no longer allowed to build in {1}",
                                                info.ClassyName, realm.ClassyName);
                                if (target != null)
                                {
                                    target.Message("&WYou can no longer build in realm {0}&W (removed from whitelist by {1}&W).",
                                                    realm.ClassyName, player.ClassyName);
                                }
                            }
                            Logger.Log(LogType.UserActivity, "{0} removed {1} from the build whitelist on realm {2}",
                                        player.Name, info.Name, realm.Name);
                            changesWereMade = true;
                            break;
                    }

                    // Setting minimum rank
                }
                else
                {
                    Rank rank = RankManager.FindRank(name);
                    if (rank == null)
                    {
                        player.MessageNoRank(name);
                    }
                    else if (!player.Info.Rank.AllowSecurityCircumvention &&
                             realm.BuildSecurity.MinRank > rank &&
                             realm.BuildSecurity.MinRank > player.Info.Rank)
                    {
                        player.Message("&WYou must be ranked {0}&W+ to lower build restrictions for realm {1}",
                                        realm.BuildSecurity.MinRank.ClassyName, realm.ClassyName);
                    }
                    else
                    {
                        // list players who are redundantly blacklisted
                        var exceptionList = realm.BuildSecurity.ExceptionList;
                        PlayerInfo[] noLongerExcluded = exceptionList.Excluded.Where(excludedPlayer => excludedPlayer.Rank < rank).ToArray();
                        if (noLongerExcluded.Length > 0)
                        {
                            player.Message("Following players no longer need to be blacklisted on realm {0}&S: {1}",
                                            realm.ClassyName,
                                            noLongerExcluded.JoinToClassyString());
                        }

                        // list players who are redundantly whitelisted
                        PlayerInfo[] noLongerIncluded = exceptionList.Included.Where(includedPlayer => includedPlayer.Rank >= rank).ToArray();
                        if (noLongerIncluded.Length > 0)
                        {
                            player.Message("Following players no longer need to be whitelisted on realm {0}&S: {1}",
                                            realm.ClassyName,
                                            noLongerIncluded.JoinToClassyString());
                        }

                        // apply changes
                        realm.BuildSecurity.MinRank = rank;
                        changesWereMade = true;
                        if (realm.BuildSecurity.MinRank == RankManager.LowestRank)
                        {
                            Server.Message("{0}&S allowed anyone to build on realm {1}",
                                              player.ClassyName, realm.ClassyName);
                        }
                        else
                        {
                            Server.Message("{0}&S allowed only {1}+&S to build in realm {2}",
                                              player.ClassyName, realm.BuildSecurity.MinRank.ClassyName, realm.ClassyName);
                        }
                        Logger.Log(LogType.UserActivity, "{0} set build rank for realm {1} to {2}+",
                                    player.Name, realm.Name, realm.BuildSecurity.MinRank.Name);
                    }
                }
            } while ((name = cmd.Next()) != null);

            if (changesWereMade)
            {
                WorldManager.SaveWorldList();
            }
        }
Exemplo n.º 23
0
        static void SetSpawnHandler( Player player, CommandReader cmd ) {
            World playerWorld = player.World;
            if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );


            string playerName = cmd.Next();
            if( playerName == null ) {
                Map map = player.WorldMap;
                map.Spawn = player.Position;
                player.TeleportTo( map.Spawn );
                player.Send( Packet.MakeAddEntity( Packet.SelfID, player.ListName, player.Position ) );
                player.Message( "New spawn point saved." );
                Logger.Log( LogType.UserActivity,
                            "{0} changed the spawned point.",
                            player.Name );

            } else if( player.Can( Permission.Bring ) ) {
                Player[] infos = playerWorld.FindPlayers( player, playerName );
                if( infos.Length == 1 ) {
                    Player target = infos[0];
                    player.LastUsedPlayerName = target.Name;
                    if( player.Can( Permission.Bring, target.Info.Rank ) ) {
                        target.Send( Packet.MakeAddEntity( Packet.SelfID, target.ListName, player.Position ) );
                    } else {
                        player.Message( "You may only set spawn of players ranked {0}&S or lower.",
                                        player.Info.Rank.GetLimit( Permission.Bring ).ClassyName );
                        player.Message( "{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName );
                    }

                } else if( infos.Length > 0 ) {
                    player.MessageManyMatches( "player", infos );

                } else {
                    infos = Server.FindPlayers( player, playerName, true, false, true );
                    if( infos.Length > 0 ) {
                        player.Message( "You may only set spawn of players on the same world as you." );
                    } else {
                        player.MessageNoPlayer( playerName );
                    }
                }
            } else {
                player.MessageNoAccess( CdSetSpawn );
            }
        }
Exemplo n.º 24
0
        public static PlayerInfo FindPlayerInfoOrPrintMatches([NotNull] Player player, [NotNull] string namePart,
                                                              SearchOptions options)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (namePart == null)
            {
                throw new ArgumentNullException("namePart");
            }
            CheckIfLoaded();

            bool includeSelf = (options & SearchOptions.IncludeSelf) != 0;
            bool returnSelf  = (options & SearchOptions.ReturnSelfIfOnlyMatch) != 0;

            // If name starts with '!', return matches for online players only
            if (namePart.Length > 1 && namePart[0] == '!')
            {
                namePart = namePart.Substring(1);
                Player targetPlayer = Server.FindPlayerOrPrintMatches(player, namePart, options);
                if (targetPlayer != null)
                {
                    return(targetPlayer.Info);
                }
                else
                {
                    player.Message("No online players found matching \"{0}\"", namePart);
                    return(null);
                }
            }

            // Repeat last-used player name
            if (namePart == "-")
            {
                if (player.LastUsedPlayerName != null)
                {
                    namePart = player.LastUsedPlayerName;
                }
                else
                {
                    player.Message("Cannot repeat player name: you haven't used any names yet.");
                    return(null);
                }
            }

            // Make sure player name is valid
            if (!Player.ContainsValidCharacters(namePart))
            {
                player.MessageInvalidPlayerName(namePart);
                return(null);
            }

            // Search for exact matches first
            PlayerInfo target = FindPlayerInfoExact(namePart);

            // If no exact match was found, look for partial matches
            if (target == null || target == player.Info && !includeSelf)
            {
                PlayerInfo[] targets = FindPlayers(namePart);

                if (!includeSelf)
                {
                    // special handling if IncludeSelf flag is not set
                    if (targets.Length > 1)
                    {
                        targets = targets.Where(p => p != player.Info).ToArray();
                    }
                    else if (!returnSelf && targets.Length == 1 && targets[0] == player.Info)
                    {
                        // special handling if ReturnSelfIfOnlyMatch flag is not set
                        targets = new PlayerInfo[0];
                    }
                }

                if (targets.Length == 0)
                {
                    // No matches
                    player.MessageNoPlayer(namePart);
                    return(null);
                }
                else if (targets.Length > 1)
                {
                    // More than one match
                    Array.Sort(targets, new PlayerInfoComparer(player));
                    player.MessageManyMatches("player", targets.Take(MatchesToPrint).ToArray());
                    return(null);
                } // else: one match!
                target = targets[0];
            }

            // If a single name has been found, set it as LastUsedPlayerName
            if (includeSelf || target != player.Info)
            {
                player.LastUsedPlayerName = target.Name;
            }
            return(target);
        }
Exemplo n.º 25
0
        static void InfoHandler( Player player, CommandReader cmd ) {
            string name = cmd.Next();
            if( name == null ) {
                // no name given, print own info
                PrintPlayerInfo( player, player.Info );
                return;

            } else if( name.Equals( player.Name, StringComparison.OrdinalIgnoreCase ) ) {
                // own name given
                player.LastUsedPlayerName = player.Name;
                PrintPlayerInfo( player, player.Info );
                return;

            } else if( !player.Can( Permission.ViewOthersInfo ) ) {
                // someone else's name or IP given, permission required.
                player.MessageNoAccess( Permission.ViewOthersInfo );
                return;
            }

            // repeat last-typed name
            if( name == "-" ) {
                if( player.LastUsedPlayerName != null ) {
                    name = player.LastUsedPlayerName;
                } else {
                    player.Message( "Cannot repeat player name: you haven't used any names yet." );
                    return;
                }
            }

            PlayerInfo[] infos;
            IPAddress ip;

            if( name.Contains( "/" ) ) {
                // IP range matching (CIDR notation)
                string ipString = name.Substring( 0, name.IndexOf( '/' ) );
                string rangeString = name.Substring( name.IndexOf( '/' ) + 1 );
                byte range;
                if( IPAddressUtil.IsIP( ipString ) && IPAddress.TryParse( ipString, out ip ) &&
                    Byte.TryParse( rangeString, out range ) && range <= 32 ) {
                    player.Message( "Searching {0}-{1}", ip.RangeMin( range ), ip.RangeMax( range ) );
                    infos = PlayerDB.FindPlayersCidr( ip, range );
                } else {
                    player.Message( "Info: Invalid IP range format. Use CIDR notation." );
                    return;
                }

            } else if( IPAddressUtil.IsIP( name ) && IPAddress.TryParse( name, out ip ) ) {
                // find players by IP
                infos = PlayerDB.FindPlayers( ip );

            } else if( name.Equals( "*" ) ) {
                infos = (PlayerInfo[])PlayerDB.PlayerInfoList.Clone();

            } else if( name.Contains( "*" ) || name.Contains( "?" ) ) {
                // find players by regex/wildcard
                string regexString = "^" + RegexNonNameChars.Replace( name, "" ).Replace( "*", ".*" ).Replace( "?", "." ) + "$";
                Regex regex = new Regex( regexString, RegexOptions.IgnoreCase | RegexOptions.Compiled );
                infos = PlayerDB.FindPlayers( regex );

            } else if( name.StartsWith( "@" ) ) {
                string rankName = name.Substring( 1 );
                Rank rank = RankManager.FindRank( rankName );
                if( rank == null ) {
                    player.MessageNoRank( rankName );
                    return;
                } else {
                    infos = PlayerDB.PlayerInfoList
                                    .Where( info => info.Rank == rank )
                                    .ToArray();
                }

            } else if( name.StartsWith( "!" ) ) {
                // find online players by partial matches
                name = name.Substring( 1 );
                infos = Server.FindPlayers( name, true )
                              .Select( p => p.Info )
                              .ToArray();

            } else {
                // find players by partial matching
                PlayerInfo tempInfo;
                if( !PlayerDB.FindPlayerInfo( name, out tempInfo ) ) {
                    infos = PlayerDB.FindPlayers( name );
                } else if( tempInfo == null ) {
                    player.MessageNoPlayer( name );
                    return;
                } else {
                    infos = new[] { tempInfo };
                }
            }

            Array.Sort( infos, new PlayerInfoComparer( player ) );

            if( infos.Length == 1 ) {
                // only one match found; print it right away
                player.LastUsedPlayerName = infos[0].Name;
                PrintPlayerInfo( player, infos[0] );

            } else if( infos.Length > 1 ) {
                // multiple matches found
                if( infos.Length <= PlayersPerPage ) {
                    // all fit to one page
                    player.MessageManyMatches( "player", infos );

                } else {
                    // pagination
                    int offset;
                    if( !cmd.NextInt( out offset ) ) offset = 0;
                    if( offset >= infos.Length ) {
                        offset = Math.Max( 0, infos.Length - PlayersPerPage );
                    }
                    PlayerInfo[] infosPart = infos.Skip( offset ).Take( PlayersPerPage ).ToArray();
                    player.MessageManyMatches( "player", infosPart );
                    if( offset + infosPart.Length < infos.Length ) {
                        // normal page
                        player.Message( "Showing {0}-{1} (out of {2}). Next: &H/Info {3} {4}",
                                        offset + 1, offset + infosPart.Length, infos.Length,
                                        name, offset + infosPart.Length );
                    } else {
                        // last page
                        player.Message( "Showing matches {0}-{1} (out of {2}).",
                                        offset + 1, offset + infosPart.Length, infos.Length );
                    }
                }

            } else {
                // no matches found
                player.MessageNoPlayer( name );
            }
        }
Exemplo n.º 26
0
        static void InfoHandler( Player player, CommandReader cmd ) {
            string name = cmd.Next();
            if( name == null ) {
                // no name given, print own info
                PrintPlayerInfo( player, player.Info );
                return;

            } else if( name.Equals( player.Name, StringComparison.OrdinalIgnoreCase ) ) {
                // own name given
                player.LastUsedPlayerName = player.Name;
                PrintPlayerInfo( player, player.Info );
                return;

            } else if( !player.Can( Permission.ViewOthersInfo ) ) {
                // someone else's name or IP given, permission required.
                player.MessageNoAccess( Permission.ViewOthersInfo );
                return;
            }

            // repeat last-typed name
            if( name == "-" ) {
                if( player.LastUsedPlayerName != null ) {
                    name = player.LastUsedPlayerName;
                } else {
                    player.Message( "Cannot repeat player name: you haven't used any names yet." );
                    return;
                }
            }

            PlayerInfo[] infos;
            IPAddress ip;

            if( IPAddressUtil.IsIP( name ) && IPAddress.TryParse( name, out ip ) ) {
                // find players by IP
                infos = PlayerDB.FindByIP( ip ).ToArray();

            } else if( name.Contains( "*" ) || name.Contains( "?" ) ) {
                // find players by regex/wildcard
                infos = PlayerDB.FindByPattern( name ).ToArray();

            } else if( name.StartsWith( "@" ) ) {
                string rankName = name.Substring( 1 );
                Rank rank = RankManager.FindRank( rankName );
                if( rank == null ) {
                    player.Message( "Unknown rank: {0}", rankName );
                    return;
                } else {
                    using( PlayerDB.GetReadLock() ) {
                        infos = PlayerDB.List
                                        .Where( info => info.Rank == rank )
                                        .ToArray();
                    }
                }

            } else {
                // find players by partial matching
                PlayerInfo tempInfo;
                if( !PlayerDB.FindOneByPartialName( name, out tempInfo ) ) {
                    infos = PlayerDB.FindByPartialName( name ).ToArray();
                } else if( tempInfo == null ) {
                    player.MessageNoPlayer( name );
                    return;
                } else {
                    infos = new[] { tempInfo };
                }
            }

            Array.Sort( infos, new PlayerInfoComparer( player ) );

            if( infos.Length == 1 ) {
                // only one match found; print it right away
                player.LastUsedPlayerName = infos[0].Name;
                PrintPlayerInfo( player, infos[0] );

            } else if( infos.Length > 1 ) {
                // multiple matches found
                if( infos.Length <= PlayersPerPage ) {
                    // all fit to one page
                    player.MessageManyMatches( "player", infos );

                } else {
                    // pagination
                    int offset;
                    if( !cmd.NextInt( out offset ) ) offset = 0;
                    if( offset >= infos.Length ) {
                        offset = Math.Max( 0, infos.Length - PlayersPerPage );
                    }
                    PlayerInfo[] infosPart = infos.Skip( offset ).Take( PlayersPerPage ).ToArray();
                    player.MessageManyMatches( "player", infosPart );
                    if( offset + infosPart.Length < infos.Length ) {
                        // normal page
                        player.Message( "Showing {0}-{1} (out of {2}). Next: &H/Info {3} {4}",
                                        offset + 1, offset + infosPart.Length, infos.Length,
                                        name, offset + infosPart.Length );
                    } else {
                        // last page
                        player.Message( "Showing matches {0}-{1} (out of {2}).",
                                        offset + 1, offset + infosPart.Length, infos.Length );
                    }
                }

            } else {
                // no matches found
                player.MessageNoPlayer( name );
            }
        }