Ejemplo 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;
            }
        }
        public static void SetParametrization(Player p, Command cmd)
        {
            string strFunc = cmd.Next();
            if (string.IsNullOrWhiteSpace(strFunc))
            {
                p.Message("Error: empty parametrization expression");
                return;
            }
            if (strFunc.Length < 3)
            {
                p.Message("Error: expression is too short (should be like x=f(t,u,v))");
                return;
            }

            strFunc = strFunc.ToLower();

            try
            {
                string coordVar = SimpleParser.PreparseAssignment(ref strFunc);
                CheckCoordVar(coordVar);

                Expression expression = SimpleParser.Parse(strFunc, new string[] { "t", "u", "v" });

                p.Message("Expression parsed as " + coordVar + "=" + expression.Print());

                GetPlayerParametrizationCoordsStorage(p)[VarNameToIdx(coordVar[0])] = expression;
            }
            catch (Exception e)
            {
                p.Message("Error: "+e.Message);
            }
        }
Ejemplo n.º 3
1
        protected FuncDrawOperation(Player player, Command cmd)
            : base(player)
        {
            string strFunc = cmd.Next();
            if (string.IsNullOrWhiteSpace(strFunc))
            {
                player.Message("&WEmpty function expression");
                return;
            }
            if (strFunc.Length < 3)
            {
                player.Message("&WExpression is too short (should be like z=f(x,y))");
                return;
            }

            strFunc = strFunc.ToLower();

            _vaxis = GetAxis(SimpleParser.PreparseAssignment(ref strFunc));

            _expression = SimpleParser.Parse(strFunc, GetVarArray(_vaxis));

            Player.Message("Expression parsed as "+_expression.Print());
            string scalingStr=cmd.Next();
            _scaler = new Scaler(scalingStr);
        }
Ejemplo n.º 4
1
 internal static void CModeWater(Player player, Command cmd)
 {
     if (!player.Can(Permissions.ControlPhysics))
     {
         player.NoAccessMessage(Permissions.ControlPhysics);
         return;
     }
     string blockpar = cmd.Next();
     string wmt = "";
     int BlockAddr = -1;
     try { BlockAddr = Convert.ToInt32(blockpar); }
     catch
     {
         player.Message("Incorrect parameter!"); return;
     }
     if (BlockAddr < 3 && BlockAddr >= 0)
     {
         player.world.map.modeWater = BlockAddr;
         switch (BlockAddr)
         {
             case 0: wmt = "'none'"; break;
             case 1: wmt = "'infinite'"; break;
             case 2: wmt = "'finite'"; break;
         }
         player.Message("Water mode set to " + wmt + ".");
     }
 }
Ejemplo n.º 5
1
        static void PayHandler(Player player, Command cmd)
        {
            string targetName = cmd.Next();
            string money = cmd.Next();
            int amount;

            if (money == null)
            {
                player.Message("&ePlease select the amount of bits you wish to send.");
                return;
            }

            Player target = Server.FindPlayerOrPrintMatches(player, targetName, false, true);
            if (target == null)
            {
                player.Message("&ePlease select a player to pay bits towards.");
                return;
            }

            if (!int.TryParse(money, out amount))
            {
                player.Message("&ePlease select from a whole number.");
                return;
            }

            PayHandler(player, new Command("/economy pay " + target + " " + money));
        }
Ejemplo n.º 6
1
 void Paint( Player player, Command cmd ) {
     player.replaceMode = !player.replaceMode;
     if( player.replaceMode ){
         player.Message( "Replacement mode: ON" );
     } else {
         player.Message( "Replacement mode: OFF" );
     }
 }
Ejemplo n.º 7
1
 public void PrintUsage( Player player ) {
     if( player == null ) throw new ArgumentNullException( "player" );
     if( Usage != null ) {
         player.Message( "Usage: &H{0}", Usage );
     } else {
         player.Message( "Usage: &H/{0}", Name );
     }
 }
		public static void SetParamIteration(Player p, CommandReader cmd)
		{
			string strParam = cmd.Next();
			if (string.IsNullOrWhiteSpace(strParam))
			{
				p.Message("Error: missing param variable name");
				return;
			}

			strParam = strParam.ToLower();

			try
			{
				CheckParamVar(strParam);

				double from = ReadDoubleParam(cmd, "lower bound");
				double to = ReadDoubleParam(cmd, "upper bound");
				double step = ReadDoubleParam(cmd, "step");

				if (step == 0 ||
				    (to - from)/step < 0)
					throw new ArgumentException("wrong iteration bounds/step combination");

				p.Message("Iteration for " + strParam + " from " + from + " to " + to + " with step " + step + ". " +
				          ((to - from)/step + 1) + " steps.");

				GetPlayerParametrizationParamsStorage(p)[VarNameToIdx(strParam[0])] = new double[] {from, to, step};
			}
			catch (Exception e)
			{
				p.Message("Error: " + e.Message);
			}
		}
Ejemplo n.º 9
1
 internal static void CancelDraw( Player player, Command command )
 {
     if( player.marksExpected > 0 ) {
         player.marksExpected = 0;
     } else {
         player.Message( "There is currently nothing to cancel." );
     }
 }
Ejemplo n.º 10
0
        void Compass( Player player, Command cmd ) {
            int offset = (int)(player.pos.r / 255f * 64f) + 32;
            string name = cmd.Next();

            if( name != null ) {
                Player target = world.FindPlayer( name );
                if( target != null ) {
                    player.Message( "Coordinates of player \"" + target.name + "\":" );
                    offset = (int)(target.pos.r / 255f * 64f) + 32;
                } else {
                    world.NoPlayerMessage( player, name );
                    return;
                }
            }

            player.Message( Color.Silver, String.Format( "({0},{1},{2}) - {3}[{4}{5}{6}{3}{7}]",
                            player.pos.x / 32,
                            player.pos.y / 32,
                            player.pos.h / 32,
                            Color.White,
                            compass.Substring( offset - 12, 11 ),
                            Color.Red,
                            compass.Substring( offset - 1, 3 ),
                            compass.Substring( offset + 2, 11 ) ) );
        }
Ejemplo n.º 11
0
 static void BumHandler(Player player, CommandReader cmd)
 {
     string newModeName = cmd.Next();
     if (newModeName == null)
     {
         player.Message("&sBytes Sent: {0}  Per Second: {1:0.0}", player.BytesSent, player.BytesSentRate);
         player.Message("&sBytes Received: {0}  Per Second: {1:0.0}", player.BytesReceived, player.BytesReceivedRate);
         player.Message("&sBandwidth mode: {0}",player.BandwidthUseMode);
                         
                         
                         
         return;
     }
     else if (player.Can(Permission.EditPlayerDB))
     {
         var newMode = (BandwidthUseMode)Enum.Parse(typeof(BandwidthUseMode), newModeName, true);
         player.Message("&sBandwidth mode: {0} --> {1}", player.BandwidthUseMode, newMode.ToString());
         player.BandwidthUseMode = newMode;
         player.Info.BandwidthUseMode = newMode;
         return;
     }
     else
     {
         player.Message("You need {0}&s to change your BandwidthUseMode", RankManager.GetMinRankWithAnyPermission(Permission.EditPlayerDB).ClassyName);
         return;
     }
     
 }
Ejemplo n.º 12
0
        private static void TrollHandler( Player player, CommandReader cmd ) {
            string Name = cmd.Next();
            if ( Name == null ) {
                player.Message( "Player not found. Please specify valid name." );
                return;
            }
            if ( !Player.IsValidPlayerName( Name ) )
                return;
            Player target = Server.FindPlayerOrPrintMatches( player, Name, SearchOptions.Default );
            if ( target == null )
                return;
            string options = cmd.Next();
            if ( options == null ) {
                CdTroll.PrintUsage( player );
                return;
            }
            string Message = cmd.NextAll();
            if ( Message.Length < 1 && options.ToLower() != "leave" ) {
                player.Message( "&WError: Please enter a message for {0}.", target.ClassyName );
                return;
            }
            switch ( options.ToLower() ) {
                case "pm":
                    if ( player.Can( Permission.UseColorCodes ) && Message.Contains( "%" ) ) {
                        Message = Chat.ReplacePercentColorCodes( Message, false );
                    }
                    Server.Players.Message( "&Pfrom {0}: {1}",
                        target.Name, Message );
                    break;

                case "st":
                case "staff":
                    Chat.SendStaff( target, Message );
                    break;

                case "i":
                case "impersonate":
                case "msg":
                case "message":
                case "m":
                    Server.Message( "{0}&S&F: {1}",
                                      target.ClassyName, Message );
                    break;

                case "leave":
                case "disconnect":
                case "gtfo":
                    Server.Players.Message( "&SPlayer {0}&S left the server.",
                        target.ClassyName );
                    break;

                default:
                    player.Message( "Invalid option. Please choose st, ac, pm, message or leave" );
                    break;
            }
        }
Ejemplo n.º 13
0
 void Solid( Player player, Command cmd ) {
     if( player.mode == BlockPlacementMode.Solid ){
         player.mode = BlockPlacementMode.Normal;
         player.Message( "Solid: OFF" );
     } else if( player.Can( Permissions.PlaceAdmincrete ) ) {
         player.mode = BlockPlacementMode.Solid;
         player.Message( "Solid: ON" );
     } else {
         world.NoAccessMessage( player );
     }
 }
Ejemplo n.º 14
0
 void Water( Player player, Command cmd ) {
     if( player.mode == BlockPlacementMode.Water ) {
         player.mode = BlockPlacementMode.Normal;
         player.Message( "Water: OFF" );
     } else if( player.Can( Permissions.PlaceWater ) ) {
         player.mode = BlockPlacementMode.Water;
         player.Message( "Water: ON. Blue blocks are replaced with water." );
     } else {
         world.NoAccessMessage( player );
     }
 }
Ejemplo n.º 15
0
 void Lava( Player player, Command cmd ) {
     if( player.mode == BlockPlacementMode.Lava ) {
         player.mode = BlockPlacementMode.Normal;
         player.Message( "Lava: OFF." );
     } else if( player.Can( Permissions.PlaceWater ) ) {
         player.mode = BlockPlacementMode.Lava;
         player.Message( "Lava: ON. Red blocks are replaced with lava." );
     } else {
         world.NoAccessMessage( player );
     }
 }
Ejemplo n.º 16
0
 void Grass( Player player, Command cmd ) {
     if( player.mode == BlockPlacementMode.Grass ) {
         player.mode = BlockPlacementMode.Normal;
         player.Message( "Grass: OFF" );
     } else if( player.Can( Permissions.PlaceGrass ) ) {
         player.mode = BlockPlacementMode.Grass;
         player.Message( "Grass: ON. Dirt blocks are replaced with grass." );
     } else {
         world.NoAccessMessage( player );
     }
 }
Ejemplo n.º 17
0
 internal static void Hardened(Player player, Command cmd)
 {
     if (player.hardenedMode == BlockPlacementMode.Hardened) {
         player.hardenedMode = BlockPlacementMode.Normal;
         player.Message("Hardened blocks: OFF");
     } else if (player.Can(Permissions.PlaceHardenedBlocks)) {
         player.hardenedMode = BlockPlacementMode.Hardened;
         player.Message("Hardened blocks: ON");
     } else {
         player.NoAccessMessage( Permissions.PlaceHardenedBlocks );
     }
 }
Ejemplo n.º 18
0
        internal static void WorldInfo( Player player, Command cmd ) {
            string worldName = cmd.Next();
            if( worldName == null ) {
                if( player.World == null ) {
                    player.Message( "Please specify a world name when calling /winfo form console." );
                    return;
                } else {
                    worldName = player.World.Name;
                }
            }

            World world = WorldManager.FindWorldOrPrintMatches( player, worldName );
            if( world == null ) return;

            player.Message( "World {0}&S has {1} player(s) on.",
                            world.GetClassyName(),
                            world.CountVisiblePlayers(player) );

            Map map = world.Map;

            // If map is not currently loaded, grab its header from disk
            if( map == null ) {
                try {
                    map = MapUtility.LoadHeader( Path.Combine( Paths.MapPath, world.GetMapName() ) );
                } catch( Exception ex ) {
                    player.Message( "Map information could not be loaded: {0}: {1}",
                                    ex.GetType().Name, ex.Message );
                }
            }

            if( map != null ) {
                player.Message( "Map dimensions are {0} x {1} x {2}",
                                map.WidthX, map.WidthY, map.Height );
            }

            // Print access/build limits
            world.AccessSecurity.PrintDescription( player, world, "world", "accessed" );
            world.BuildSecurity.PrintDescription( player, world, "world", "modified" );

            // Print lock/unlock information
            if( world.IsLocked ) {
                player.Message( "{0}&S was locked {1} ago by {2}",
                                world.GetClassyName(),
                                DateTime.UtcNow.Subtract( world.LockedDate ).ToMiniString(),
                                world.LockedBy );
            } else if( world.UnlockedBy != null ) {
                player.Message( "{0}&S was unlocked {1} ago by {2}",
                                world.GetClassyName(),
                                DateTime.UtcNow.Subtract( world.UnlockedDate ).ToMiniString(),
                                world.UnlockedBy );
            }
        }
Ejemplo n.º 19
0
 internal void ParseCommand( Player player, string message, bool fromConsole ) {
     Command cmd = new Command( message );
     if( consoleSafeHandlers.ContainsKey( cmd.name ) ) {
         consoleSafeHandlers[cmd.name]( player, cmd );
     } else if( handlers.ContainsKey( cmd.name ) ) {
         if( fromConsole ) {
             player.Message( "You cannot use this command from console." );
         } else {
             handlers[cmd.name]( player, cmd );
         }
     } else {
         player.Message( "Unrecognized command: " + cmd.name );
     }
 }
Ejemplo n.º 20
0
 public static void ProcessCommand( Player p, Command cmd )
 {
     string command = cmd.Next();
     if ( String.IsNullOrWhiteSpace( command ) ) {
         p.Message( "&WLife command is missing or empty" );
         return;
     }
     LifeCommand c;
     if ( !Commands.TryGetValue( command.ToLower(), out c ) ) {
         p.Message( "&WUnknown life command " + command + ". &hType '/life help' for the list of commands." );
         return;
     }
     c.F( p, cmd );
 }
Ejemplo n.º 21
0
 static void BanHandler( Player player, CommandReader cmd ) {
     string targetName = cmd.Next();
     if( targetName == null ) {
         CdBan.PrintUsage( player );
         return;
     }
     PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches( player,
                                                                targetName,
                                                                SearchOptions.ReturnSelfIfOnlyMatch );
     if( target == null ) return;
     if( target == player.Info ) {
         player.Message( "You cannot &H/Ban&S yourself." );
         return;
     }
     string reason = cmd.NextAll();
     try {
         Player targetPlayer = target.PlayerObject;
         target.Ban( player, reason, true, true );
         WarnIfOtherPlayersOnIP( player, target, targetPlayer );
     } catch( PlayerOpException ex ) {
         player.Message( ex.MessageColored );
         if( ex.ErrorCode == PlayerOpExceptionCode.ReasonRequired ) {
             FreezeIfAllowed( player, target );
         }
     }
 }
Ejemplo n.º 22
0
 public static void AssignBlue(Player p)
 {
     string sbName = p.Name;
     p.Message("Let the games Begin!");
     p.Message("You are on the &1Blue Team");
     p.iName = "TeamBlue";
     p.Info.tempDisplayedName = "&f(" + blueTeam + "&f) " + Color.Navy + sbName;
     p.Info.isOnBlueTeam = true;
     p.Info.isOnRedTeam = false;
     p.Info.isPlayingTD = true;
     p.entityChanged = true;
     p.Info.gameKills = 0;
     p.Info.gameDeaths = 0;
     blueTeamCount++;
     return;
 }
Ejemplo n.º 23
0
        internal static void DumpStats( Player player, Command cmd ) {
            string fileName = cmd.Next();
            if( fileName == null ) {
                cdDumpStats.PrintUsage( player );
                return;
            }

            if( !Paths.Contains( Paths.WorkingPath, fileName ) ) {
                player.UnsafePathMessage();
                return;
            }

            if( Paths.IsProtectedFileName( Path.GetFileName( fileName ) ) ) {
                player.Message( "You may not use this file." );
                return;
            }

            if( Path.HasExtension( fileName ) &&
                !Path.GetExtension( fileName ).Equals( ".txt", StringComparison.OrdinalIgnoreCase ) ) {
                player.Message( "Stats filename must end with .txt" );
                return;
            }

            if( File.Exists( fileName ) && !cmd.IsConfirmed ) {
                player.AskForConfirmation( cmd, "File \"{0}\" already exists. Overwrite?", Path.GetFileName( fileName ) );
                return;
            }

            if( !Paths.TestFile( "dumpstats file", fileName, false, true, false ) ) {
                player.Message( "Cannot create specified file. See log for details." );
                return;
            }

            PlayerInfo[] infos;
            using( FileStream fs = File.Create( fileName ) ) {
                using( StreamWriter writer = new StreamWriter( fs ) ) {
                    infos = PlayerDB.GetPlayerListCopy();
                    if( infos.Length == 0 ) {
                        writer.WriteLine( "{0} (0 players)", "(TOTAL)" );
                        writer.WriteLine();
                    } else {
                        DumpPlayerGroupStats( writer, infos, "(TOTAL)" );
                    }

                    foreach( Rank rank in RankManager.Ranks ) {
                        infos = PlayerDB.GetPlayerListCopy( rank );
                        if( infos.Length == 0 ) {
                            writer.WriteLine( "{0} (0 players)", rank.Name );
                            writer.WriteLine();
                        } else {
                            DumpPlayerGroupStats( writer, infos, rank.Name );
                        }
                    }
                }
            }

            player.Message( "Stats saved to \"{0}\"", Path.GetFileName( fileName ) );
        }
Ejemplo n.º 24
0
        internal static void Colors( Player player, Command cmd ) {
            StringBuilder sb = new StringBuilder( "List of colors: " );

            foreach( var color in Color.ColorNames ) {
                sb.AppendFormat( "&{0}%{0} {1} ", color.Key, color.Value );
            }

            player.Message( sb.ToString() );
        }
Ejemplo n.º 25
0
        public override MapGeneratorParameters CreateParameters( Player player, CommandReader cmd ) {
            string themeName = cmd.Next();
            if( themeName == null ) {
                return CreateDefaultParameters();
            }

            MapGenTheme theme;
            RealisticMapGenTerrainType terrainType;

            string templateName = cmd.Next();
            if( templateName == null ) {
                player.Message( "SetGen: Realistic MapGen requires both a theme and a terrainType. " +
                                "See &H/Help SetGen Realistic&S or check wiki.fCraft.net for details" );
                return null;
            }

            // parse theme
            bool swapThemeAndTemplate;
            if( EnumUtil.TryParse( themeName, out theme, true ) ) {
                swapThemeAndTemplate = false;

            } else if( EnumUtil.TryParse( templateName, out theme, true ) ) {
                swapThemeAndTemplate = true;

            } else {
                player.Message( "SetGen: Unrecognized theme \"{0}\". Available themes are: {1}",
                                themeName,
                                Enum.GetNames( typeof( MapGenTheme ) ).JoinToString() );
                return null;
            }

            // parse terrainType
            if( swapThemeAndTemplate && !EnumUtil.TryParse( themeName, out terrainType, true ) ) {
                MessageTemplateList( themeName, player );
                return null;
            } else if( !EnumUtil.TryParse( templateName, out terrainType, true ) ) {
                MessageTemplateList( templateName, player );
                return null;
            }

            // TODO: optional parameters for preset customization
            return CreateParameters( terrainType, theme );
        }
Ejemplo n.º 26
0
        public static void test(Player player, Command cmd)
        {
            if (!File.Exists("C:/users/jb509/desktop/1.schematic"))
            {
                player.Message("Nop"); return;
            }
            NbtFile file = new NbtFile("C:/users/jb509/desktop/1.schematic");
            file.RootTag = new NbtCompound("Schematic");
            file.LoadFile();
            bool notClassic = false;
            short width = file.RootTag.Query<NbtShort>("/Schematic/Width").Value;
            short height = file.RootTag.Query<NbtShort>("/Schematic/Height").Value;
            short length = file.RootTag.Query<NbtShort>("/Schematic/Length").Value;
            Byte[] blocks = file.RootTag.Query<NbtByteArray>("/Schematic/Blocks").Value;

            Vector3I pos = player.Position.ToBlockCoords();
            int i = 0;
            player.Message("&SDrawing Schematic ({0}x{1}x{2})", length, width, height);
            for (int x = pos.X; x < width + pos.X; x++)
            {
                for (int y = pos.Y; y < length + pos.Y; y++)
                {
                    for (int z = pos.Z; z < height + pos.Z; z++)
                    {
                        if (Enum.Parse(typeof(Block), ((Block)blocks[i]).ToString(), true) != null)
                        {
                            if (!notClassic && blocks[i] > 49)
                            {
                                notClassic = true;
                                player.Message("&WSchematic used is not designed for Minecraft Classic;" +
                                                " Converting all unsupported blocks with air");
                            }
                            if (blocks[i] < 50)
                            {
                                player.WorldMap.QueueUpdate(new BlockUpdate(null, (short)x, (short)y, (short)z, (Block)blocks[i]));
                            }
                        }
                        i++;
                    }
                }
            }
            file.Dispose();
        }
Ejemplo n.º 27
0
 private static void ModelHandler(Player player, CommandReader cmd) {
     PlayerInfo otherPlayer = InfoCommands.FindPlayerInfo(player, cmd, cmd.Next() ?? player.Name);
     if (otherPlayer == null) return;
      
     if (!player.IsStaff && otherPlayer != player.Info) {
         Rank staffRank = RankManager.GetMinRankWithAnyPermission(Permission.ReadStaffChat);
         if (staffRank != null) {
             player.Message("You must be {0}&s+ to change another players Model", staffRank.ClassyName);
         } else {
             player.Message("No ranks have the ReadStaffChat permission so no one can change other players Model, yell at the owner.");
         }
         return;
     }
     if (otherPlayer.Rank.Index < player.Info.Rank.Index) {
         player.Message("Cannot change the Model of someone higher rank than you.");
         return;
     }
     if (otherPlayer == null) {
         player.Message("Your current Model: &f" + player.Info.Mob);
         return;
     }
     string model = cmd.Next();
     if (string.IsNullOrEmpty(model)) {
         player.Message("Current Model for {0}: &f{1}", otherPlayer.Name, otherPlayer.Mob);
         return;
     }
     if (otherPlayer.IsOnline && otherPlayer.Rank.Index >= player.Info.Rank.Index) {
         if (!validEntities.Contains(model.ToLower())) {
             Block block;
             if (Map.GetBlockByName(model, false, out block)) {
                 model = block.GetHashCode().ToString();
             } else {
                 player.Message("Model not valid, see &h/Help Model&s.");
                 return;
             }
         }
         if (otherPlayer.Mob.ToLower() == model.ToLower()) {
             player.Message("&f{0}&s's model is already set to &f{1}", otherPlayer.Name, model);
             return;
         }
         if (otherPlayer.IsOnline) {
             otherPlayer.PlayerObject.Message("&f{0}&shanged your model from &f{1} &sto &f{2}", (otherPlayer.PlayerObject == player ? "&sC" : player.Name + " &sc"), otherPlayer.Mob, model);
         }
         if (otherPlayer.PlayerObject != player) {
             player.Message("&sChanged model of &f{0} &sfrom &f{1} &sto &f{2}", otherPlayer.Name, otherPlayer.Mob, model);
         }
         otherPlayer.oldMob = otherPlayer.Mob;
         otherPlayer.Mob = model;
     } else {
         player.Message("Player not found/online or lower rank than you");
     }
 }
Ejemplo n.º 28
0
        void Load( Player player, Command cmd ) {
            lock( loadLock ) {
                if( world.loadInProgress || world.loadSendingInProgress ) {
                    player.Message( "Loading already in progress, please wait." );
                    return;
                }
                world.loadInProgress = true;
            }

            if( !player.Can( Permissions.SaveAndLoad ) ) {
                world.NoAccessMessage( player );
                world.loadInProgress = false;
                return;
            }

            string mapName = cmd.Next();
            if( mapName == null ) {
                player.Message( "Syntax: " + Color.Help + "/load mapName" );
                world.loadInProgress = false;
                return;
            }

            string mapFileName = mapName + ".fcm";
            if( !File.Exists( mapFileName ) ) {
                player.Message( "No backup file \"" + mapName + "\" found." );
                world.loadInProgress = false;
                return;
            }

            Map newMap = Map.Load( world, mapFileName );
            if( newMap == null ) {
                player.Message( "Could not load \"" + mapFileName + "\". Check logfile for details." );
                world.loadInProgress = false;
                return;
            }

            if( newMap.widthX != world.map.widthX ||
                newMap.widthY != world.map.widthY ||
                newMap.height != world.map.height ) {
                player.Message( "Map sizes of \"" + mapName + "\" and the current map do not match." );
                world.loadInProgress = false;
                return;
            }

            world.log.Log( "{0} is loading the map \"{1}\".", LogType.UserActivity, player.name, mapName );
            player.Message( "Loading map \"" + mapName + "\"..." );
            world.BeginLockDown();
            MapSenderParams param = new MapSenderParams() {
                map = newMap,
                player = player,
                world = world
            };
            world.tasks.Add( MapSender.StreamLoad, param, true );
        }
Ejemplo n.º 29
0
        public EqualityDrawOperation( Player player, Command cmd )
            : base(player)
        {
            string strFunc = cmd.Next();
            if ( string.IsNullOrWhiteSpace( strFunc ) ) {
                player.Message( "empty equality expression" );
                return;
            }
            if ( strFunc.Length < 3 ) {
                player.Message( "expression is too short (should be like f(x,y,z)=g(x,y,z))" );
                return;
            }

            strFunc = strFunc.ToLower();

            _expression = SimpleParser.ParseAsEquality( strFunc, new string[] { "x", "y", "z" } );

            player.Message( "Expression parsed as " + _expression.Print() );
            string scalingStr = cmd.Next();
            _scaler = new Scaler( scalingStr );
        }
Ejemplo n.º 30
0
 public static void AssignBlue(Player p)
 {
     p.Message("You are on the &9Blue Team");
     p.iName = "TeamBlue";
     p.Info.tempDisplayedName = "&f(" + blueTeam + "&f) " + Color.Navy + p.Name;
     p.Info.CTFBlueTeam = true;
     p.Info.CTFRedTeam = false;
     p.Info.isPlayingCTF = true;
     p.entityChanged = true;
     blueTeamCount++;
     return;
 }
Ejemplo n.º 31
0
        public static void coords(Player player)
        {
            Vector3I Blockcoords = player.Position.ToBlockCoords();

            player.Message("Your current coordinates are " + Blockcoords + ".");
        }
Ejemplo n.º 32
0
        /// <summary> Sends a global (white) chat. </summary>
        /// <param name="player"> Player writing the message. </param>
        /// <param name="rawMessage"> Message text. </param>
        /// <returns> True if message was sent, false if it was cancelled by an event callback. </returns>
        public static bool SendGlobal([NotNull] Player player, [NotNull] string rawMessage)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (rawMessage == null)
            {
                throw new ArgumentNullException("rawMessage");
            }
            string OriginalMessage = rawMessage;

            if (Server.Moderation && !Server.VoicedPlayers.Contains(player) && player.World != null)
            {
                player.Message("&WError: Server Moderation is activated. Message failed to send");
                return(false);
            }
            rawMessage = rawMessage.Replace("$name", player.ClassyName);
            rawMessage = rawMessage.Replace("$kicks", player.Info.TimesKickedOthers.ToString());
            rawMessage = rawMessage.Replace("$bans", player.Info.TimesBannedOthers.ToString());
            rawMessage = rawMessage.Replace("$awesome",
                                            "It is my professional opinion, that " + ConfigKey.ServerName.GetString() +
                                            " is the best server on Minecraft");
            rawMessage = rawMessage.Replace("$server", ConfigKey.ServerName.GetString());
            rawMessage = rawMessage.Replace("$motd", ConfigKey.MOTD.GetString());
            rawMessage = rawMessage.Replace("$date", DateTime.UtcNow.ToShortDateString());
            rawMessage = rawMessage.Replace("$time", DateTime.Now.ToString());
            rawMessage = rawMessage.Replace("$money", player.Info.Money.ToString());

            if (!player.Can(Permission.ChatWithCaps))
            {
                int caps = 0;
                for (int i = 0; i < rawMessage.Length; i++)
                {
                    if (Char.IsUpper(rawMessage[i]))
                    {
                        caps++;
                        if (caps > ConfigKey.MaxCaps.GetInt())
                        {
                            rawMessage = rawMessage.ToLower();
                            player.Message(
                                "Your message was changed to lowercase as it exceeded the maximum amount of capital letters.");
                        }
                    }
                }
            }

            if (!player.Can(Permission.Swear))
            {
                if (!File.Exists("SwearWords.txt"))
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("#This txt file should be filled with bad words that you want to be filtered out");
                    sb.AppendLine("#I have included some examples, excuse my language :P");
                    sb.AppendLine("f**k");
                    sb.AppendLine("f*****g");
                    sb.AppendLine("f****d");
                    sb.AppendLine("dick");
                    sb.AppendLine("bitch");
                    sb.AppendLine("shit");
                    sb.AppendLine("s******g");
                    sb.AppendLine("s******d");
                    sb.AppendLine("c**t");
                    sb.AppendLine("nigger");
                    sb.AppendLine("wanker");
                    sb.AppendLine("wank");
                    sb.AppendLine("wanking");
                    sb.AppendLine("piss");
                    File.WriteAllText("SwearWords.txt", sb.ToString());
                }
                string CensoredText = Color.ReplacePercentCodes(ConfigKey.SwearName.GetString()) + Color.White;
                if (ConfigKey.SwearName.GetString() == null)
                {
                    CensoredText = "&CBlock&F";
                }

                const string       PatternTemplate = @"\b({0})(s?)\b";
                const RegexOptions Options         = RegexOptions.IgnoreCase;

                if (Swears.Count == 0)
                {
                    Swears.AddRange(File.ReadAllLines("SwearWords.txt").
                                    Where(line => line.StartsWith("#") == false || line.Trim().Equals(String.Empty)));
                }

                if (badWordMatchers == null)
                {
                    badWordMatchers = Swears.
                                      Select(x => new Regex(string.Format(PatternTemplate, x), Options));
                }

                string output = badWordMatchers.
                                Aggregate(rawMessage, (current, matcher) => matcher.Replace(current, CensoredText));
                rawMessage = output;
            }

            var recepientList = Server.Players.NotIgnoring(player);

            string formattedMessage = String.Format("{0}&F: {1}",
                                                    player.ClassyName,
                                                    rawMessage);

            var e = new ChatSendingEventArgs(player,
                                             rawMessage,
                                             formattedMessage,
                                             ChatMessageType.Global,
                                             recepientList);

            if (!SendInternal(e))
            {
                return(false);
            }

            Logger.Log(LogType.GlobalChat,
                       "{0}: {1}", player.Name, OriginalMessage);
            return(true);
        }
Ejemplo n.º 33
0
        public Map AcceptPlayer([NotNull] Player player, bool announce)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }

            lock ( SyncRoot ) {
                if (IsFull)
                {
                    if (player.Info.Rank.HasReservedSlot)
                    {
                        Player idlestPlayer = Players.Where(p => p.Info.Rank.IdleKickTimer != 0)
                                              .OrderBy(p => p.LastActiveTime)
                                              .FirstOrDefault();
                        if (idlestPlayer != null)
                        {
                            idlestPlayer.Kick(Player.Console, "Auto-kicked to make room (idle).",
                                              LeaveReason.IdleKick, false, false, false);

                            Server.Players
                            .CanSee(player)
                            .Message("&SPlayer {0}&S was auto-kicked to make room for {1}",
                                     idlestPlayer.ClassyName, player.ClassyName);
                            Server.Players
                            .CantSee(player)
                            .Message("{0}&S was kicked for being idle for {1} min",
                                     player.ClassyName, player.Info.Rank.IdleKickTimer);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }

                if (playerIndex.ContainsKey(player.Name.ToLower()))
                {
                    Logger.Log(LogType.Error,
                               "This world already contains the player by name ({0}). " +
                               "Some sort of state corruption must have occurred.",
                               player.Name);
                    playerIndex.Remove(player.Name.ToLower());
                }

                playerIndex.Add(player.Name.ToLower(), player);

                // load the map, if it's not yet loaded
                IsPendingMapUnload = false;
                Map = LoadMap();

                if (ConfigKey.BackupOnJoin.Enabled() && (HasChangedSinceBackup || !ConfigKey.BackupOnlyWhenChanged.Enabled()))
                {
                    string backupFileName = String.Format(JoinBackupFormat,
                                                          Name, DateTime.Now, player.Name);   // localized
                    SaveBackup(Path.Combine(Paths.BackupPath, backupFileName));
                }

                UpdatePlayerList();

                if (announce && ConfigKey.ShowJoinedWorldMessages.Enabled())
                {
                    Server.Players.CanSee(player)
                    .Message("&SPlayer {0}&S joined {1}",
                             player.ClassyName, ClassyName);
                }

                Logger.Log(LogType.UserActivity,
                           "Player {0} joined world {1}.",
                           player.Name, Name);

                if (IsLocked)
                {
                    player.Message("&WThis map is currently locked (read-only).");
                }

                if (player.Info.IsHidden)
                {
                    player.Message("&8Reminder: You are still hidden.");
                }

                return(Map);
            }
        }
Ejemplo n.º 34
0
        /// <summary> Parses next parameter as a Minecraft block name.
        /// Allows an optional integer parameter to follow the block name after a slash, e.g. "BlockName/#"
        /// Messages warnings directly to the player in case of problems. </summary>
        /// <param name="player"> Player to send warnings to (if any come up). </param>
        /// <param name="allowNoneBlock"> Whether "none"/"skip" blocktype is allowed. </param>
        /// <param name="block"> On success, this is set to the given block type.
        /// On failure, this is set to Block.None </param>
        /// <param name="param"> Optional integer parameter. Set to 1 if not given. </param>
        /// <returns> True on success.
        /// False if no more parameters were given;
        /// if next parameter could not be parsed as a block name;
        /// if optional parameter was given but was not an integer;
        /// or if "none" blocktype was given and allowNoneBlock is false. </returns>
        public bool NextBlockWithParam([CanBeNull] Player player, bool allowNoneBlock, out Block block, out int param)
        {
            block = Block.None;
            param = 1;

            string jointString = Next();

            if (jointString == null)
            {
                return(false);
            }

            int slashIndex = jointString.IndexOf('/');

            if (slashIndex != -1)
            {
                string blockName   = jointString.Substring(0, slashIndex);
                string paramString = jointString.Substring(slashIndex + 1);

                if (Map.GetBlockByName(blockName, true, out block))
                {
                    if (block == Block.None && !allowNoneBlock)
                    {
                        if (player != null)
                        {
                            player.Message("The \"none\" block is not allowed here");
                        }
                    }
                    else if (Int32.TryParse(paramString, out param))
                    {
                        return(true);
                    }
                    else if (player != null)
                    {
                        player.Message("Could not parse \"{0}\" as an integer.", paramString);
                    }
                }
                else if (player != null)
                {
                    player.Message("Unrecognized blocktype \"{0}\"", blockName);
                }
            }
            else
            {
                if (Map.GetBlockByName(jointString, true, out block))
                {
                    if (block != Block.None || allowNoneBlock)
                    {
                        return(true);
                    }
                    else if (player != null)
                    {
                        player.Message("The \"none\" block is not allowed here");
                    }
                }
                else if (player != null)
                {
                    player.Message("Unrecognized blocktype \"{0}\"", jointString);
                }
            }
            return(false);
        }
Ejemplo n.º 35
0
 static void DoorCheckH(Player player, Command cmd)
 {
     player.Message("Left click to select a door.");
     player.Info.isDoorChecking = true;
     player.Info.doorCheckTime  = DateTime.Now;
 }
Ejemplo n.º 36
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.");
            }
        }
Ejemplo n.º 37
0
 static void ZoneTestHandler(Player player, Command cmd)
 {
     player.SelectionStart(1, ZoneTestCallback, null);
     player.Message("Click the block that you would like to test.");
 }
Ejemplo n.º 38
0
        /// <summary> Sends a global(white) chat. </summary>
        /// <param name="player"> Player writing the message. </param>
        /// <param name="rawMessage"> Message text. </param>
        /// <returns> True if message was sent, false if it was cancelled by an event callback. </returns>
        public static bool SendGlobal([NotNull] Player player, [NotNull] string rawMessage)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (rawMessage == null)
            {
                throw new ArgumentNullException("rawMessage");
            }
            string OriginalMessage = rawMessage;

            rawMessage = rawMessage.Replace("$name", player.ClassyName + "&f");
            rawMessage = rawMessage.Replace("$kicks", player.Info.TimesKickedOthers.ToString());
            rawMessage = rawMessage.Replace("$bans", player.Info.TimesBannedOthers.ToString());
            rawMessage = rawMessage.Replace("$awesome", "It is my professional opinion, that " + ConfigKey.ServerName.GetString() + " is the best server on Minecraft");
            rawMessage = rawMessage.Replace("$server", ConfigKey.ServerName.GetString());
            rawMessage = rawMessage.Replace("$motd", ConfigKey.MOTD.GetString());
            rawMessage = rawMessage.Replace("$date", DateTime.UtcNow.ToShortDateString());
            rawMessage = rawMessage.Replace("$time", DateTime.Now.ToString());
            rawMessage = rawMessage.Replace("$money", player.Info.Money.ToString());
            rawMessage = rawMessage.Replace("$ass", "You, my good sir, are an &cAss&f");
            rawMessage = rawMessage.Replace("$mad", "U &cmad&f, bro?");
            rawMessage = rawMessage.Replace("$welcome", "Welcome to " + ConfigKey.ServerName.GetString());
            rawMessage = rawMessage.Replace("$clap", "A round of applause might be appropriate, *claps*");
            rawMessage = rawMessage.Replace("$website", ConfigKey.WebsiteURL.GetString());
            rawMessage = rawMessage.Replace("$ws", ConfigKey.WebsiteURL.GetString());

            if (ConfigKey.IRCBotEnabled.Enabled())
            {
                rawMessage = rawMessage.Replace("$irc", ConfigKey.IRCBotChannels.GetString());
            }
            else
            {
                rawMessage = rawMessage.Replace("$irc", "No IRC");
            }

            if (player.Can(Permission.UseColorCodes))
            {
                rawMessage = rawMessage.Replace("$lime", "&a");                  //alternate color codes for ease if you can't remember the codes
                rawMessage = rawMessage.Replace("$aqua", "&b");
                rawMessage = rawMessage.Replace("$cyan", "&b");
                rawMessage = rawMessage.Replace("$red", "&c");
                rawMessage = rawMessage.Replace("$magenta", "&d");
                rawMessage = rawMessage.Replace("$pink", "&d");
                rawMessage = rawMessage.Replace("$yellow", "&e");
                rawMessage = rawMessage.Replace("$white", "&f");
                rawMessage = rawMessage.Replace("$navy", "&1");
                rawMessage = rawMessage.Replace("$darkblue", "&1");
                rawMessage = rawMessage.Replace("$green", "&2");
                rawMessage = rawMessage.Replace("$teal", "&3");
                rawMessage = rawMessage.Replace("$maroon", "&4");
                rawMessage = rawMessage.Replace("$purple", "&5");
                rawMessage = rawMessage.Replace("$olive", "&6");
                rawMessage = rawMessage.Replace("$gold", "&6");
                rawMessage = rawMessage.Replace("$silver", "&7");
                rawMessage = rawMessage.Replace("$grey", "&8");
                rawMessage = rawMessage.Replace("$gray", "&8");
                rawMessage = rawMessage.Replace("$blue", "&9");
                rawMessage = rawMessage.Replace("$black", "&0");
            }

            if (!player.Can(Permission.ChatWithCaps))
            {
                int caps = 0;
                for (int i = 0; i < rawMessage.Length; i++)
                {
                    if (Char.IsUpper(rawMessage[i]))
                    {
                        caps++;
                        if (caps > ConfigKey.MaxCaps.GetInt())
                        {
                            rawMessage = rawMessage.ToLower();
                            player.Message("Your message was changed to lowercase as it exceeded the maximum amount of capital letters.");
                        }
                    }
                }
            }

            if (!player.Can(Permission.Swear))
            {
                if (!File.Exists(Paths.SwearWordsFileName))
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("#This txt file should be filled with bad words that you want to be filtered out");
                    sb.AppendLine("#I have included some examples, excuse my language :P");
                    sb.AppendLine("f**k");
                    sb.AppendLine("f*****g");
                    sb.AppendLine("f****d");
                    sb.AppendLine("dick");
                    sb.AppendLine("bitch");
                    sb.AppendLine("shit");
                    sb.AppendLine("s******g");
                    sb.AppendLine("s******d");
                    sb.AppendLine("c**t");
                    sb.AppendLine("nigger");
                    sb.AppendLine("wanker");
                    sb.AppendLine("wank");
                    sb.AppendLine("wanking");
                    sb.AppendLine("piss");
                    File.WriteAllText(Paths.SwearWordsFileName, sb.ToString());
                }
                string CensoredText = Color.ReplacePercentCodes(ConfigKey.SwearName.GetString()) + Color.White;
                if (ConfigKey.SwearName.GetString() == null)
                {
                    CensoredText = "&CBlock&F";
                }

                const string       PatternTemplate = @"\b({0})(s?)\b";
                const RegexOptions Options         = RegexOptions.IgnoreCase;

                if (Swears.Count == 0)
                {
                    Swears.AddRange(File.ReadAllLines(Paths.SwearWordsFileName).
                                    Where(line => line.StartsWith("#") == false || line.Trim().Equals(String.Empty)));
                }

                if (badWordMatchers == null)
                {
                    badWordMatchers = Swears.
                                      Select(x => new Regex(string.Format(PatternTemplate, x), Options));
                }

                string output = badWordMatchers.
                                Aggregate(rawMessage, (current, matcher) => matcher.Replace(current, CensoredText));
                rawMessage = output;
            }

            /*if(player.World != null)
             * {
             *      if(player.World.GameOn)
             *      {
             *              if(Games.MineChallenge.mode == Games.MineChallenge.GameMode.math1)
             *              {
             *                      if(rawMessage == Games.MineChallenge.answer.ToString() && !Games.MineChallenge.completed.Contains(player))
             *                      {
             *                              Games.MineChallenge.completed.Add(player);
             *                              player.Message("&8Correct!");
             *                              if(player.World.blueTeam.Contains(player)) player.World.blueScore++;
             *                              else player.World.redScore++;
             *                      }
             *                      else
             *                      {
             *                              player.Message("&8Incorrect");
             *                      }
             *                      return false;
             *              }
             *
             *              if(Games.MineChallenge.mode == Games.MineChallenge.GameMode.math2)
             *              {
             *                      if(rawMessage == Games.MineChallenge.answer.ToString() && !Games.MineChallenge.completed.Contains(player))
             *                      {
             *                              Games.MineChallenge.completed.Add(player);
             *                              player.Message("&8Correct!");
             *                              if(player.World.blueTeam.Contains(player)) player.World.blueScore++;
             *                              else player.World.redScore++;
             *                      }
             *                      else
             *                      {
             *                              player.Message("&8Incorrect");
             *                      }
             *                      return false;
             *              }
             *      }
             * }*/

            var recepientList = Server.Players.NotIgnoring(player);             //if(player.World.WorldOnlyChat) recepientList = player.World.Players.NotIgnoring(player);


            string formattedMessage = String.Format("{0}&F: {1}",
                                                    player.ClassyName,
                                                    rawMessage);

            var e = new ChatSendingEventArgs(player,
                                             rawMessage,
                                             formattedMessage,
                                             ChatMessageType.Global,
                                             recepientList);

            if (!SendInternal(e))
            {
                return(false);
            }

            Logger.Log(LogType.GlobalChat,
                       "{0}: {1}", player.Name, OriginalMessage);
            return(true);
        }
Ejemplo n.º 39
0
        private static void TimerHandler(Player player, Command cmd)
        {
            string param = cmd.Next();

            // List timers
            if (param == null)
            {
                ChatTimer[] list = ChatTimer.TimerList.OrderBy(timer => timer.TimeLeft).ToArray();
                if (list.Length == 0)
                {
                    player.Message("&SNo timers running.");
                }
                else
                {
                    player.Message("&WThere are {0} timers running:", list.Length);
                    foreach (ChatTimer timer in list)
                    {
                        player.Message("#{0} \"{1}&S\" (started by {2}, {3} left)",
                                       timer.Id, timer.Message, timer.StartedBy, timer.TimeLeft.ToMiniString());
                    }
                }
                return;
            }

            // Abort a timer
            if (param.Equals("abort", StringComparison.OrdinalIgnoreCase))
            {
                int timerId;
                if (cmd.NextInt(out timerId))
                {
                    ChatTimer timer = ChatTimer.FindTimerById(timerId);
                    if (timer == null || !timer.IsRunning)
                    {
                        player.Message("&WTimer #{0} does not exist.", timerId);
                    }
                    else
                    {
                        timer.Stop();
                        string abortMsg = String.Format("&Y(Timer) {0}&Y aborted a timer with {1} left: {2}",
                                                        player.ClassyName, timer.TimeLeft.ToMiniString(), timer.Message);
                        Chat.SendSay(player, abortMsg);
                    }
                }
                else
                {
                    CdTimer.PrintUsage(player);
                }
                return;
            }

            // Start a timer
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }
            if (player.DetectChatSpam())
            {
                return;
            }
            TimeSpan duration;

            if (!param.TryParseMiniTimespan(out duration))
            {
                CdTimer.PrintUsage(player);
                return;
            }
            if (duration > DateTimeUtil.MaxTimeSpan)
            {
                player.MessageMaxTimeSpan();
                return;
            }
            if (duration < ChatTimer.MinDuration)
            {
                player.Message("&WTimer: Must be at least 1 second.");
                return;
            }

            string sayMessage;
            string message = cmd.NextAll();

            if (String.IsNullOrEmpty(message))
            {
                sayMessage = String.Format("&Y(Timer) {0}&Y started a {1} timer",
                                           player.ClassyName,
                                           duration.ToMiniString());
            }
            else
            {
                sayMessage = String.Format("&Y(Timer) {0}&Y started a {1} timer: {2}",
                                           player.ClassyName,
                                           duration.ToMiniString(),
                                           message);
            }
            Chat.SendSay(player, sayMessage);
            ChatTimer.Start(duration, message, player.Name);
        }
Ejemplo n.º 40
0
        private static void GlobalHandler(Player player, Command cmd)
        {
            var    sendList = Server.Players.Where(p => p.GlobalChatAllowed && !p.IsDeaf);
            string msg      = cmd.NextAll();

            if (!ConfigKey.GlobalChat.Enabled())
            {
                player.Message("&WGlobal Chat is disabled on this server.");
                return;
            }
            if (!GlobalChat.GlobalThread.GcReady)
            {
                player.Message("&WGlobal Chat is not connected.");
                return;
            }
            string reason;

            if (Server.GlobalChatBans.TryGetValue(player.Name.ToLower(), out reason))
            {
                player.Message("You were &cbanned &efrom &gglobal chat&e by &h{0}&e", reason);
                player.Message("You can appeal your ban at &9http://atomiccraft.net");
                return;
            }
            switch (msg)
            {
            case "reconnect":
                if (player.Can(Permission.ManageGlobalChat))
                {
                    if (GlobalChat.GlobalThread.GcReady)
                    {
                        player.Message("&WThis server is currently connected to global chat.");
                        return;
                    }
                    GlobalChat.GlobalThread.GcReady = true;
                    Server.Message(
                        "&WAttempting to connect to AtomicCraft Global Chat Network. This may take a few seconds.");
                    GlobalChat.Init();
                    GlobalChat.Start();
                    return;
                }
                break;

            case "rules":
                if (!player.GlobalChatAllowed)
                {
                    player.Message(
                        "&RRules: No spamming and no advertising. All chat rules that apply to your server apply here.\n" +
                        "&WServer staff have the right to kick you.\n" +
                        "&SBy using the Global Chat, you accept these conditions.\n" +
                        "&SType &H/global accept &Sto connect");
                    return;
                }

                if (player.GlobalChatAllowed)
                {
                    player.Message(
                        "&RRules: No spamming and no advertising. All chat rules that apply to your server apply here.\n" +
                        "&WServer staff have the right to kick you.\n" +
                        "&SBy using the Global Chat, you accept these conditions.");
                    return;
                }
                break;

            case "accept":

                if (!player.GlobalChatAllowed)
                {
                    player.GlobalChatAllowed = true;
                    player.Message("&SThank you for accepting the global chat rules.\n" +
                                   "&WYou now have global chat enabled.");
                    GlobalChat.GlobalThread.SendChannelMessage(player.ClassyName + " &Sjoined global chat.");
                    sendList.Message(player.ClassyName + " &Sjoined global chat.");
                    return;
                }

                if (player.GlobalChatAllowed)
                {
                    player.Message("&WYou have already accepted the global chat rules.");
                    return;
                }
                break;

            case "ignore":
                if (!player.GlobalChatIgnore)
                {
                    player.GlobalChatIgnore = true;
                    player.Message("&WYou have disconnected from global chat.");
                    sendList.Message(player.ClassyName + " &Sdisconnected from global chat.");
                    GlobalChat.GlobalThread.SendChannelMessage(player.ClassyName +
                                                               " &Sdisconnected from global chat.");
                    return;
                }
                break;

            case "help":
                CdGlobal.PrintUsage(player);
                break;
            }
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            if ((!player.GlobalChatAllowed) && ((msg.Length < 1) || (msg.Length > 1)))
            {
                player.Message("&WYou must read and accept the global chat rules. Type &H/global rules");
                return;
            }

            if ((player.GlobalChatAllowed) && string.IsNullOrEmpty(msg))
            {
                player.Message("&WYou must enter a message!");
                return;
            }
            if (!player.GlobalChatAllowed)
            {
                return;
            }
            string pMsg = player.ClassyName + Color.White + ": " + msg;

            msg = player.ClassyName + Color.Black + ": " + msg;
            sendList.Message("&g[Global] " + pMsg); //send the white message to Server
            msg = Color.MinecraftToIrcColors(msg);
            msg = Color.ReplacePercentCodes(msg);
            GlobalChat.GlobalThread.SendChannelMessage(msg); //send the black message to GC
        }
Ejemplo n.º 41
0
        public static PlayerInfo FindPlayerInfoOrPrintMatches([NotNull] Player player, [NotNull] string partialName)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (partialName == null)
            {
                throw new ArgumentNullException("partialName");
            }
            CheckIfLoaded();

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

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

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

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

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

            // If a single name has been found, set it as LastUsedPlayerName
            player.LastUsedPlayerName = target.Name;
            return(target);
        }
Ejemplo n.º 42
0
        public static string FindMapFile([NotNull] Player player, [NotNull] string fileName)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }
            // Check if path contains missing drives or invalid characters
            if (!Paths.IsValidPath(fileName))
            {
                player.Message("Invalid filename or path.");
                return(null);
            }

            // Look for the file
            string sourceFullFileName = Path.Combine(Paths.MapPath, fileName);

            if (!File.Exists(sourceFullFileName) && !Directory.Exists(sourceFullFileName))
            {
                if (File.Exists(sourceFullFileName + ".fcm"))
                {
                    // Try with extension added
                    sourceFullFileName += ".fcm";
                }
                else if (MonoCompat.IsCaseSensitive)
                {
                    try {
                        // If we're on a case-sensitive OS, try case-insensitive search
                        FileInfo[] candidates = Paths.FindFiles(sourceFullFileName + ".fcm");
                        if (candidates.Length == 0)
                        {
                            candidates = Paths.FindFiles(sourceFullFileName);
                        }

                        if (candidates.Length == 0)
                        {
                            player.Message("File/directory not found: {0}", fileName);
                        }
                        else if (candidates.Length == 1)
                        {
                            player.Message("Filenames are case-sensitive! Did you mean to load \"{0}\"?", candidates[0].Name);
                        }
                        else
                        {
                            player.Message("Filenames are case-sensitive! Did you mean to load one of these: {0}",
                                           String.Join(", ", candidates.Select(c => c.Name).ToArray()));
                        }
                    } catch (DirectoryNotFoundException ex) {
                        player.Message(ex.Message);
                    }
                    return(null);
                }
                else
                {
                    // Nothing found!
                    player.Message("File/directory not found: {0}", fileName);
                    return(null);
                }
            }

            // Make sure that the given file is within the map directory
            if (!Paths.Contains(Paths.MapPath, sourceFullFileName))
            {
                player.MessageUnsafePath();
                return(null);
            }

            return(sourceFullFileName);
        }
Ejemplo n.º 43
0
 public static void testFunction(Player player)
 {
     player.Message("This is a legendcraft test function");
 }
Ejemplo n.º 44
0
        public static void RealmCreate(Player player, Command cmd, string themeName, string templateName)
        {
            MapGenTemplate template;
            MapGenTheme theme;

            int wx, wy, height = 128;
            if (!(cmd.NextInt(out wx) && cmd.NextInt(out wy) && cmd.NextInt(out height)))
            {
                if (player.World != null)
                {
                    wx = 128;
                    wy = 128;
                    height = 128;
                }
                else
                {
                    player.Message("When used from console, /gen requires map dimensions.");

                    return;
                }
                cmd.Rewind();
                cmd.Next();
                cmd.Next();
            }

            if (!Map.IsValidDimension(wx))
            {
                player.Message("Cannot make map with width {0}: dimensions must be multiples of 16.", wx);
                return;
            }
            else if (!Map.IsValidDimension(wy))
            {
                player.Message("Cannot make map with length {0}: dimensions must be multiples of 16.", wy);
                return;
            }
            else if (!Map.IsValidDimension(height))
            {
                player.Message("Cannot make map with height {0}: dimensions must be multiples of 16.", height);
                return;
            }

            string fileName = player.Name;
            if (player.Name.Contains('.'))
            {
                fileName = player.Name.Replace(".", "-"); //support for email names
            }
            
            string fullFileName = null;

            if (fileName == null)
            {
                if (player.World == null)
                {
                    player.Message("When used from console, /gen requires FileName.");

                    return;
                }
                if (!cmd.IsConfirmed)
                {
                    player.Confirm(cmd, "Replace this realm's map with a generated one?");
                    return;
                }
            }
            else
            {
                fileName = fileName.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
                if (!fileName.EndsWith(".fcm", StringComparison.OrdinalIgnoreCase))
                {
                    fileName += ".fcm";
                }
                fullFileName = Path.Combine(Paths.MapPath, fileName);
                if (!Paths.IsValidPath(fullFileName))
                {
                    player.Message("Invalid filename.");
                    return;
                }
                if (!Paths.Contains(Paths.MapPath, fullFileName))
                {
                    player.MessageUnsafePath();
                    return;
                }
                string dirName = fullFileName.Substring(0, fullFileName.LastIndexOf(Path.DirectorySeparatorChar));
                if (!Directory.Exists(dirName))
                {
                    Directory.CreateDirectory(dirName);
                }
                if (!cmd.IsConfirmed && File.Exists(fullFileName))
                {
                    player.Confirm(cmd, "The mapfile \"{0}\" already exists. Overwrite?", fileName);
                    return;
                }
            }

            bool noTrees;
            if (themeName.Equals("grass", StringComparison.OrdinalIgnoreCase))
            {
                theme = MapGenTheme.Forest;
                noTrees = true;
            }
            else
            {
                try
                {
                    theme = (MapGenTheme)Enum.Parse(typeof(MapGenTheme), themeName, true);
                    noTrees = (theme != MapGenTheme.Forest);
                }
                catch (Exception)
                {
                    player.MessageNow("Unrecognized theme \"{0}\". Available themes are: Grass, {1}",
                                       themeName,
                                       String.Join(", ", Enum.GetNames(typeof(MapGenTheme))));
                    return;
                }
            }

            try
            {
                template = (MapGenTemplate)Enum.Parse(typeof(MapGenTemplate), templateName, true);
            }
            catch (Exception)
            {
                player.Message("Unrecognized template \"{0}\". Available templates are: {1}",
                                templateName,
                                String.Join(", ", Enum.GetNames(typeof(MapGenTemplate))));
                return;
            }

            if (!Enum.IsDefined(typeof(MapGenTheme), theme) || !Enum.IsDefined(typeof(MapGenTemplate), template))
            {

                return;
            }

            MapGeneratorArgs args = MapGenerator.MakeTemplate(template);
            args.MapWidth = wx;
            args.MapLength = wy;
            args.MapHeight = height;
            args.MaxHeight = (int)(args.MaxHeight / 80d * height);
            args.MaxDepth = (int)(args.MaxDepth / 80d * height);
            args.Theme = theme;
            args.AddTrees = !noTrees;

            Map map;
            try
            {
                if (theme == MapGenTheme.Forest && noTrees)
                {
                    player.MessageNow("Generating Grass {0}...", template);
                }
                else
                {
                    player.MessageNow("Generating {0} {1}...", theme, template);
                }
                if (theme == MapGenTheme.Forest && noTrees && template == MapGenTemplate.Flat)
                {
                    map = MapGenerator.GenerateFlatgrass(args.MapWidth, args.MapLength, args.MapHeight);
                }
                else
                {
                    MapGenerator generator = new MapGenerator(args);
                    map = generator.Generate();
                }

            }
            catch (Exception ex)
            {
                Logger.Log(LogType.Error, "MapGenerator: Generation failed: {0}",
                            ex);
                player.MessageNow("&WAn error occured while generating the map.");
                return;
            }

            if (fileName != null)
            {
                if (map.Save(fullFileName))
                {
                    player.MessageNow("Generation done. Saved to {0}", fileName);
                }
                else
                {
                    player.Message("&WAn error occured while saving generated map to {0}", fileName);
                }
            }
            else
            {
                player.MessageNow("Generation done. Changing map...");
                player.World.ChangeMap(map);
            }
        }
Ejemplo n.º 45
0
        static void DrawEllipsoid(Player player, Position[] marks, object tag)
        {
            player.drawingInProgress = true;
            Block drawBlock = (Block)tag;

            // find start/end coordinates
            int sx = Math.Min(marks[0].x, marks[1].x);
            int ex = Math.Max(marks[0].x, marks[1].x);
            int sy = Math.Min(marks[0].y, marks[1].y);
            int ey = Math.Max(marks[0].y, marks[1].y);
            int sh = Math.Min(marks[0].h, marks[1].h);
            int eh = Math.Max(marks[0].h, marks[1].h);

            int  blocks;
            byte block;
            int  step = 8;

            blocks = (ex - sx + 1) * (ey - sy + 1) * (eh - sh + 1);
            if (blocks > 2000000)
            {
                player.Message("NOTE: This draw command is too massive to undo.");
            }

            // find axis lengths
            double rx = (ex - sx + 1) / 2 + .25;
            double ry = (ey - sy + 1) / 2 + .25;
            double rh = (eh - sh + 1) / 2 + .25;

            double rx2 = 1 / (rx * rx);
            double ry2 = 1 / (ry * ry);
            double rh2 = 1 / (rh * rh);

            // find center points
            double cx = (ex + sx) / 2;
            double cy = (ey + sy) / 2;
            double ch = (eh + sh) / 2;

            // prepare to draw
            player.drawUndoBuffer.Clear();

            blocks = (int)(Math.PI * 0.75 * rx * ry * rh);
            if (blocks > 2000000)
            {
                player.Message("NOTE: This draw command is too massive to undo.");
            }

            for (int x = sx; x <= ex; x += step)
            {
                for (int y = sy; y <= ey; y += step)
                {
                    for (int h = sh; h <= eh; h += step)
                    {
                        for (int h3 = 0; h3 < step && h + h3 <= eh; h3++)
                        {
                            for (int y3 = 0; y3 < step && y + y3 <= ey; y3++)
                            {
                                for (int x3 = 0; x3 < step && x + x3 <= ex; x3++)
                                {
                                    // get relative coordinates
                                    double dx = (x + x3 - cx);
                                    double dy = (y + y3 - cy);
                                    double dh = (h + h3 - ch);

                                    // test if it's inside ellipse
                                    if ((dx * dx) * rx2 + (dy * dy) * ry2 + (dh * dh) * rh2 <= 1)
                                    {
                                        block = player.world.map.GetBlock(x + x3, y + y3, h + h3);
                                        if (block == (byte)drawBlock)
                                        {
                                            continue;
                                        }
                                        if (block == (byte)Block.Admincrete && !player.Can(Permissions.DeleteAdmincrete))
                                        {
                                            continue;
                                        }
                                        player.drawUndoBuffer.Enqueue(new BlockUpdate(Player.Console, x + x3, y + y3, h + h3, block));
                                        player.world.map.QueueUpdate(new BlockUpdate(Player.Console, x + x3, y + y3, h + h3, (byte)drawBlock));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            player.drawingInProgress = false;
            player.Message("Drawing " + blocks + " blocks... The map is now being updated.");
            player.world.log.Log("{0} initiated drawing a cuboid containing {1} blocks of type {2}.", LogType.UserActivity,
                                 player.name,
                                 blocks,
                                 drawBlock.ToString());
            GC.Collect();
        }
Ejemplo n.º 46
0
        public static PlayerInfo FindPlayerInfoOrPrintMatches([NotNull] Player player, [NotNull] string namePart,
                                                              SearchOptions options)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (namePart == null)
            {
                throw new ArgumentNullException("namePart");
            }
            CheckIfLoaded();

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

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

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

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

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

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

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

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

            // If a single name has been found, set it as LastUsedPlayerName
            if (includeSelf || target != player.Info)
            {
                player.LastUsedPlayerName = target.Name;
            }
            return(target);
        }
Ejemplo n.º 47
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 (!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.",
                               newZone.Controller.MinRank.ClassyName, info.ClassyName);
            }
            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;
                        }

                        if (name.ToLower().StartsWith("msg="))
                        {
                            newZone.Message = name.Substring(4) + " " + (cmd.NextAll() ?? "");
                            player.Message("Zone: Custom denied messaged changed to '" + newZone.Message + "'");
                            break;
                        }

                        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;
                }
                else
                {
                    player.MessageNoRank(rankName);
                    return;
                }
            }
            player.Message("Zone " + newZone.ClassyName + "&S: Place a block or type &H/Mark&S to use your location.");
            player.SelectionStart(2, ZoneAddCallback, newZone, CdZoneAdd.Permissions);
        }
Ejemplo n.º 48
0
        public static void RevertNames()    //reverts names for online players. offline players get reverted upon leaving the game
        {
            List <PlayerInfo> TDPlayers = new List <PlayerInfo>(PlayerDB.PlayerInfoList.Where(r => (r.isOnBlueTeam || r.isOnRedTeam) && r.IsOnline).ToArray());

            for (int i = 0; i < TDPlayers.Count(); i++)
            {
                string     p1 = TDPlayers[i].Name.ToString();
                PlayerInfo pI = PlayerDB.FindPlayerInfoExact(p1);
                Player     p  = pI.PlayerObject;

                if (p != null)
                {
                    p.iName = null;
                    pI.tempDisplayedName = null;
                    pI.isOnRedTeam       = false;
                    pI.isOnBlueTeam      = false;
                    pI.isPlayingTD       = false;
                    pI.Health            = 100;
                    p.entityChanged      = true;

                    //reset all special messages
                    if (p.SupportsMessageTypes)
                    {
                        p.Send(PacketWriter.MakeSpecialMessage((byte)100, "&f"));
                        p.Send(PacketWriter.MakeSpecialMessage((byte)1, "&f"));
                        p.Send(PacketWriter.MakeSpecialMessage((byte)2, "&f"));
                    }

                    //undo gunmode (taken from GunHandler.cs)
                    p.GunMode = false;
                    try
                    {
                        foreach (Vector3I block in p.GunCache.Values)
                        {
                            p.Send(PacketWriter.MakeSetBlock(block.X, block.Y, block.Z, p.WorldMap.GetBlock(block)));
                            Vector3I removed;
                            p.GunCache.TryRemove(block.ToString(), out removed);
                        }
                        if (p.bluePortal.Count > 0)
                        {
                            int j = 0;
                            foreach (Vector3I block in p.bluePortal)
                            {
                                if (p.WorldMap != null && p.World.IsLoaded)
                                {
                                    p.WorldMap.QueueUpdate(new BlockUpdate(null, block, p.blueOld[j]));
                                    j++;
                                }
                            }
                            p.blueOld.Clear();
                            p.bluePortal.Clear();
                        }
                        if (p.orangePortal.Count > 0)
                        {
                            int j = 0;
                            foreach (Vector3I block in p.orangePortal)
                            {
                                if (p.WorldMap != null && p.World.IsLoaded)
                                {
                                    p.WorldMap.QueueUpdate(new BlockUpdate(null, block, p.orangeOld[j]));
                                    j++;
                                }
                            }
                            p.orangeOld.Clear();
                            p.orangePortal.Clear();
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogType.SeriousError, "" + ex);
                    }
                    if (p.IsOnline)
                    {
                        p.Message("Your status has been reverted.");
                    }
                }
            }
        }
Ejemplo n.º 49
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");
            }
        }
Ejemplo n.º 50
0
        public static void GunHandler(Player player, Command cmd)
        {
            //to prevent players from doing /gun during a TDM game that arent actually playing in
            if (player.World.gameMode == GameMode.TeamDeathMatch && !player.Info.isPlayingTD)
            {
                player.Message("Players who are not playing Team DeathMatch can only spectate.");
                return;
            }

            if (player.Info.isPlayingCTF && player.Info.gunDisarmed)
            {
                player.Message("You are currently disarmed. You cannot use a gun until the disarm powerup has worn off.");
                return;
            }
            if (player.GunMode)
            {
                player.GunMode = false;
                try
                {
                    foreach (Vector3I block in player.GunCache.Values)
                    {
                        player.Send(PacketWriter.MakeSetBlock(block.X, block.Y, block.Z, player.WorldMap.GetBlock(block)));
                        Vector3I removed;
                        player.GunCache.TryRemove(block.ToString(), out removed);
                    }
                    if (player.bluePortal.Count > 0)
                    {
                        int i = 0;
                        foreach (Vector3I block in player.bluePortal)
                        {
                            if (player.WorldMap != null && player.World.IsLoaded)
                            {
                                player.WorldMap.QueueUpdate(new BlockUpdate(null, block, player.blueOld[i]));
                                i++;
                            }
                        }
                        player.blueOld.Clear();
                        player.bluePortal.Clear();
                    }
                    if (player.orangePortal.Count > 0)
                    {
                        int i = 0;
                        foreach (Vector3I block in player.orangePortal)
                        {
                            if (player.WorldMap != null && player.World.IsLoaded)
                            {
                                player.WorldMap.QueueUpdate(new BlockUpdate(null, block, player.orangeOld[i]));
                                i++;
                            }
                        }
                        player.orangeOld.Clear();
                        player.orangePortal.Clear();
                    }
                    player.Message("&SGunMode deactivated");
                }
                catch (Exception ex)
                {
                    Logger.Log(LogType.SeriousError, "" + ex);
                }
            }
            else
            {
                if (!player.World.gunPhysics)
                {
                    player.Message("&WGun physics are disabled on this world");
                    return;
                }
                player.GunMode = true;
                GunGlassTimer timer = new GunGlassTimer(player);
                timer.Start();
                player.Message("&SGunMode activated. Fire at will!");
            }
        }
Ejemplo n.º 51
0
        static void ZoneRenameHandler(Player player, Command 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);
        }
Ejemplo n.º 52
0
        static void ZoneRemoveHandler(Player player, CommandReader cmd)
        {
            if (player.World == null)
            {
                PlayerOpException.ThrowNoWorld(player);
            }

            string zoneName = cmd.Next();

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

            if (zoneName == "*")
            {
                if (!cmd.IsConfirmed)
                {
                    Logger.Log(LogType.UserActivity,
                               "ZRemove: Asked {0} to confirm removing all zones on world {1}",
                               player.Name, player.World.Name);
                    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;
                    }
                }
                if (!cmd.IsConfirmed)
                {
                    Logger.Log(LogType.UserActivity,
                               "ZRemove: Asked {0} to confirm removing zone {1} from world {2}",
                               player.Name, zone.Name, player.World.Name);
                    player.Confirm(cmd, "Remove zone {0}&S?", zone.ClassyName);
                    return;
                }

                if (zones.Remove(zone.Name))
                {
                    Logger.Log(LogType.UserActivity,
                               "Player {0} removed zone {1} from world {2}",
                               player.Name, zone.Name, player.World.Name);
                    player.Message("Zone \"{0}\" removed.", zone.Name);
                }
            }
            else
            {
                player.MessageNoZone(zoneName);
            }
        }
 public static void ClearParametrization(Player p, Command cmd)
 {
     p.PublicAuxStateObjects.Remove(CoordsStorageName);
     p.PublicAuxStateObjects.Remove(ParamsStorageName);
     p.Message("Prepared parametrization data cleared");
 }
Ejemplo n.º 54
0
        internal static void RealmAccess(Player player, Command cmd, string worldName, string name)
        {

            // Print information about the current realm
            if (worldName == null)
            {
                if (player.World == null)
                {
                    player.Message("Error.");
                }
                else
                {
                    player.Message(player.World.AccessSecurity.GetDescription(player.World, "realm", "accessed"));
                }
                return;
            }

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



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

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

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

                    // prevent players from whitelisting themselves to bypass protection


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

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

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

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

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

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

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

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

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

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

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

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

                    }

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

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

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

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

                WorldManager.SaveWorldList();
            }
        }
Ejemplo n.º 55
0
        public static void PowerUp(Player p)
        {
            int GetPowerUp = (new Random()).Next(1, 4);

            if (GetPowerUp < 3)
            {
                return;
            }

            int choosePowerUp = (new Random()).Next(1, 19);

            //decide which powerup to use, certain powerups have a higher chance such as first aid kit and dodge as opposed to rarer ones like holy blessing
            switch (choosePowerUp)
            {
            case 1:
            case 2:
            case 3:
                //first aid kit - heal user for 50 hp
                world_.Players.Message("&f{0} has discovered a &aFirst Aid Kit&f!", p.Name);
                world_.Players.Message("&f{0} has been healed for 50 hp.", p.Name);

                //set health to 100, make sure it doesn't overflow
                p.Info.Health += 50;
                if (p.Info.Health > 100)
                {
                    p.Info.Health = 100;
                }

                string healthBar = "&f[&a--------&f]";
                if (p.Info.Health == 75)
                {
                    healthBar = "&f[&a------&8--&f]";
                }
                else if (p.Info.Health == 50)
                {
                    healthBar = "&f[&e----&8----&f]";
                }
                else if (p.Info.Health == 25)
                {
                    healthBar = "&f[&c--&8------&f]";
                }
                else
                {
                    healthBar = "&f[&8--------&f]";
                }

                if (p.SupportsMessageTypes)
                {
                    p.Send(PacketWriter.MakeSpecialMessage((byte)1, healthBar));
                }
                else
                {
                    p.Message("You have " + p.Info.Health.ToString() + " health.");
                }

                break;

            case 4:
            case 5:
                //penicillin - heal user for 100 hp
                world_.Players.Message("&f{0} has discovered a &aPenicillin Case&f!", p.Name);
                world_.Players.Message("&f{0} has been healed for 100 hp.", p.Name);
                p.Info.Health = 100;

                if (p.SupportsMessageTypes)
                {
                    p.Send(PacketWriter.MakeSpecialMessage((byte)1, "&f[&8--------&f]"));
                }
                else
                {
                    p.Message("You have " + p.Info.Health.ToString() + " health.");
                }

                break;

            case 6:
            case 7:
                //disarm
                world_.Players.Message("&f{0} has discovered a &aDisarm Spell&f!", p.Name);
                if (p.Info.CTFBlueTeam)
                {
                    world_.Players.Message("The red team has lost all weaponry for 30 seconds!");
                    foreach (Player pl in world_.Players)
                    {
                        if (pl.Info.CTFRedTeam)
                        {
                            pl.Info.gunDisarmed  = true;
                            pl.Info.stabDisarmed = true;
                            pl.GunMode           = false;
                        }
                    }
                    RedDisarmed = DateTime.UtcNow;
                }
                else
                {
                    world_.Players.Message("The blue team has lost all weaponry for 30 seconds!");
                    foreach (Player pl in world_.Players)
                    {
                        if (pl.Info.CTFBlueTeam)
                        {
                            pl.Info.gunDisarmed  = true;
                            pl.Info.stabDisarmed = true;
                            pl.GunMode           = false;
                        }
                    }
                    BlueDisarmed = DateTime.UtcNow;
                }

                break;

            case 8:
            case 9:
                //blades of fury
                world_.Players.Message("&f{0} has discovered the &aBlades of Fury&f!", p.Name);
                if (p.Info.CTFBlueTeam)
                {
                    world_.Players.Message("The red team is unable to backstab for 1 minute!");
                    world_.Players.Message("The blue team can now stab the red team from any angle for 1 minute!");
                    foreach (Player pl in world_.Players)
                    {
                        if (pl.Info.CTFBlueTeam)
                        {
                            pl.Info.stabAnywhere = true;
                        }
                        else
                        {
                            pl.Info.stabDisarmed = true;
                        }
                    }
                    RedBOFdebuff = DateTime.UtcNow;
                }
                else
                {
                    world_.Players.Message("The blue team is unable to backstab for 1 minute!");
                    world_.Players.Message("The red team can now stab the blue team from any angle for 1 minute!");
                    foreach (Player pl in world_.Players)
                    {
                        if (pl.Info.CTFRedTeam)
                        {
                            pl.Info.stabAnywhere = true;
                        }
                        else
                        {
                            pl.Info.stabDisarmed = true;
                        }
                    }
                    RedBOFdebuff = DateTime.UtcNow;
                }
                break;

            case 10:
            case 11:
                //war cry
                world_.Players.Message("&f{0} has discovered their &aWar Cry&f!", p.Name);
                if (p.Info.CTFBlueTeam)
                {
                    world_.Players.Message("The red team has been frightened back into their spawn!");
                    foreach (Player pl in world_.Players)
                    {
                        if (pl.Info.CTFRedTeam)
                        {
                            pl.TeleportTo(world_.redCTFSpawn.ToPlayerCoords());
                        }
                    }
                }
                else
                {
                    world_.Players.Message("The blue team has been frightened back into their spawn!");
                    foreach (Player pl in world_.Players)
                    {
                        if (pl.Info.CTFBlueTeam)
                        {
                            pl.TeleportTo(world_.blueCTFSpawn.ToPlayerCoords());
                        }
                    }
                }
                break;

            case 12:
            case 13:
            case 14:
                //strengthen
                world_.Players.Message("&f{0} has discovered a &aStrength Pack&f!", p.Name);
                world_.Players.Message("&f{0}'s gun now deals twice the damage for the next minute!", p.Name);
                p.Info.strengthened = true;
                p.Info.strengthTime = DateTime.UtcNow;
                break;

            case 15:
            case 16:
            case 17:
                //dodge
                world_.Players.Message("&f{0} has discovered a new &aDodging Technique&f!", p.Name);
                world_.Players.Message("&f{0}'s has a 50% chance to dodge incomming gun attacks for the next minute!", p.Name);
                p.Info.canDodge  = true;
                p.Info.dodgeTime = DateTime.UtcNow;
                break;

            case 18:
                //holy blessing (rarest and most treasured power up, yet easiest to code :P )
                world_.Players.Message("&f{0} has discovered the rare &aHoly Blessing&f!!!", p.Name);
                if (p.Info.CTFBlueTeam)
                {
                    world_.Players.Message("The Blue Team has been granted 1 point.");
                    redScore++;
                }
                else
                {
                    world_.Players.Message("The Red Team has been granted 1 point.");
                    blueScore++;
                }
                foreach (Player pl in world_.Players)
                {
                    if (pl.SupportsMessageTypes)
                    {
                        pl.Send(PacketWriter.MakeSpecialMessage((byte)2, "&cRed&f: " + redScore + ",&1 Blue&f: " + blueScore));
                    }
                    else
                    {
                        pl.Message("The score is now &cRed&f: {0} and &1Blue&f: {1}.", redScore, blueScore);
                    }
                }
                break;

            default:
                //no power up 4 u
                break;
            }
        }
Ejemplo n.º 56
0
        public static void RealmLoad(Player player, Command cmd, string fileName, string worldName)
        {

            if (worldName == null && player.World == null)
            {
                player.Message("When using /realm from console, you must specify the realm name.");
                return;
            }

            if (fileName == null)
            {
                // No params given at all
                
                return;
            }

            string fullFileName = WorldManager.FindMapFile(player, fileName);
            if (fullFileName == null) return;

            // Loading map into current realm
            if (worldName == null)
            {
                if (!cmd.IsConfirmed)
                {
                    player.Confirm(cmd, "About to replace THIS REALM with \"{0}\".", fileName);
                    return;
                }
                Map map;
                try
                {
                    map = MapUtility.Load(fullFileName);
                }
                catch (Exception ex)
                {
                    player.MessageNow("Could not load specified file: {0}: {1}", ex.GetType().Name, ex.Message);
                    return;
                }
                World realm = player.World;

                // Loading to current realm
                realm.MapChangedBy = player.Name;
                realm.ChangeMap(map);

                realm.Players.Message(player, "{0}&S loaded a new map for this realm.",
                                              player.ClassyName);
                player.MessageNow("New map loaded for the realm {0}", realm.ClassyName);

                Logger.Log(LogType.UserActivity,
                            "{0} loaded new map for realm \"{1}\" from {2}",
                            player.Name, realm.Name, fileName);
                realm.IsHidden = false;
                realm.IsRealm = true;
                WorldManager.SaveWorldList();


            }
            else
            {
                // Loading to some other (or new) realm
                if (!World.IsValidName(worldName))
                {
                    player.MessageInvalidWorldName(worldName);
                    return;
                }

                string buildRankName = cmd.Next();
                string accessRankName = cmd.Next();
                Rank buildRank = RankManager.DefaultBuildRank;
                Rank accessRank = null;
                if (buildRankName != null)
                {
                    buildRank = RankManager.FindRank(buildRankName);
                    if (buildRank == null)
                    {
                        player.MessageNoRank(buildRankName);
                        return;
                    }
                    if (accessRankName != null)
                    {
                        accessRank = RankManager.FindRank(accessRankName);
                        if (accessRank == null)
                        {
                            player.MessageNoRank(accessRankName);
                            return;
                        }
                    }
                }

                // Retype realm name, if needed
                if (worldName == "-")
                {
                    if (player.LastUsedWorldName != null)
                    {
                        worldName = player.LastUsedWorldName;
                    }
                    else
                    {
                        player.Message("Cannot repeat realm name: you haven't used any names yet.");
                        return;
                    }
                }

                lock (WorldManager.SyncRoot)
                {
                    World realm = WorldManager.FindWorldExact(worldName);
                    if (realm != null)
                    {
                        player.LastUsedWorldName = realm.Name;
                        // Replacing existing realm's map
                        if (!cmd.IsConfirmed)
                        {
                            player.Confirm(cmd, "About to replace realm map for {0}&S with \"{1}\".",
                                            realm.ClassyName, fileName);
                            return;
                        }

                        Map map;
                        try
                        {
                            map = MapUtility.Load(fullFileName);
                            realm.IsHidden = false;
                            realm.IsRealm = true;
                            WorldManager.SaveWorldList();
                        }
                        catch (Exception ex)
                        {
                            player.MessageNow("Could not load specified file: {0}: {1}", ex.GetType().Name, ex.Message);
                            return;
                        }

                        try
                        {
                            realm.MapChangedBy = player.Name;
                            realm.ChangeMap(map);
                            realm.IsHidden = false;
                            realm.IsRealm = true;
                            WorldManager.SaveWorldList();
                        }
                        catch (WorldOpException ex)
                        {
                            Logger.Log(LogType.Error,
                                        "Could not complete RealmLoad operation: {0}", ex.Message);
                            player.Message("&WRealmLoad: {0}", ex.Message);
                            return;
                        }

                        realm.Players.Message(player, "{0}&S loaded a new map for the realm {1}",
                                               player.ClassyName, realm.ClassyName);
                        player.MessageNow("New map for the realm {0}&S has been loaded.", realm.ClassyName);
                        Logger.Log(LogType.UserActivity,
                                    "{0} loaded new map for realm \"{1}\" from {2}",
                                    player.Name, realm.Name, fullFileName);
                        

                    }
                    else
                    {
                        // Adding a new realm
                        string targetFullFileName = Path.Combine(Paths.MapPath, worldName + ".fcm");
                        if (!cmd.IsConfirmed &&
                            File.Exists(targetFullFileName) && // target file already exists
                            !Paths.Compare(targetFullFileName, fullFileName))
                        {
                            // and is different from sourceFile
                            player.Confirm(cmd,
                                            "A map named \"{0}\" already exists, and will be overwritten with \"{1}\".",
                                            Path.GetFileName(targetFullFileName), Path.GetFileName(fullFileName));
                            return;
                        }

                        Map map;
                        try
                        {
                            map = MapUtility.Load(fullFileName);
                            //realm.IsHidden = false;
                            //realm.IsRealm = true;
                            //WorldManager.SaveWorldList();
                        }
                        catch (Exception ex)
                        {
                            player.MessageNow("Could not load \"{0}\": {1}: {2}",
                                               fileName, ex.GetType().Name, ex.Message);
                            return;
                        }

                        World newWorld;
                        try
                        {
                            newWorld = WorldManager.AddWorld(player, worldName, map, false);
                            
                        }
                        catch (WorldOpException ex)
                        {
                            player.Message("RealmLoad: {0}", ex.Message);
                            return;
                        }

                        player.LastUsedWorldName = worldName;
                        newWorld.BuildSecurity.MinRank = buildRank;
                        if (accessRank == null)
                        {
                            newWorld.AccessSecurity.ResetMinRank();
                        }
                        else
                        {
                            newWorld.AccessSecurity.MinRank = accessRank;
                        }
                        newWorld.BlockDB.AutoToggleIfNeeded();
                        if (BlockDB.IsEnabledGlobally && newWorld.BlockDB.IsEnabled)
                        {
                            player.Message("BlockDB is now auto-enabled on realm {0}", newWorld.ClassyName);
                        }
                        newWorld.LoadedBy = player.Name;
                        newWorld.LoadedOn = DateTime.UtcNow;
                        Server.Message("{0}&S created a new realm named {1}",
                                        player.ClassyName, newWorld.ClassyName);
                        Logger.Log(LogType.UserActivity,
                                    "{0} created a new realm named \"{1}\" (loaded from \"{2}\")",
                                    player.Name, worldName, fileName);
                        newWorld.IsHidden = false;
                        newWorld.IsRealm = true;
                        WorldManager.SaveWorldList();
                        player.MessageNow("Access permission is {0}+&S, and build permission is {1}+",
                                           newWorld.AccessSecurity.MinRank.ClassyName,
                                           newWorld.BuildSecurity.MinRank.ClassyName);
                        
                    }
                }
            }

            Server.RequestGC();
        }
Ejemplo n.º 57
0
 public static void GunHandler(Player player, Command cmd)
 {
     if (player.GunMode)
     {
         player.GunMode = false;
         try
         {
             foreach (Vector3I block in player.GunCache.Values)
             {
                 player.Send(PacketWriter.MakeSetBlock(block.X, block.Y, block.Z, player.WorldMap.GetBlock(block)));
                 Vector3I removed;
                 player.GunCache.TryRemove(block.ToString(), out removed);
             }
             if (player.bluePortal.Count > 0)
             {
                 int i = 0;
                 foreach (Vector3I block in player.bluePortal)
                 {
                     if (player.WorldMap != null && player.World.IsLoaded)
                     {
                         player.WorldMap.QueueUpdate(new BlockUpdate(null, block, player.blueOld[i]));
                         i++;
                     }
                 }
                 player.blueOld.Clear();
                 player.bluePortal.Clear();
             }
             if (player.orangePortal.Count > 0)
             {
                 int i = 0;
                 foreach (Vector3I block in player.orangePortal)
                 {
                     if (player.WorldMap != null && player.World.IsLoaded)
                     {
                         player.WorldMap.QueueUpdate(new BlockUpdate(null, block, player.orangeOld[i]));
                         i++;
                     }
                 }
                 player.orangeOld.Clear();
                 player.orangePortal.Clear();
             }
             player.Message("&SGunMode deactivated");
         }
         catch (Exception ex)
         {
             Logger.Log(LogType.SeriousError, "" + ex);
         }
     }
     else
     {
         if (!player.World.gunPhysics)
         {
             player.Message("&WGun physics are disabled on this world");
             return;
         }
         player.GunMode = true;
         GunGlassTimer timer = new GunGlassTimer(player);
         timer.Start();
         player.Message("&SGunMode activated. Fire at will!");
     }
 }
Ejemplo n.º 58
0
        void Draw(Player player, Command command, DrawMode mode)
        {
            if (!player.Can(Permissions.Draw))
            {
                world.NoAccessMessage(player);
                return;
            }
            if (player.drawingInProgress)
            {
                player.Message("Another draw command is already in progress. Please wait.");
                return;
            }
            string blockName = command.Next();
            Block  block;

            if (blockName == null || blockName == "")
            {
                if (mode == DrawMode.Cuboid)
                {
                    player.Message("Usage: " + Color.Help + "/cuboid blockName" + Color.Sys + " or " + Color.Help + "/cub blockName");
                }
                else
                {
                    player.Message("Usage: " + Color.Help + "/ellipsoid blockName" + Color.Sys + " or " + Color.Help + "/ell blockName");
                }
                return;
            }
            try {
                block = Map.GetBlockByName(blockName);
            } catch (Exception) {
                player.Message("Unknown block name: " + blockName);
                return;
            }
            player.tag = block;

            Permissions permission = Permissions.Build;

            switch (block)
            {
            case Block.Admincrete: permission = Permissions.PlaceAdmincrete; break;

            case Block.Air: permission = Permissions.Delete; break;

            case Block.Water:
            case Block.StillWater: permission = Permissions.PlaceWater; break;

            case Block.Lava:
            case Block.StillLava: permission = Permissions.PlaceLava; break;
            }
            if (!player.Can(permission))
            {
                player.Message("You are not allowed to draw with this block.");
                return;
            }

            player.marksExpected = 2;
            player.markCount     = 0;
            player.marks.Clear();
            player.Message(mode.ToString() + ": Place a block or type /mark to use your location.");

            if (mode == DrawMode.Cuboid)
            {
                player.selectionCallback = DrawCuboid;
            }
            else
            {
                player.selectionCallback = DrawEllipsoid;
            }
        }
Ejemplo n.º 59
0
        internal static void RealmBuild(Player player, Command cmd, string worldName, string name, string NameIfRankIsName)
        {


            // Print information about the current realm
            if (worldName == null)
            {
                if (player.World == null)
                {
                    player.Message("When calling /wbuild from console, you must specify a realm name.");
                }
                else
                {
                    player.Message(player.World.BuildSecurity.GetDescription(player.World, "realm", "modified"));
                }
                return;
            }

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


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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if (changesWereMade)
            {
                WorldManager.SaveWorldList();
            }
        }
Ejemplo n.º 60
0
        static void ZoneEditHandler(Player player, CommandReader cmd)
        {
            World playerWorld = player.World;

            if (playerWorld == null)
            {
                PlayerOpException.ThrowNoWorld(player);
            }
            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, playerWorld.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, playerWorld.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.FindPlayerInfoOrPrintMatches(player, nextToken.Substring(1), SearchOptions.IncludeSelf);
                    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.FindPlayerInfoOrPrintMatches(player, nextToken.Substring(1), SearchOptions.IncludeSelf);
                    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.OnEdited(player.Info.Name);
                }
                else
                {
                    player.Message("No changes were made to the zone.");
                }
            }
        }