Ejemplo n.º 1
0
        private static void PortalH(Player player, Command command)
        {
            try
            {
                String option = command.Next();

                if (option == null)
                {
                    CdPortal.PrintUsage(player);
                }
                else if (option.ToLower().Equals("create"))
                {
                    if (player.Can(Permission.ManagePortal))
                    {
                        string world = command.Next();

                        if (world != null && WorldManager.FindWorldExact(world) != null)
                        {
                            DrawOperation operation = new CuboidDrawOperation(player);
                            NormalBrush brush = new NormalBrush(Block.Water, Block.Water);

                            string blockTypeOrName = command.Next();

                            if (blockTypeOrName != null && blockTypeOrName.ToLower().Equals("lava"))
                            {
                                brush = new NormalBrush(Block.Lava, Block.Lava);
                            }
                            else if (blockTypeOrName != null && !blockTypeOrName.ToLower().Equals("water"))
                            {
                                player.Message("Invalid block, choose between water or lava.");
                                return;
                            }

                            string portalName = command.Next();

                            if (portalName == null)
                            {
                                player.PortalName = null;
                            }
                            else
                            {
                                if (!Portal.DoesNameExist(player.World, portalName))
                                {
                                    player.PortalName = portalName;
                                }
                                else
                                {
                                    player.Message("A portal with name {0} already exists in this world.", portalName);
                                    return;
                                }
                            }

                            operation.Brush = brush;
                            player.PortalWorld = world;

                            player.SelectionStart(operation.ExpectedMarks, PortalCreateCallback, operation, Permission.Draw);
                            player.Message("Click {0} blocks or use &H/Mark&S to mark the area of the portal.", operation.ExpectedMarks);
                        }
                        else
                        {
                            if (world == null)
                            {
                                player.Message("No world specified.");
                            }
                            else
                            {
                                player.MessageNoWorld(world);
                            }
                        }
                    }
                    else
                    {
                        player.MessageNoAccess(Permission.ManagePortal);
                    }
                }
                else if (option.ToLower().Equals("remove"))
                {
                    if (player.Can(Permission.ManagePortal))
                    {
                        string portalName = command.Next();

                        if (portalName == null)
                        {
                            player.Message("No portal name specified.");
                        }
                        else
                        {
                            if (player.World.Portals != null && player.World.Portals.Count > 0)
                            {
                                bool found = false;
                                Portal portalFound = null;

                                lock (player.World.Portals.SyncRoot)
                                {
                                    foreach (Portal portal in player.World.Portals)
                                    {
                                        if (portal.Name.Equals(portalName))
                                        {
                                            portalFound = portal;
                                            found = true;
                                            break;
                                        }
                                    }

                                    if (!found)
                                    {
                                        player.Message("Could not find portal by name {0}.", portalName);
                                    }
                                    else
                                    {
                                        portalFound.Remove(player);
                                        player.Message("Portal was removed.");
                                    }
                                }
                            }
                            else
                            {
                                player.Message("Could not find portal as this world doesn't contain a portal.");
                            }
                        }
                    }
                    else
                    {
                        player.MessageNoAccess(Permission.ManagePortal);
                    }
                }
                else if (option.ToLower().Equals("info"))
                {
                    string portalName = command.Next();

                    if (portalName == null)
                    {
                        player.Message("No portal name specified.");
                    }
                    else
                    {
                        if (player.World.Portals != null && player.World.Portals.Count > 0)
                        {
                            bool found = false;

                            lock (player.World.Portals.SyncRoot)
                            {
                                foreach (Portal portal in player.World.Portals)
                                {
                                    if (portal.Name.Equals(portalName))
                                    {
                                        World portalWorld = WorldManager.FindWorldExact(portal.World);
                                        player.Message("Portal {0}&S was created by {1}&S at {2} and teleports to world {3}&S.",
                                            portal.Name, PlayerDB.FindPlayerInfoExact(portal.Creator).ClassyName, portal.Created, portalWorld.ClassyName);
                                        found = true;
                                    }
                                }
                            }

                            if (!found)
                            {
                                player.Message("Could not find portal by name {0}.", portalName);
                            }
                        }
                        else
                        {
                            player.Message("Could not find portal as this world doesn't contain a portal.");
                        }
                    }
                }
                else if (option.ToLower().Equals("list"))
                {
                    if (player.World.Portals == null || player.World.Portals.Count == 0)
                    {
                        player.Message("There are no portals in {0}&S.", player.World.ClassyName);
                    }
                    else
                    {
                        String[] portalNames = new String[player.World.Portals.Count];
                        StringBuilder output = new StringBuilder("There are " + player.World.Portals.Count + " portals in " + player.World.ClassyName + "&S: ");

                        for (int i = 0; i < player.World.Portals.Count; i++)
                        {
                            portalNames[i] = ((Portal)player.World.Portals[i]).Name;
                        }

                        output.Append(portalNames.JoinToString(", "));

                        player.Message(output.ToString());
                    }
                }
                else if (option.ToLower().Equals("enable"))
                {
                    player.PortalsEnabled = true;
                    player.Message("You enabled the use of portals.");
                }
                else if (option.ToLower().Equals("disable"))
                {
                    player.PortalsEnabled = false;
                    player.Message("You disabled the use of portals, type /portal enable to re-enable portals.");
                }
                else
                {
                    CdPortal.PrintUsage(player);
                }
            }
            catch (PortalException ex)
            {
                player.Message(ex.Message);
                Logger.Log(LogType.Error, "WorldCommands.PortalH: " + ex);
            }
            catch (Exception ex)
            {
                player.Message("Unexpected error: " + ex);
                Logger.Log(LogType.Error, "WorldCommands.PortalH: " + ex);
            }
        }
Ejemplo n.º 2
0
        static void MessageBlock( Player player, Command cmd )
        {
            string option = cmd.Next();
            if ( option == null ) {
                CdMessageBlock.PrintUsage( player );
                return;
            } else if ( option.ToLower() == "add" || option.ToLower() == "create" ) {
                string Message = cmd.NextAll();
                player.SelectionStart( 1, MessageBlockAdd, Message, CdMessageBlock.Permissions );
                player.Message( "MessageBlock: Place a block or type /mark to use your location." );
                return;
            } else if ( option.ToLower().Equals( "remove" ) || option.ToLower().Equals( "rd" ) ) {
                string MessageBlockName = cmd.Next();

                if ( MessageBlockName == null ) {
                    player.Message( "No MessageBlock name specified." );
                } else {
                    if ( player.World.Map.MessageBlocks != null && player.World.Map.MessageBlocks.Count > 0 ) {
                        bool found = false;
                        MessageBlock MessageBlockFound = null;

                        lock ( player.World.Map.MessageBlocks.SyncRoot ) {
                            foreach ( MessageBlock MessageBlock in player.World.Map.MessageBlocks ) {
                                if ( MessageBlock.Name.ToLower().Equals( MessageBlockName.ToLower() ) ) {
                                    MessageBlockFound = MessageBlock;
                                    found = true;
                                    break;
                                }
                            }

                            if ( !found ) {
                                player.Message( "Could not find MessageBlock by name {0}.", MessageBlockName );
                            } else {
                                MessageBlockFound.Remove( player );
                                player.Message( "MessageBlock was removed." );
                            }
                        }
                    } else {
                        player.Message( "Could not find MessageBlock as this world doesn't contain a MessageBlock." );
                    }
                }
            } else if ( option.ToLower().Equals( "info" ) ) {
                string MessageBlockName = cmd.Next();

                if ( MessageBlockName == null ) {
                    player.Message( "No MessageBlock name specified." );
                } else {
                    if ( player.World.Map.MessageBlocks != null && player.World.Map.MessageBlocks.Count > 0 ) {
                        bool found = false;

                        lock ( player.World.Map.MessageBlocks.SyncRoot ) {
                            foreach ( MessageBlock MessageBlock in player.World.Map.MessageBlocks ) {
                                if ( MessageBlock.Name.ToLower().Equals( MessageBlockName.ToLower() ) ) {
                                    World MessageBlockWorld = WorldManager.FindWorldExact( MessageBlock.World );
                                    player.Message( "MessageBlock '{0}&S' was created by {1}&S at {2}",
                                        MessageBlock.Name, MessageBlock.Creator, MessageBlock.Created );
                                    found = true;
                                }
                            }
                        }
                        if ( !found ) {
                            player.Message( "Could not find MessageBlock by name {0}.", MessageBlockName );
                        }
                    } else {
                        player.Message( "Could not find MessageBlock as this world doesn't contain a MessageBlock." );
                    }
                }
            } else if ( option.ToLower().Equals( "test" ) ) {
                player.SelectionStart( 1, MessageBlockTestCallback, null, CdMessageBlock.Permissions );
                player.Message( "MessageBlockTest: Click a block or type /mark to use your location." );
            } else if ( option.ToLower().Equals( "list" ) ) {
                if ( player.World.Map.MessageBlocks == null || player.World.Map.MessageBlocks.Count == 0 ) {
                    player.Message( "There are no MessageBlocks in {0}&S.", player.World.ClassyName );
                } else {
                    String[] MessageBlockNames = new String[player.World.Map.MessageBlocks.Count];
                    System.Text.StringBuilder output = new System.Text.StringBuilder( "There are " + player.World.Map.MessageBlocks.Count + " MessageBlocks in " + player.World.ClassyName + "&S: " );

                    for ( int i = 0; i < player.World.Map.MessageBlocks.Count; i++ ) {
                        MessageBlockNames[i] = ( ( MessageBlock )player.World.Map.MessageBlocks[i] ).Name;
                    }
                    output.Append( MessageBlockNames.JoinToString( ", " ) );
                    player.Message( output.ToString() );
                }
            } else {
                CdMessageBlock.PrintUsage( player );
            }
        }
Ejemplo n.º 3
0
        internal static void ListHandler(Player player, Command cmd)
        {
            string Option = cmd.Next();
            if (Option == null)
            {
                CdList.PrintUsage(player);
                player.Message("  Sections include: Staff, DisplayedNames, Idles, Portals, Rank, Top10");
                return;
            }
            switch (Option.ToLower())
            {
                default:
                    CdList.PrintUsage(player);
                    player.Message("  Sections include: Staff, DisplayedNames, Idles, Portals, Rank, Top10");
                    break;
                case "top10":
                    List<World> WorldNames = new List<World>(WorldManager.Worlds.Where(w => w.VisitCount > 0)
                                         .OrderBy(c => c.VisitCount)
                                         .ToArray()
                                         .Reverse());
                    string list = WorldNames.Take(10).JoinToString(w => String.Format("{0}&S: {1}", w.ClassyName, w.VisitCount));
                    if (WorldNames.Count() < 1){
                        player.Message("&WNo results found");
                        return;
                    }
                    player.Message("&WShowing worlds with the most visits: " + list);
                    WorldNames.Clear();
                    break;
                case "idles":
                case "idle":
                    var Idles = Server.Players.Where(p => p.IdleTime.TotalMinutes > 5).ToArray();
                    var visiblePlayers = Idles.Where(player.CanSee);
                    if (Idles.Count() > 0)
                        player.Message("Listing players idle for 5 mins or more: {0}",
                                        visiblePlayers.JoinToString(r => String.Format("{0}", r.ClassyName)));
                    else player.Message("No players have been idle for more than 5 minutes");
                    break;
                case "portals":
                    if (player.World == null){
                        player.Message("/List portals cannot be used from Console");
                        return;
                    }
                    if (player.World.Portals == null ||
                        player.World.Portals.Count == 0){
                        player.Message("There are no portals in {0}&S.", player.World.ClassyName);
                    }
                    else
                    {
                        String[] portalNames = new String[player.World.Portals.Count];
                        StringBuilder output = new StringBuilder("There are " + player.World.Portals.Count + " portals in " + player.World.ClassyName + "&S: ");

                        for (int i = 0; i < player.World.Portals.Count; i++)
                        {
                            portalNames[i] = ((fCraft.Portals.Portal)player.World.Portals[i]).Name;
                        }
                        output.Append(portalNames.JoinToString(", "));
                        player.Message(output.ToString());
                    }
                    break;
                case "staff":
                    var StaffNames = PlayerDB.PlayerInfoList
                                         .Where(r => r.Rank.Can(Permission.ReadStaffChat) &&
                                             r.Rank.Can(Permission.Ban) &&
                                             r.Rank.Can(Permission.Promote))
                                             .OrderBy(p => p.Rank)
                                             .ToArray();
                    if (StaffNames.Length < 1){
                        player.Message("&WNo results found");
                        return;
                    }
                    if (StaffNames.Length <= PlayersPerPage){
                        player.MessageManyMatches("staff", StaffNames);
                    }else{
                        int offset;
                        if (!cmd.NextInt(out offset)) offset = 0;
                        if (offset >= StaffNames.Length)
                            offset = Math.Max(0, StaffNames.Length - PlayersPerPage);
                        PlayerInfo[] StaffPart = StaffNames.Skip(offset).Take(PlayersPerPage).ToArray();
                        player.MessageManyMatches("staff", StaffPart);
                        if (offset + StaffPart.Length < StaffNames.Length)
                            player.Message("Showing {0}-{1} (out of {2}). Next: &H/List {3} {4}",
                                            offset + 1, offset + StaffPart.Length, StaffNames.Length,
                                            "staff", offset + StaffPart.Length);
                        else
                            player.Message("Showing matches {0}-{1} (out of {2}).",
                                            offset + 1, offset + StaffPart.Length, StaffNames.Length);
                    }
                    break;

                case "rank":
                    string rankName = cmd.Next();
                    if (rankName == null)
                    {
                        player.Message("Usage: /List rank rankName");
                        return;
                    }
                    Rank rank = RankManager.FindRank(rankName);
                    var RankNames = PlayerDB.PlayerInfoList
                                         .Where(r => r.Rank == rank)
                                             .ToArray();
                    if (RankNames.Length < 1){
                        player.Message("&WNo results found");
                        return;
                    }
                    if (RankNames.Length <= PlayersPerPage)
                    {
                        player.MessageManyMatches("players", RankNames);
                    }
                    else
                    {
                        int offset;
                        if (!cmd.NextInt(out offset)) offset = 0;
                        if (offset >= RankNames.Length)
                            offset = Math.Max(0, RankNames.Length - PlayersPerPage);
                        PlayerInfo[] RankPart = RankNames.Skip(offset).Take(PlayersPerPage).ToArray();
                        player.MessageManyMatches("rank list", RankPart);
                        if (offset + RankPart.Length < RankNames.Length)
                            player.Message("Showing {0}-{1} (out of {2}). Next: &H/List {3} {4}",
                                            offset + 1, offset + RankPart.Length, RankNames.Length,
                                            "rank " + rank.ClassyName, offset + RankPart.Length);
                        else
                            player.Message("Showing matches {0}-{1} (out of {2}).",
                                            offset + 1, offset + RankPart.Length, RankNames.Length);
                    }
                    break;
                case "displayednames":
                case "displayedname":
                case "dn":
                    var DisplayedNames = PlayerDB.PlayerInfoList
                                             .Where(r => r.DisplayedName != null).OrderBy(p => p.Rank).ToArray();
                    if (DisplayedNames.Length < 1){
                        player.Message("&WNo results found");
                        return;
                    }
                    if (DisplayedNames.Length <= 15)
                    {
                        player.MessageManyDisplayedNamesMatches("DisplayedNames", DisplayedNames);
                    }
                    else
                    {
                        int offset;
                        if (!cmd.NextInt(out offset)) offset = 0;
                        if (offset >= DisplayedNames.Count())
                            offset = Math.Max(0, DisplayedNames.Length - 15);
                        PlayerInfo[] DnPart = DisplayedNames.Skip(offset).Take(15).ToArray();
                        player.MessageManyDisplayedNamesMatches("DisplayedNames", DnPart);
                        if (offset + DisplayedNames.Length < DisplayedNames.Length)
                            player.Message("Showing {0}-{1} (out of {2}). Next: &H/List {3} {4}",
                                            offset + 1, offset + DnPart.Length, DisplayedNames.Length,
                                            "DisplayedNames", offset + DnPart.Length);
                        else
                            player.Message("Showing matches {0}-{1} (out of {2}).",
                                            offset + 1, offset + DnPart.Length, DisplayedNames.Length);
                    }
                    break;
            }
        }
Ejemplo n.º 4
0
        internal static void ListHandler( Player player, Command cmd )
        {
            string Option = cmd.Next();
            if ( Option == null ) {
                CdList.PrintUsage( player );
                player.Message( "  Sections include: Staff, DisplayedNames, Idles, Portals, Rank, Top10, Emotes" );
                return;
            }
            switch ( Option.ToLower() ) {
                default:
                    CdList.PrintUsage( player );
                    player.Message( "  Sections include: Staff, DisplayedNames, Idles, Portals, Rank, Top10, Emotes" );
                    break;
                case "emotes":
                    string Usage = "Shows a list of all available emotes and their keywords. " +
                   "There are 31 emotes, spanning 3 pages. Use &h/List emotes 2&s and &h/List emotes 3&s to see pages 2 and 3.";
                    int page = 1;
                    if ( cmd.HasNext ) {
                        if ( !cmd.NextInt( out page ) ) {
                            player.Message( Usage );
                            return;
                        }
                    }
                    if ( page < 1 || page > 3 ) {
                        player.Message( Usage );
                        return;
                    }

                    var emoteChars = Chat.EmoteKeywords
                                         .Values
                                         .Distinct()
                                         .Skip( ( page - 1 ) * 11 )
                                         .Take( 11 );

                    player.Message( "List of emotes, page {0} of 3:", page );
                    foreach ( char ch in emoteChars ) {
                        char ch1 = ch;
                        string keywords = Chat.EmoteKeywords
                                              .Where( pair => pair.Value == ch1 )
                                              .Select( kvp => "{&F" + kvp.Key.UppercaseFirst() + "&7}" )
                                              .JoinToString( " " );
                        player.Message( "&F  {0} &7= {1}", ch, keywords );
                    }
                    if ( page < 3 )
                        player.Message( "Type /List Emotes {0} for the next page", page + 1 );

                    break;
                case "top10":
                    List<World> WorldNames = new List<World>( WorldManager.Worlds.Where( w => w.VisitCount > 0 )
                                         .OrderBy( c => c.VisitCount )
                                         .ToArray()
                                         .Reverse() );
                    string list = WorldNames.Take( 10 ).JoinToString( w => String.Format( "{0}&S: {1}", w.ClassyName, w.VisitCount ) );
                    if ( WorldNames.Count() < 1 ) {
                        player.Message( "&WNo results found" );
                        return;
                    }
                    player.Message( "&WShowing worlds with the most visits: " + list );
                    WorldNames.Clear();
                    break;
                case "idles":
                case "idle":
                    var Idles = Server.Players.Where( p => p.IdleTime.TotalMinutes > 5 ).ToArray();
                    var visiblePlayers = Idles.Where( player.CanSee );
                    if ( visiblePlayers.Count() > 0 )
                        player.Message( "Listing players idle for 5 mins or more: {0}",
                                        visiblePlayers.JoinToString( r => String.Format( "{0}&S (Idle {1}", r.ClassyName, r.IdleTime.ToMiniString() ) ) );
                    else player.Message( "No players have been idle for more than 5 minutes" );
                    break;
                case "portals":
                    if ( player.World == null ) {
                        player.Message( "/List portals cannot be used from Console" );
                        return;
                    }
                    if ( player.World.Map.Portals == null ||
                        player.World.Map.Portals.Count == 0 ) {
                        player.Message( "There are no portals in {0}&S.", player.World.ClassyName );
                    } else {
                        String[] portalNames = new String[player.World.Map.Portals.Count];
                        StringBuilder output = new StringBuilder( "There are " + player.World.Map.Portals.Count + " portals in " + player.World.ClassyName + "&S: " );

                        for ( int i = 0; i < player.World.Map.Portals.Count; i++ ) {
                            portalNames[i] = ( ( fCraft.Portals.Portal )player.World.Map.Portals[i] ).Name;
                        }
                        output.Append( portalNames.JoinToString( ", " ) );
                        player.Message( output.ToString() );
                    }
                    break;
                case "staff":
                    var StaffNames = PlayerDB.PlayerInfoList
                                         .Where( r => r.Rank.Can( Permission.ReadStaffChat ) &&
                                             r.Rank.Can( Permission.Ban ) &&
                                             r.Rank.Can( Permission.Promote ) )
                                             .OrderBy( p => p.Rank )
                                             .ToArray();
                    if ( StaffNames.Length < 1 ) {
                        player.Message( "&WNo results found" );
                        return;
                    }
                    if ( StaffNames.Length <= PlayersPerPage ) {
                        player.MessageManyMatches( "staff", StaffNames );
                    } else {
                        int offset;
                        if ( !cmd.NextInt( out offset ) ) offset = 0;
                        if ( offset >= StaffNames.Length )
                            offset = Math.Max( 0, StaffNames.Length - PlayersPerPage );
                        PlayerInfo[] StaffPart = StaffNames.Skip( offset ).Take( PlayersPerPage ).ToArray();
                        player.MessageManyMatches( "staff", StaffPart );
                        if ( offset + StaffPart.Length < StaffNames.Length )
                            player.Message( "Showing {0}-{1} (out of {2}). Next: &H/List {3} {4}",
                                            offset + 1, offset + StaffPart.Length, StaffNames.Length,
                                            "staff", offset + StaffPart.Length );
                        else
                            player.Message( "Showing matches {0}-{1} (out of {2}).",
                                            offset + 1, offset + StaffPart.Length, StaffNames.Length );
                    }
                    break;

                case "rank":
                    string rankName = cmd.Next();
                    if ( rankName == null ) {
                        player.Message( "Usage: /List rank rankName" );
                        return;
                    }
                    Rank rank = RankManager.FindRank( rankName );
                    var RankNames = PlayerDB.PlayerInfoList
                                         .Where( r => r.Rank == rank )
                                             .ToArray();
                    if ( RankNames.Length < 1 ) {
                        player.Message( "&WNo results found" );
                        return;
                    }
                    if ( RankNames.Length <= PlayersPerPage ) {
                        player.MessageManyMatches( "players", RankNames );
                    } else {
                        int offset;
                        if ( !cmd.NextInt( out offset ) ) offset = 0;
                        if ( offset >= RankNames.Length )
                            offset = Math.Max( 0, RankNames.Length - PlayersPerPage );
                        PlayerInfo[] RankPart = RankNames.Skip( offset ).Take( PlayersPerPage ).ToArray();
                        player.MessageManyMatches( "rank list", RankPart );
                        if ( offset + RankPart.Length < RankNames.Length )
                            player.Message( "Showing {0}-{1} (out of {2}). Next: &H/List {3} {4}",
                                            offset + 1, offset + RankPart.Length, RankNames.Length,
                                            "rank " + rank.ClassyName, offset + RankPart.Length );
                        else
                            player.Message( "Showing matches {0}-{1} (out of {2}).",
                                            offset + 1, offset + RankPart.Length, RankNames.Length );
                    }
                    break;
                case "displayednames":
                case "displayedname":
                case "dn":
                    var DisplayedNames = PlayerDB.PlayerInfoList
                                             .Where( r => r.DisplayedName != null ).OrderBy( p => p.Rank ).ToArray();
                    if ( DisplayedNames.Length < 1 ) {
                        player.Message( "&WNo results found" );
                        return;
                    }
                    if ( DisplayedNames.Length <= 15 ) {
                        player.MessageManyDisplayedNamesMatches( "DisplayedNames", DisplayedNames );
                    } else {
                        int offset;
                        if ( !cmd.NextInt( out offset ) ) offset = 0;
                        if ( offset >= DisplayedNames.Count() )
                            offset = Math.Max( 0, DisplayedNames.Length - 15 );
                        PlayerInfo[] DnPart = DisplayedNames.Skip( offset ).Take( 15 ).ToArray();
                        player.MessageManyDisplayedNamesMatches( "DisplayedNames", DnPart );
                        if ( offset + DisplayedNames.Length < DisplayedNames.Length )
                            player.Message( "Showing {0}-{1} (out of {2}). Next: &H/List {3} {4}",
                                            offset + 1, offset + DnPart.Length, DisplayedNames.Length,
                                            "DisplayedNames", offset + DnPart.Length );
                        else
                            player.Message( "Showing matches {0}-{1} (out of {2}).",
                                            offset + 1, offset + DnPart.Length, DisplayedNames.Length );
                    }
                    break;
            }
        }
Ejemplo n.º 5
0
        static void Door( Player player, Command cmd )
        {
            string option = cmd.Next();
            if ( option == null ) {
                Door door = new Door();
                player.SelectionStart( 2, DoorAdd, door, CdDoor.Permissions );
                player.Message( "Door: Place a block or type /mark to use your location." );
                return;
            } else if ( option.ToLower().Equals( "remove" ) || option.ToLower().Equals( "rd" ) ) {
                string doorName = cmd.Next();

                if ( doorName == null ) {
                    player.Message( "No door name specified." );
                } else {
                    if ( player.World.Map.Doors != null && player.World.Map.Doors.Count > 0 ) {
                        bool found = false;
                        Door doorFound = null;

                        lock ( player.World.Map.Doors.SyncRoot ) {
                            foreach ( Door door in player.World.Map.Doors ) {
                                if ( door.Name.ToLower().Equals( doorName.ToLower() ) ) {
                                    doorFound = door;
                                    found = true;
                                    break;
                                }
                            }

                            if ( !found ) {
                                player.Message( "Could not find door by name {0}.", doorName );
                            } else {
                                doorFound.Remove( player );
                                player.Message( "door was removed." );
                            }
                        }
                    } else {
                        player.Message( "Could not find door as this world doesn't contain a door." );
                    }
                }
            } else if ( option.ToLower().Equals( "info" ) ) {
                string doorName = cmd.Next();

                if ( doorName == null ) {
                    player.Message( "No door name specified." );
                } else {
                    if ( player.World.Map.Doors != null && player.World.Map.Doors.Count > 0 ) {
                        bool found = false;

                        lock ( player.World.Map.Doors.SyncRoot ) {
                            foreach ( Door door in player.World.Map.Doors ) {
                                if ( door.Name.ToLower().Equals( doorName.ToLower() ) ) {
                                    World doorWorld = WorldManager.FindWorldExact( door.World );
                                    player.Message( "Door '{0}&S' was created by {1}&S at {2}",
                                        door.Name, door.Creator, door.Created );
                                    found = true;
                                }
                            }
                        }

                        if ( !found ) {
                            player.Message( "Could not find door by name {0}.", doorName );
                        }
                    } else {
                        player.Message( "Could not find door as this world doesn't contain a door." );
                    }
                }
            } else if ( option.ToLower().Equals( "list" ) ) {
                if ( player.World.Map.Doors == null || player.World.Map.Doors.Count == 0 ) {
                    player.Message( "There are no doors in {0}&S.", player.World.ClassyName );
                } else {
                    String[] doorNames = new String[player.World.Map.Doors.Count];
                    System.Text.StringBuilder output = new System.Text.StringBuilder( "There are " + player.World.Map.Doors.Count + " doors in " + player.World.ClassyName + "&S: " );

                    for ( int i = 0; i < player.World.Map.Doors.Count; i++ ) {
                        doorNames[i] = ( ( Door )player.World.Map.Doors[i] ).Name;
                    }
                    output.Append( doorNames.JoinToString( ", " ) );
                    player.Message( output.ToString() );
                }
            } else {
                CdDoor.PrintUsage( player );
            }
        }
Ejemplo n.º 6
0
        private static void Door( Player player, Command cmd )
        {
            string option = cmd.Next();
            if ( string.IsNullOrEmpty(option) ) {
                const int maxNumberOfDoorsPerPlayer = 4;
                if ( DoorHandler.GetPlayerOwnedDoorsCount( player.World, player ) >= maxNumberOfDoorsPerPlayer ) {
                    player.Message( "You cannot place any more doors, a player can have a maximum of {0} doors per world",
                        maxNumberOfDoorsPerPlayer );
                    return;
                }
                Door door = new Door();
                player.SelectionStart( 2, DoorAdd, door, CdDoor.Permissions );
                player.Message( "Door: Place a block or type /Mark to use your location." );
                return;
            } else if ( option.ToLower().Equals( "remove" ) || option.ToLower().Equals( "rd" ) ) {
                string doorName = cmd.Next();
                if ( doorName == null ) {
                    player.Message( "No door name specified." );
                } else {
                    if ( player.World.Map.Doors != null && player.World.Map.Doors.Count > 0 ) {
                        bool found = false;
                        Door doorFound = null;
                        lock ( player.World.Map.Doors.SyncRoot ) {
                            foreach ( Door door in player.World.Map.Doors ) {
                                if ( door.Name.Equals( doorName, StringComparison.OrdinalIgnoreCase ) ) {
                                    doorFound = door;
                                    found = true;
                                    break;
                                }
                            }
                            if ( !found ) {
                                player.Message( "Could not find door by name {0}.", doorName );
                            } else {
                                doorFound.Remove( player );
                                player.Message( "door was removed." );
                            }
                        }
                    } else {
                        player.Message( "Could not find door as this world doesn't contain a door." );
                    }
                }
            } else if ( option.ToLower().Equals( "info" ) ) {
                string doorName = cmd.Next();
                if ( doorName == null ) {
                    player.Message( "No door name specified." );
                } else {
                    if ( player.World.Map.Doors != null && player.World.Map.Doors.Count > 0 ) {
                        bool found = false;
                        lock ( player.World.Map.Doors.SyncRoot ) {
                            foreach ( Door door in player.World.Map.Doors ) {
                                if ( door.Name.Equals( doorName, StringComparison.OrdinalIgnoreCase ) ) {
                                    player.Message( "Door '{0}&S' was created by {1}&S at {2}",
                                        door.Name, door.Creator, door.Created );
                                    found = true;
                                }
                            }
                        }
                        if ( !found ) {
                            player.Message( "Could not find door by name {0}.", doorName );
                        }
                    } else {
                        player.Message( "Could not find door as this world doesn't contain a door." );
                    }
                }
            } else if ( option.ToLower().Equals( "list" ) ) {
                if ( player.World.Map.Doors == null || player.World.Map.Doors.Count == 0 ) {
                    player.Message( "There are no doors in {0}&S.", player.World.ClassyName );
                } else {
                    String[] doorNames = new String[player.World.Map.Doors.Count];
                    System.Text.StringBuilder output = new System.Text.StringBuilder( "There are " + player.World.Map.Doors.Count + " doors in " + player.World.ClassyName + "&S: " );

                    for ( int i = 0; i < player.World.Map.Doors.Count; i++ ) {
                        doorNames[i] = ( ( Door )player.World.Map.Doors[i] ).Name;
                    }
                    output.Append( doorNames.JoinToString( ", " ) );
                    player.Message( output.ToString() );
                }
            } else if ( option.ToLower() == "test" ) {
                player.SelectionStart( 1, DoorTestCallback, null, CdDoor.Permissions );
                player.Message( "DoorTest: Click a block or type /mark to use your location." );
            } else {
                CdDoor.PrintUsage( player );
            }
        }