Inheritance: IClassy
Esempio n. 1
1
        void DoZone( Player player, Command cmd ) {
            if( !player.Can( Permissions.SetSpawn ) ) {
                world.NoAccessMessage( player );
                return;
            }

            string name = cmd.Next();
            if( name == null ) {
                player.Message( "No zone name specified. See " + Color.Help + "/help zone" );
                return;
            }
            if( !Player.IsValidName( name ) ) {
                player.Message( "\"" + name + "\" is not a valid zone name" );
                return;
            }
            Zone zone = new Zone();
            zone.name = name;

            string property = cmd.Next();
            if( property == null ) {
                player.Message( "No zone rank/whitelist/blacklist specified. See " + Color.Help + "/help zone" );
                return;
            }
            PlayerClass minRank = world.classes.ParseClass( property );
            
            if( minRank != null ) {
                zone.buildRank = minRank.rank;
                player.tag = zone;
                player.marksExpected = 2;
                player.marks.Clear();
                player.markCount = 0;
                player.selectionCallback = MakeZone;
            }
        }
Esempio n. 2
0
 static void Door(Player player, CommandReader cmd)
 {
     string option = cmd.Next();
     if (string.IsNullOrEmpty(option)) {
         cdDoor.PrintUsage(player);
         return;
     } else {
         switch (option.ToLower()) {
             case "add":
             case "create":
                 string add = cmd.Next();
                 if (string.IsNullOrEmpty(add)) {
                     player.Message("You must specify a name for this door! Usage is /Door Create [name]");
                     break;
                 }
                 if (player.WorldMap.Zones.FindExact("Door_" + add.ToLower()) != null) {
                     player.Message("Door with same name already exists!");
                     break;
                 }
                 Zone door = new Zone();
                 door.Name = "Door_" + add.ToLower();
                 player.SelectionStart(2, DoorAdd, door, cdDoor.Permissions);
                 player.Message("Door: Place a block or type /mark to use your location.");
                 break;
             case "remove":
             case "delete":
                 Zone rzone;
                 string delete = cmd.Next();
                 if (string.IsNullOrEmpty(delete)) {
                     player.Message("You must specify the name of a door to remove! Usage is /Door Remove [name]");
                     break;
                 }
                 if (delete.ToLower().StartsWith("door_")) {
                     delete = delete.Substring(5);
                 }
                 if ((rzone = player.WorldMap.Zones.FindExact("Door_" + delete.ToLower())) != null) {
                     if (rzone.CreatedBy.ToLower().Equals(player.Name.ToLower()) || player.IsStaff) {
                         player.WorldMap.Zones.Remove(rzone);
                         player.Message("Door removed.");
                     } else {
                         player.Message("You are not able to remove someone elses door.");
                     }
                 } else {
                     player.Message("Could not find door: " + delete + " on this map!");
                 }
                 break;
             case "list":
                 player.Message("__Doors on {0}__", player.World.Name);
                 foreach (Zone list in player.World.Map.Zones.Where(z => z.Name.StartsWith("Door_")).ToArray()) {
                     player.Message(list.Name);
                 }
                 break;
             case "test":
             case "check":
                 player.SelectionStart(1, DoorTestCallback, null);
                 player.Message("Click the block that you would like to test.");
                 break;
             default:
                 player.Message(cdDoor.Help);
                 break;
         }
     }
 }
Esempio n. 3
0
        static void Game(Player player, Command cmd)
        {
            string option = cmd.Next();
            string mode = cmd.Next();
            if (option == "stop")
            {
                if (mode == "tf2" || mode == "tfminecraft")
                {
                    TFMinecraftHandler.Stop(player);
                    return;
                }
            }
            if (option == "start")
            {
                if (mode == "tf2" || mode == "tfminecraft")
                {
                    //if gameMap.Zones.Contains all bases
                    //startgame
                    //return; (saves time)
                    if (player.WorldMap.Zones.FindExact("redbase1") == null)
                    {
                        Zone BaseRed1 = new Zone();
                        BaseRed1.Name = "redbase1";
                        player.SelectionStart(2, TFMinecraftHandler.BaseAdd, BaseRed1, CdBase.Permissions);
                        player.Message("Red Base 1: Place 2 blocks to cuboid a Red base");
                        return;
                    }

                    else if (player.WorldMap.Zones.FindExact("redbase2") == null)
                    {
                        TFMinecraftHandler.RedBase2(player);
                        return;
                    }
                    else if (player.WorldMap.Zones.FindExact("redbase3") == null)
                    {
                        TFMinecraftHandler.RedBase3(player);
                        return;
                    }
                    else if (player.WorldMap.Zones.FindExact("bluebase1") == null)
                    {
                        TFMinecraftHandler.BlueBase1(player);
                        return;
                    }
                    else if (player.WorldMap.Zones.FindExact("bluebase2") == null)
                    {
                        TFMinecraftHandler.BlueBase2(player);
                        return;
                    }
                    else if (player.WorldMap.Zones.FindExact("bluebase3") == null)
                    {
                        TFMinecraftHandler.BlueBase3(player);
                        return;
                    }
                    else TFMinecraftHandler.Start(player, player.World);
                }

                else player.Message("Invalid Option");
            }
        }
Esempio n. 4
0
 public static void RedBase3(Player player)
 {
     Zone BaseRed3 = new Zone();
        BaseRed3.Name = "redbase3";
        player.SelectionStart(2, TFMinecraftHandler.BaseAdd, BaseRed3, WorldCommands.CdBase.Permissions);
        player.Message("Red Base 3: Place 2 blocks to cuboid a Red base");
 }
Esempio n. 5
0
        static void ZoneInfoHandler(Player player, Command cmd)
        {
            string zoneName = cmd.Next();

            if (zoneName == null)
            {
                player.Message("No zone name specified. See &H/Help ZInfo");
                return;
            }

            Zone zone = player.WorldMap.Zones.Find(zoneName);

            if (zone == null)
            {
                player.MessageNoZone(zoneName);
                return;
            }

            player.Message("About zone \"{0}\": size {1} x {2} x {3}, contains {4} blocks, editable by {5}+.",
                           zone.Name,
                           zone.Bounds.Width, zone.Bounds.Length, zone.Bounds.Height,
                           zone.Bounds.Volume,
                           zone.Controller.MinRank.ClassyName);

            player.Message("  Zone center is at ({0},{1},{2}).",
                           (zone.Bounds.XMin + zone.Bounds.XMax) / 2,
                           (zone.Bounds.YMin + zone.Bounds.YMax) / 2,
                           (zone.Bounds.ZMin + zone.Bounds.ZMax) / 2);

            if (zone.CreatedBy != null)
            {
                player.Message("  Zone created by {0}&S on {1:MMM d} at {1:h:mm} ({2} ago).",
                               zone.CreatedByClassy,
                               zone.CreatedDate,
                               DateTime.UtcNow.Subtract(zone.CreatedDate).ToMiniString());
            }

            if (zone.EditedBy != null)
            {
                player.Message("  Zone last edited by {0}&S on {1:MMM d} at {1:h:mm} ({2}d {3}h ago).",
                               zone.EditedByClassy,
                               zone.EditedDate,
                               DateTime.UtcNow.Subtract(zone.EditedDate).Days,
                               DateTime.UtcNow.Subtract(zone.EditedDate).Hours);
            }

            PlayerExceptions zoneExceptions = zone.ExceptionList;

            if (zoneExceptions.Included.Length > 0)
            {
                player.Message("  Zone whitelist includes: {0}",
                               zoneExceptions.Included.JoinToClassyString());
            }

            if (zoneExceptions.Excluded.Length > 0)
            {
                player.Message("  Zone blacklist excludes: {0}",
                               zoneExceptions.Excluded.JoinToClassyString());
            }

            if (null != zone.Message)
            {
                player.Message("  Zone has custom deny build message: " + zone.Message);
            }
            else
            {
                player.Message("  Zone has no custom deny build message");
            }
        }
Esempio n. 6
0
        static void ZoneAddHandler( Player player, Command cmd )
        {
            World playerWorld = player.World;
            if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );

            string givenZoneName = cmd.Next();
            if( givenZoneName == null ) {
                CdZoneAdd.PrintUsage( player );
                return;
            }

            if (givenZoneName.EndsWith("door"))
            {
                player.Message("&SA Zone name cannot end with 'door'");
                return;
            }

            if( !player.Info.Rank.AllowSecurityCircumvention ) {
                SecurityCheckResult buildCheck = playerWorld.BuildSecurity.CheckDetailed( player.Info );
                switch( buildCheck ) {
                    case SecurityCheckResult.BlackListed:
                        player.Message( "Cannot add zones to world {0}&S: You are barred from building here.",
                                        playerWorld.ClassyName );
                        return;
                    case SecurityCheckResult.RankTooLow:
                        player.Message( "Cannot add zones to world {0}&S: You are not allowed to build here.",
                                        playerWorld.ClassyName );
                        return;
                    //case SecurityCheckResult.RankTooHigh:
                }
            }

            Zone newZone = new Zone();
            ZoneCollection zoneCollection = player.WorldMap.Zones;

            if( givenZoneName.StartsWith( "+" ) ) {
                // personal zone (/ZAdd +Name)
                givenZoneName = givenZoneName.Substring( 1 );

                // Find the target player
                PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches( player, givenZoneName );
                if( info == null ) return;

                // Make sure that the name is not taken already.
                // If a zone named after the player already exists, try adding a number after the name (e.g. "Notch2")
                newZone.Name = info.Name;
                for( int i = 2; zoneCollection.Contains( newZone.Name ); i++ ) {
                    newZone.Name = givenZoneName + i;
                }

                newZone.Controller.MinRank = info.Rank.NextRankUp ?? info.Rank;
                newZone.Controller.Include( info );
                player.Message( "Zone: Creating a {0}+&S zone for player {1}&S. Place a block or type /Mark to use your location.",
                                newZone.Controller.MinRank.ClassyName, info.ClassyName );
                player.SelectionStart( 2, ZoneAddCallback, newZone, CdZoneAdd.Permissions );

            } else {
                // Adding an ordinary, rank-restricted zone.
                if( !World.IsValidName( givenZoneName ) ) {
                    player.Message( "\"{0}\" is not a valid zone name", givenZoneName );
                    return;
                }

                if( zoneCollection.Contains( givenZoneName ) ) {
                    player.Message( "A zone with this name already exists. Use &H/ZEdit&S to edit." );
                    return;
                }

                newZone.Name = givenZoneName;

                string rankName = cmd.Next();
                if( rankName == null ) {
                    player.Message( "No rank was specified. See &H/Help zone" );
                    return;
                }
                Rank minRank = RankManager.FindRank( rankName );

                if( minRank != null ) {
                    string name;
                    while( (name = cmd.Next()) != null ) {

                        if( name.Length == 0 ) continue;

                        PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches( player, name.Substring( 1 ) );
                        if( info == null ) return;

                        if( name.StartsWith( "+" ) ) {
                            newZone.Controller.Include( info );
                        } else if( name.StartsWith( "-" ) ) {
                            newZone.Controller.Exclude( info );
                        }
                    }

                    newZone.Controller.MinRank = minRank;
                    player.SelectionStart( 2, ZoneAddCallback, newZone, CdZoneAdd.Permissions );
                    player.Message( "Zone: Place a block or type &H/Mark&S to use your location." );

                } else {
                    player.MessageNoRank( rankName );
                }
            }
        }
Esempio n. 7
0
        static void Door(Player player, Command cmd)
        {
            if (player.WorldMap.Zones.FindExact(player.Name + "door") != null) {
                player.Message("One door per person.");
                return;
            }

            Zone door = new Zone();
            door.Name = player.Name + "door";
            player.SelectionStart(2, DoorAdd, door, cdDoor.Permissions);
            player.Message("Door: Place a block or type /mark to use your location.");
        }
Esempio n. 8
0
        static void Door(Player player, Command cmd)
        {
            string name = cmd.Next();
            if (String.IsNullOrEmpty(name))
            {
                player.Message("You must have a name for your door! Usage is /door [name]");
                return;
            }

            if (player.WorldMap.Zones.FindExact("Door_" + name) != null)
            {
                player.Message("There is a door on this world with that name already!");
                return;
            }

            Zone door = new Zone();
            door.Name = "Door_" + name;
            player.SelectionStart(2, DoorAdd, door, cdDoor.Permissions);
            player.Message("Door: Place a block or type /mark to use your location.");
        }
Esempio n. 9
0
        static void CaptureBase(Zone zone, Player player)
        {
            int sx = zone.Bounds.XMin;
            int ex = zone.Bounds.XMax;
            int sy = zone.Bounds.YMin;
            int ey = zone.Bounds.YMax;
            int sz = zone.Bounds.ZMin;
            int ez = zone.Bounds.ZMax;

            Block[] buffer = new Block[zone.Bounds.Volume];

            int counter = 0;
            for (int x = sx; x <= ex; x++)
            {
                for (int y = sy; y <= ey; y++)
                {
                    for (int z = sz; z <= ez; z++)
                    {
                        buffer[counter] = player.WorldMap.GetBlock(x, y, z);
                        player.WorldMap.QueueUpdate(new BlockUpdate(null, new Vector3I(x, y, z), Block.Blue));
                        counter++;
                    }
                }
            }
        }
Esempio n. 10
0
 public void sendZoneMessage(Zone zone, string backup) {
     FileInfo SignInfo = new FileInfo("./signs/" + World.Name + "/" + zone.Name + ".txt");
     string SignMessage = null;
     if (SignInfo.Exists) {
         string[] SignList = File.ReadAllLines("./signs/" + World.Name + "/" + zone.Name + ".txt");
         foreach (string line in SignList) {
             SignMessage += line + "&n";
         }
     }
     if ((DateTime.UtcNow - LastZoneNotification).Seconds > 2) {
         Message(SignMessage ?? backup);
         LastZoneNotification = DateTime.UtcNow;
     }
 }
Esempio n. 11
0
        static void ZoneRenameHandler(Player player, CommandReader cmd)
        {
            World playerWorld = player.World;

            if (playerWorld == null)
            {
                PlayerOpException.ThrowNoWorld(player);
            }

            // make sure that both parameters are given
            string oldName = cmd.Next();
            string newName = cmd.Next();

            if (oldName == null || newName == null)
            {
                CdZoneRename.PrintUsage(player);
                return;
            }

            // make sure that the new name is valid
            if (!World.IsValidName(newName))
            {
                player.Message("\"{0}\" is not a valid zone name", newName);
                return;
            }

            // find the old zone
            var  zones   = player.WorldMap.Zones;
            Zone oldZone = zones.Find(oldName);

            if (oldZone == null)
            {
                player.MessageNoZone(oldName);
                return;
            }

            // Check if a zone with "newName" name already exists
            Zone newZone = zones.FindExact(newName);

            if (newZone != null && newZone != oldZone)
            {
                player.Message("A zone with the name \"{0}\" already exists.", newName);
                return;
            }

            // check if any change is needed
            string fullOldName = oldZone.Name;

            if (fullOldName == newName)
            {
                player.Message("The zone is already named \"{0}\"", fullOldName);
                return;
            }

            // actually rename the zone
            zones.Rename(oldZone, newName);

            // announce the rename
            playerWorld.Players.Message("&SZone \"{0}\" was renamed to \"{1}&S\" by {2}",
                                        fullOldName, oldZone.ClassyName, player.ClassyName);
            Logger.Log(LogType.UserActivity,
                       "Player {0} renamed zone \"{1}\" to \"{2}\" on world {3}",
                       player.Name, fullOldName, newName, playerWorld.Name);
        }
Esempio n. 12
0
        static void ZoneRemoveHandler(Player player, CommandReader cmd)
        {
            string zoneName = cmd.Next();

            if (zoneName == null || cmd.HasNext)
            {
                CdZoneRemove.PrintUsage(player);
                return;
            }

            if (zoneName == "*")
            {
                if (!cmd.IsConfirmed)
                {
                    player.Confirm(cmd,
                                   "&WRemove ALL zones on this world ({0}&W)? This cannot be undone.&S",
                                   player.World.ClassyName);
                    return;
                }
                player.WorldMap.Zones.Clear();
                Logger.Log(LogType.UserActivity,
                           "Player {0} removed all zones on world {1}",
                           player.Name, player.World.Name);
                Server.Message("Player {0}&S removed all zones on world {1}",
                               player.ClassyName, player.World.ClassyName);
                return;
            }

            ZoneCollection zones = player.WorldMap.Zones;
            Zone           zone  = zones.Find(zoneName);

            if (zone != null)
            {
                if (!player.Info.Rank.AllowSecurityCircumvention)
                {
                    switch (zone.Controller.CheckDetailed(player.Info))
                    {
                    case SecurityCheckResult.BlackListed:
                        player.Message("You are not allowed to remove zone {0}: you are blacklisted.", zone.ClassyName);
                        return;

                    case SecurityCheckResult.RankTooLow:
                        player.Message("You are not allowed to remove zone {0}.", zone.ClassyName);
                        return;

                        // TODO: Must be below rank or Operator
                        // case SecurityCheckResult.RankTooLow:
                    }
                }
                if (!cmd.IsConfirmed)
                {
                    player.Confirm(cmd, "Remove zone {0}&S?", zone.ClassyName);
                    return;
                }

                if (zones.Remove(zone.Name))
                {
                    player.Message("Zone \"{0}\" removed.", zone.Name);
                }
            }
            else
            {
                player.MessageNoZone(zoneName);
            }
        }
Esempio n. 13
0
        static void ZoneAddHandler(Player player, CommandReader cmd)
        {
            World playerWorld = player.World;

            if (playerWorld == null)
            {
                PlayerOpException.ThrowNoWorld(player);
            }

            string givenZoneName = cmd.Next();

            if (givenZoneName == null)
            {
                CdZoneAdd.PrintUsage(player);
                return;
            }

            if (!player.Info.Rank.AllowSecurityCircumvention)
            {
                SecurityCheckResult buildCheck = playerWorld.BuildSecurity.CheckDetailed(player.Info);
                switch (buildCheck)
                {
                case SecurityCheckResult.BlackListed:
                    player.Message("Cannot add zones to world {0}&S: You are barred from building here.",
                                   playerWorld.ClassyName);
                    return;

                case SecurityCheckResult.RankTooLow:
                    player.Message("Cannot add zones to world {0}&S: You are not allowed to build here.",
                                   playerWorld.ClassyName);
                    return;

                    //case SecurityCheckResult.RankTooHigh: // TODO
                }
            }

            Zone           newZone        = new Zone();
            ZoneCollection zoneCollection = player.WorldMap.Zones;

            if (givenZoneName.StartsWith("+"))
            {
                // personal zone (/ZAdd +Name)
                givenZoneName = givenZoneName.Substring(1);

                // Find the target player
                PlayerInfo info = PlayerDB.FindByPartialNameOrPrintMatches(player, givenZoneName);
                if (info == null)
                {
                    return;
                }
                givenZoneName = info.Name;

                // Make sure that the name is not taken already.
                // If a zone named after the player already exists, try adding a number after the name (e.g. "Notch2")
                newZone.Name = givenZoneName;
                for (int i = 2; zoneCollection.Contains(newZone.Name); i++)
                {
                    newZone.Name = givenZoneName + i;
                }

                newZone.Controller.MinRank = info.Rank.NextRankUp ?? info.Rank;
                newZone.Controller.Include(info);
                player.Message("Zone: Creating a {0}+&S zone for player {1}&S. Place a block or type /Mark to use your location.",
                               newZone.Controller.MinRank.ClassyName, info.ClassyName);
                player.SelectionStart(2, ZoneAddCallback, newZone, CdZoneAdd.Permissions);
            }
            else
            {
                // Adding an ordinary, rank-restricted zone.
                if (!World.IsValidName(givenZoneName))
                {
                    player.Message("\"{0}\" is not a valid zone name", givenZoneName);
                    return;
                }

                if (zoneCollection.Contains(givenZoneName))
                {
                    player.Message("A zone with this name already exists. Use &H/ZEdit&S to edit.");
                    return;
                }

                newZone.Name = givenZoneName;

                string rankName = cmd.Next();
                if (rankName == null)
                {
                    player.Message("No rank was specified. See &H/Help zone");
                    return;
                }
                Rank minRank = RankManager.FindRank(rankName);

                if (minRank != null)
                {
                    string name;
                    while ((name = cmd.Next()) != null)
                    {
                        if (name.Length == 0)
                        {
                            continue;
                        }

                        PlayerInfo info = PlayerDB.FindByPartialNameOrPrintMatches(player, name.Substring(1));
                        if (info == null)
                        {
                            return;
                        }

                        if (name.StartsWith("+"))
                        {
                            newZone.Controller.Include(info);
                        }
                        else if (name.StartsWith("-"))
                        {
                            newZone.Controller.Exclude(info);
                        }
                    }

                    newZone.Controller.MinRank = minRank;
                    player.SelectionStart(2, ZoneAddCallback, newZone, CdZoneAdd.Permissions);
                    player.Message("Zone: Place a block or type &H/Mark&S to use your location.");
                }
                else
                {
                    player.MessageNoRank(rankName);
                }
            }
        }
Esempio n. 14
0
        static void ZoneEditHandler(Player player, CommandReader cmd)
        {
            bool   changesWereMade = false;
            string zoneName        = cmd.Next();

            if (zoneName == null)
            {
                player.Message("No zone name specified. See &H/Help ZEdit");
                return;
            }

            Zone zone = player.WorldMap.Zones.Find(zoneName);

            if (zone == null)
            {
                player.MessageNoZone(zoneName);
                return;
            }

            string nextToken;

            while ((nextToken = cmd.Next()) != null)
            {
                // Clear whitelist
                if (nextToken.Equals("-*"))
                {
                    PlayerInfo[] oldWhitelist = zone.Controller.ExceptionList.Included;
                    if (oldWhitelist.Length > 0)
                    {
                        zone.Controller.ResetIncludedList();
                        player.Message("Whitelist of zone {0}&S cleared: {1}",
                                       zone.ClassyName, oldWhitelist.JoinToClassyString());
                        Logger.Log(LogType.UserActivity,
                                   "Player {0} cleared whitelist of zone {1} on world {2}: {3}",
                                   player.Name, zone.Name, player.World.Name,
                                   oldWhitelist.JoinToString(pi => pi.Name));
                    }
                    else
                    {
                        player.Message("Whitelist of zone {0}&S is empty.",
                                       zone.ClassyName);
                    }
                    continue;
                }

                // Clear blacklist
                if (nextToken.Equals("+*"))
                {
                    PlayerInfo[] oldBlacklist = zone.Controller.ExceptionList.Excluded;
                    if (oldBlacklist.Length > 0)
                    {
                        zone.Controller.ResetExcludedList();
                        player.Message("Blacklist of zone {0}&S cleared: {1}",
                                       zone.ClassyName, oldBlacklist.JoinToClassyString());
                        Logger.Log(LogType.UserActivity,
                                   "Player {0} cleared blacklist of zone {1} on world {2}: {3}",
                                   player.Name, zone.Name, player.World.Name,
                                   oldBlacklist.JoinToString(pi => pi.Name));
                    }
                    else
                    {
                        player.Message("Blacklist of zone {0}&S is empty.",
                                       zone.ClassyName);
                    }
                    continue;
                }

                if (nextToken.StartsWith("+"))
                {
                    PlayerInfo info = PlayerDB.FindByPartialNameOrPrintMatches(player, nextToken.Substring(1));
                    if (info == null)
                    {
                        return;
                    }

                    // prevent players from whitelisting themselves to bypass protection
                    if (!player.Info.Rank.AllowSecurityCircumvention && player.Info == info)
                    {
                        switch (zone.Controller.CheckDetailed(info))
                        {
                        case SecurityCheckResult.BlackListed:
                            player.Message("You are not allowed to remove yourself from the blacklist of zone {0}",
                                           zone.ClassyName);
                            continue;

                        case SecurityCheckResult.RankTooLow:
                            player.Message("You must be {0}+&S to add yourself to the whitelist of zone {1}",
                                           zone.Controller.MinRank.ClassyName, zone.ClassyName);
                            continue;
                        }
                    }

                    switch (zone.Controller.Include(info))
                    {
                    case PermissionOverride.Deny:
                        player.Message("{0}&S is no longer excluded from zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        changesWereMade = true;
                        break;

                    case PermissionOverride.None:
                        player.Message("{0}&S is now included in zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        changesWereMade = true;
                        break;

                    case PermissionOverride.Allow:
                        player.Message("{0}&S is already included in zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        break;
                    }
                }
                else if (nextToken.StartsWith("-"))
                {
                    PlayerInfo info = PlayerDB.FindByPartialNameOrPrintMatches(player, nextToken.Substring(1));
                    if (info == null)
                    {
                        return;
                    }

                    switch (zone.Controller.Exclude(info))
                    {
                    case PermissionOverride.Deny:
                        player.Message("{0}&S is already excluded from zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        break;

                    case PermissionOverride.None:
                        player.Message("{0}&S is now excluded from zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        changesWereMade = true;
                        break;

                    case PermissionOverride.Allow:
                        player.Message("{0}&S is no longer included in zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        changesWereMade = true;
                        break;
                    }
                }
                else
                {
                    Rank minRank = RankManager.FindRank(nextToken);

                    if (minRank != null)
                    {
                        // prevent players from lowering rank so bypass protection
                        if (!player.Info.Rank.AllowSecurityCircumvention &&
                            zone.Controller.MinRank > player.Info.Rank && minRank <= player.Info.Rank)
                        {
                            player.Message("You are not allowed to lower the zone's rank.");
                            continue;
                        }

                        if (zone.Controller.MinRank != minRank)
                        {
                            zone.Controller.MinRank = minRank;
                            player.Message("Permission for zone \"{0}\" changed to {1}+",
                                           zone.Name,
                                           minRank.ClassyName);
                            changesWereMade = true;
                        }
                    }
                    else
                    {
                        player.MessageNoRank(nextToken);
                    }
                }

                if (changesWereMade)
                {
                    zone.Edit(player.Info);
                }
                else
                {
                    player.Message("No changes were made to the zone.");
                }
            }
        }
Esempio n. 15
0
 public DoorInfo(Zone zone, Block[] buffer, Map worldMap)
 {
     Zone     = zone;
     Buffer   = buffer;
     WorldMap = worldMap;
 }
Esempio n. 16
0
        static void SignAddHandler(Player player, CommandReader cmd)
        {
            World playerWorld = player.World;
            if (playerWorld == null) PlayerOpException.ThrowNoWorld(player);

            string givenZoneName = "Sign_" + cmd.Next();
            if (givenZoneName == null || !cmd.HasNext)
            {
                CdSignAdd.PrintUsage(player);
                return;
            }

            if (!player.Info.Rank.AllowSecurityCircumvention)
            {
                SecurityCheckResult buildCheck = playerWorld.BuildSecurity.CheckDetailed(player.Info);
                switch (buildCheck)
                {
                    case SecurityCheckResult.BlackListed:
                        player.Message("Cannot add zones to world {0}&S: You are barred from building here.",
                                        playerWorld.ClassyName);
                        return;
                    case SecurityCheckResult.RankTooLow:
                        player.Message("Cannot add zones to world {0}&S: You are not allowed to build here.",
                                        playerWorld.ClassyName);
                        return;
                }
            }

            Zone newZone = new Zone();
            ZoneCollection zoneCollection = player.WorldMap.Zones;
            if (!canManageSpecialZone(givenZoneName.ToLower(), player)) {
                return;
            }


            // Adding an ordinary, rank-restricted zone.
            if (!World.IsValidName(givenZoneName))
            {
                player.Message("\"{0}\" is not a valid Sign/Zone name", givenZoneName);
                return;
            }

            if (zoneCollection.Contains(givenZoneName))
            {
                player.Message("A Sign/Zone with this name already exists.");
                return;
            }

            newZone.Name = givenZoneName;

            Rank minRank = RankManager.HighestRank;

            if (cmd.HasNext)
            {
                newZone.Sign = cmd.NextAll();
                if (newZone.Sign.Length == 0)
                {
                    CdSignAdd.PrintUsage(player); 
                    return;
                }
                else
                {
                    if (!Directory.Exists("./Signs/")) Directory.CreateDirectory("./Signs/");
                    if (!Directory.Exists("./Signs/" + player.World.Name + "/")) Directory.CreateDirectory("./Signs/" + player.World.Name + "/");
                    File.WriteAllText("./Signs/" + player.World.Name + "/" + newZone.Name + ".txt", cmd.NextAll().Replace("%n", "/n"));
                    player.Message("&SMessage for sign {0}&S is: {1}", newZone.ClassyName, newZone.Sign);
                    newZone.Sign = null;
                }
            }

            newZone.Controller.MinRank = minRank;
            player.SelectionStart(1, SignAddCallback, newZone, CdSignAdd.Permissions);
            player.Message("SignAdd: Creating sign {0}&S. Click or &H/Mark&S 1 block.",
                            newZone.ClassyName);
        }
Esempio n. 17
0
        internal static void ZoneAdd( Player player, Command cmd )
        {
            //TODO: better method names & documentation
            if( !player.Can( Permissions.ManageZones ) ) {
                player.NoAccessMessage( Permissions.ManageZones );
                return;
            }

            string name = cmd.Next();
            if( name == null ) {
                player.Message( "No zone name specified. See " + Color.Help + "/help zone" );
                return;
            }
            if( !Player.IsValidName( name ) ) {
                player.Message( "\"" + name + "\" is not a valid zone name" );
                return;
            }
            Zone[] zones = player.world.map.ListZones();
            if( zones.Length > 0 ) {
                foreach (Zone zonel in zones)
                {
                    if (zonel.name == name)
                    {
                        player.Message("Zone '" + name + "' already exists!");
                        return;
                    }
                }
            }
            Zone zone = new Zone();
            zone.name = name;

            string property = cmd.Next();
            if( property == null ) {
                player.Message( "No zone rank/whitelist/blacklist specified. See " + Color.Help + "/help zone" );
                return;
            }
            PlayerClass minRank = ClassList.ParseClass( property );

            if( minRank != null ) {
                zone.buildRank = minRank.rank;
                player.tag = zone;
                player.marksExpected = 2;
                player.marks.Clear();
                player.markCount = 0;
                player.selectionCallback = ZoneAddCallback;
                player.Message( "Zone: Place a block or type /mark to use your location." );
            } else {
                player.Message( "Unknown player class: " + property );
            }
        }
Esempio n. 18
0
		static void InitZones() {
			Zone zoneRed = new Zone();
			zoneRed.Name = RedTeam.Name;
			Vector3I redFirst = new Vector3I(map.Bounds.XMin, map.Bounds.YMin, map.Bounds.ZMin);
			Vector3I redSecond = new Vector3I(map.Bounds.Width / 2 - 2, map.Bounds.Length, map.Bounds.ZMax);
			zoneRed.Create(new BoundingBox(redFirst, redSecond), Player.Console.Info);
			map.Zones.Remove(zoneRed.Name);
			map.Zones.Add(zoneRed);
			RedTeam.SetBounds(redFirst, redSecond);

			Zone zoneBlue = new Zone();
			zoneBlue.Name = BlueTeam.Name;
			Vector3I blueFirst = new Vector3I(map.Bounds.XMax, map.Bounds.YMin, map.Bounds.ZMin);
			Vector3I blueSecond = new Vector3I((map.Bounds.Width / 2) + 2, map.Bounds.Length, map.Bounds.ZMax);
			zoneBlue.Create(new BoundingBox(blueFirst, blueSecond), Player.Console.Info);
			map.Zones.Remove(zoneBlue.Name);
			map.Zones.Add(zoneBlue);
			BlueTeam.SetBounds(blueFirst, blueSecond);
		}
Esempio n. 19
0
        internal static void ZoneAdd( Player player, Command cmd ) {
            string zoneName = cmd.Next();
            if( zoneName == null ) {
                cdZoneAdd.PrintUsage( player );
                return;
            }

            Zone zone = new Zone();

            if( zoneName.StartsWith( "+" ) ) {
                PlayerInfo info;
                if( !PlayerDB.FindPlayerInfo( zoneName.Substring( 1 ), out info ) ) {
                    player.Message( "More than one player found matching \"{0}\"", zoneName.Substring( 1 ) );
                    return;
                }
                if( info == null ) {
                    player.NoPlayerMessage( zoneName.Substring( 1 ) );
                    return;
                }

                zone.Name = info.Name;
                zone.Controller.MinRank = info.Rank.NextRankUp ?? info.Rank;
                zone.Controller.Include( info );
                player.Message( "Zone: Creating a {0}+&S zone for player {1}&S. Place a block or type /mark to use your location.",
                                zone.Controller.MinRank.GetClassyName(), info.GetClassyName() );
                player.SetCallback( 2, ZoneAddCallback, zone, cdZoneAdd.Permissions );

            } else {
                if( !World.IsValidName( zoneName ) ) {
                    player.Message( "\"{0}\" is not a valid zone name", zoneName );
                    return;
                }

                if( player.World.Map.FindZone( zoneName ) != null ) {
                    player.Message( "A zone with this name already exists. Use &H/zedit&S to edit." );
                    return;
                }

                zone.Name = zoneName;

                string rankName = cmd.Next();
                if( rankName == null ) {
                    player.Message( "No rank was specified. See &H/help zone" );
                    return;
                }
                Rank minRank = RankManager.ParseRank( rankName );

                if( minRank != null ) {
                    string name;
                    while( (name = cmd.Next()) != null ) {

                        if( name.Length == 0 ) continue;

                        PlayerInfo info;
                        if( !PlayerDB.FindPlayerInfo( name.Substring( 1 ), out info ) ) {
                            player.Message( "More than one player found matching \"{0}\"", name.Substring( 1 ) );
                            return;
                        }
                        if( info == null ) {
                            player.NoPlayerMessage( name.Substring( 1 ) );
                            return;
                        }

                        if( name.StartsWith( "+" ) ) {
                            zone.Controller.Include( info );
                        } else if( name.StartsWith( "-" ) ) {
                            zone.Controller.Exclude( info );
                        }
                    }

                    zone.Controller.MinRank = minRank;
                    player.SetCallback( 2, ZoneAddCallback, zone, cdZoneAdd.Permissions );
                    player.Message( "Zone: Place a block or type /mark to use your location." );

                } else {
                    player.NoRankMessage( rankName );
                }
            }
        }
Esempio n. 20
0
 static public void getNewZoneID(World world, Zone z) {
 retry:
     foreach (Zone r in world.map.Zones) {
         if (z.ZoneID == r.ZoneID && z.ZoneID < 255) {
             z.ZoneID++;
             goto retry;
         }
     }
 }
Esempio n. 21
0
        static void openDoor(Zone zone, Player player)
        {
            int sx = zone.Bounds.XMin;
            int ex = zone.Bounds.XMax;
            int sy = zone.Bounds.YMin;
            int ey = zone.Bounds.YMax;
            int sz = zone.Bounds.ZMin;
            int ez = zone.Bounds.ZMax;

            Block[] buffer = new Block[zone.Bounds.Volume];

            int counter = 0;
            for (int x = sx; x <= ex; x++) {
                for (int y = sy; y <= ey; y++) {
                    for (int z = sz; z <= ez; z++) {
                        buffer[counter] = player.WorldMap.GetBlock(x, y, z);
                        player.WorldMap.QueueUpdate(new BlockUpdate(null, new Vector3I(x, y, z), Block.Air));
                        counter++;
                    }
                }
            }

            DoorInfo info = new DoorInfo(zone, buffer, player.WorldMap);
            //reclose door
            Scheduler.NewTask(doorTimer_Elapsed).RunOnce(info, DoorCloseTimer);
        }
Esempio n. 22
0
 public static void BlueBase2(Player player)
 {
     Zone BaseBlue2 = new Zone();
        BaseBlue2.Name = "bluebase2";
        player.SelectionStart(2, TFMinecraftHandler.BaseAdd, BaseBlue2, WorldCommands.CdBase.Permissions);
        player.Message("Blue Base 2: Place 2 blocks to cuboid a Blue base");
 }
Esempio n. 23
0
 public DoorInfo(Zone zone, Block[] buffer, Map worldMap)
 {
     Zone = zone;
     Buffer = buffer;
     WorldMap = worldMap;
 }
Esempio n. 24
0
        static void ZoneEditHandler(Player player, Command cmd)
        {
            bool   changesWereMade = false;
            string zoneName        = cmd.Next();

            if (zoneName == null)
            {
                player.Message("No zone name specified. See &H/Help ZEdit");
                return;
            }

            Zone zone = player.WorldMap.Zones.Find(zoneName);

            if (zone == null)
            {
                player.MessageNoZone(zoneName);
                return;
            }

            string name;

            while ((name = cmd.Next()) != null)
            {
                if (name.StartsWith("+"))
                {
                    if (name.Length == 1)
                    {
                        CdZoneEdit.PrintUsage(player);
                        break;
                    }
                    PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, name.Substring(1));
                    if (info == null)
                    {
                        return;
                    }

                    // prevent players from whitelisting themselves to bypass protection
                    if (!player.Info.Rank.AllowSecurityCircumvention && player.Info == info)
                    {
                        if (!zone.Controller.Check(info))
                        {
                            player.Message("You must be {0}+&S to add yourself to this zone's whitelist.",
                                           zone.Controller.MinRank.ClassyName);
                            continue;
                        }
                    }

                    switch (zone.Controller.Include(info))
                    {
                    case PermissionOverride.Deny:
                        player.Message("{0}&S is no longer excluded from zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        changesWereMade = true;
                        break;

                    case PermissionOverride.None:
                        player.Message("{0}&S is now included in zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        changesWereMade = true;
                        break;

                    case PermissionOverride.Allow:
                        player.Message("{0}&S is already included in zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        break;
                    }
                }
                else if (name.StartsWith("-"))
                {
                    if (name.Length == 1)
                    {
                        CdZoneEdit.PrintUsage(player);
                        break;
                    }
                    PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, name.Substring(1));
                    if (info == null)
                    {
                        return;
                    }

                    switch (zone.Controller.Exclude(info))
                    {
                    case PermissionOverride.Deny:
                        player.Message("{0}&S is already excluded from zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        break;

                    case PermissionOverride.None:
                        player.Message("{0}&S is now excluded from zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        changesWereMade = true;
                        break;

                    case PermissionOverride.Allow:
                        player.Message("{0}&S is no longer included in zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        changesWereMade = true;
                        break;
                    }
                }
                else if (name.ToLower().StartsWith("msg="))
                {
                    zone.Message    = name.Substring(4) + " " + (cmd.NextAll() ?? "");
                    changesWereMade = true;
                    player.Message("Zedit: Custom denied messaged changed to '" + zone.Message + "'");
                    break;
                }
                else
                {
                    Rank minRank = RankManager.FindRank(name);

                    if (minRank != null)
                    {
                        // prevent players from lowering rank so bypass protection
                        if (!player.Info.Rank.AllowSecurityCircumvention &&
                            zone.Controller.MinRank > player.Info.Rank && minRank <= player.Info.Rank)
                        {
                            player.Message("You are not allowed to lower the zone's rank.");
                            continue;
                        }

                        if (zone.Controller.MinRank != minRank)
                        {
                            zone.Controller.MinRank = minRank;
                            player.Message("Permission for zone \"{0}\" changed to {1}+",
                                           zone.Name,
                                           minRank.ClassyName);
                            changesWereMade = true;
                        }
                    }
                    else
                    {
                        player.MessageNoRank(name);
                    }
                }
            }
            if (changesWereMade)
            {
                zone.Edit(player.Info);
            }
            else
            {
                player.Message("No changes were made to the zone.");
            }
        }