JoinWorldNow() private method

private JoinWorldNow ( [ newWorld, bool doUseWorldSpawn, WorldChangeReason reason ) : bool
newWorld [
doUseWorldSpawn bool
reason WorldChangeReason
return bool
コード例 #1
0
ファイル: WorldCommands.cs プロジェクト: fragmer/fCraft
        static void JoinHandler( Player player, CommandReader cmd ) {
            string worldName = cmd.Next();
            if( worldName == null ) {
                CdJoin.PrintUsage( player );
                return;
            }

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

            World[] worlds = WorldManager.FindWorlds( player, worldName );

            if( worlds.Length > 1 ) {
                player.MessageManyMatches( "world", worlds );

            } else if( worlds.Length == 1 ) {
                World world = worlds[0];
                player.LastUsedWorldName = world.Name;
                switch( world.AccessSecurity.CheckDetailed( player.Info ) ) {
                    case SecurityCheckResult.Allowed:
                    case SecurityCheckResult.WhiteListed:
                        if( world.IsFull ) {
                            player.Message( "Cannot join {0}&S: world is full.", world.ClassyName );
                            return;
                        }
                        player.StopSpectating();
                        if( !player.JoinWorldNow( world, true, WorldChangeContext.ManualJoin ) ) {
                            player.Message( "ERROR: Failed to join world. See log for details." );
                        }
                        break;
                    case SecurityCheckResult.BlackListed:
                        player.Message( "Cannot join world {0}&S: you are blacklisted.",
                                        world.ClassyName );
                        break;
                    case SecurityCheckResult.RankTooLow:
                        player.Message( "Cannot join world {0}&S: must be {1}+",
                                        world.ClassyName, world.AccessSecurity.MinRank.ClassyName );
                        break;
                    // TODO: Uncomment
                    //case SecurityCheckResult.RankTooHigh:
                    //    player.Message("Cannot join world {0}&S: must be {1}-",
                    //                    world.ClassyName, world.AccessSecurity.MaxRank.ClassyName);
                    //    break;
                }

            } else {
                player.MessageNoWorld( worldName );
            }
        }
コード例 #2
0
ファイル: WorldCommands.cs プロジェクト: Rhinovex/LegendCraft
        static void JoinHandler(Player player, Command cmd)
        {
            string worldName = cmd.Next();
            if (worldName == null)
            {
                CdJoin.PrintUsage(player);
                return;
            }

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

            World[] worlds = WorldManager.FindWorlds(player, worldName);

            if (worlds.Length > 1)
            {
                player.MessageManyMatches("world", worlds);

            }
            else if (worlds.Length == 1)
            {
                World world = worlds[0];
                player.LastUsedWorldName = world.Name;
                switch (world.AccessSecurity.CheckDetailed(player.Info))
                {
                    case SecurityCheckResult.Allowed:
                    case SecurityCheckResult.WhiteListed:
                        if (world.IsFull)
                        {
                            player.Message("Cannot join {0}&S: world is full.", world.ClassyName);
                            return;
                        }
                        player.StopSpectating();
                        if (!player.JoinWorldNow(world, true, WorldChangeReason.ManualJoin))
                        {
                            player.Message("ERROR: Failed to join world. See log for details.");
                        }
                        break;
                    case SecurityCheckResult.BlackListed:
                        player.Message("Cannot join world {0}&S: you are blacklisted.",
                                        world.ClassyName);
                        break;
                    case SecurityCheckResult.RankTooLow:
                        player.Message("Cannot join world {0}&S: must be {1}+",
                                        world.ClassyName, world.AccessSecurity.MinRank.ClassyName);
                        break;
                }

            }
            else
            {
                // no worlds found - see if player meant to type in "/Join" and not "/TP"
                Player[] players = Server.FindPlayers(player, worldName, true);
                if (players.Length == 1)
                {
                    player.LastUsedPlayerName = players[0].Name;
                    player.StopSpectating();
                    player.ParseMessage("/TP " + players[0].Name, false, true);
                }
                else
                {
                    player.MessageNoWorld(worldName);
                }
            }
        }
コード例 #3
0
ファイル: CommandManager.cs プロジェクト: takaaptech/ProCraft
        /// <summary> Parses an unknown command as a /Join [command] command. </summary>
        /// <param name="player"> Player who issued the command. </param>
        /// <param name="cmd"> Command to be parsed as a worldname. </param>
        /// <returns> True if the command was a world and the user was able to join it, false if world doesn't exist, or user is unable to join the world. </returns>
        public static bool ParseUnknownCommand(Player player, CommandReader cmd)
        {
            //joinworld or tp to player
            if (cmd.RawMessage.IndexOf(' ') == -1 && player != Player.Console)
            {
                string cmdString  = cmd.RawMessage.Substring(1);
                bool   wasWorldTP = false;
                if (cmdString == "-")
                {
                    if (player.LastUsedWorldName != null)
                    {
                        cmdString = player.LastUsedWorldName;
                    }
                    else
                    {
                        return(false);
                    }
                }
                World[] worlds = WorldManager.FindWorlds(player, cmdString);

                if (worlds.Length == 1)
                {
                    World world = worlds[0];
                    if (world.Name.StartsWith("PW_"))
                    {
                        return(false);
                    }
                    player.LastUsedWorldName = world.Name;
                    switch (world.AccessSecurity.CheckDetailed(player.Info))
                    {
                    case SecurityCheckResult.Allowed:
                    case SecurityCheckResult.WhiteListed:
                        if (world.IsFull)
                        {
                            break;
                        }
                        if (cmd.IsConfirmed)
                        {
                            if (player.JoinWorldNow(world, true, WorldChangeReason.ManualJoin))
                            {
                                wasWorldTP = true;
                            }
                            break;
                        }
                        if (player.World.Name.CaselessEquals("tutorial") && !player.Info.HasRTR)
                        {
                            player.Confirm(cmd,
                                           "&SYou are choosing to skip the rules, if you continue you will spawn here the next time you log in.");
                            return(true);
                        }
                        player.StopSpectating();
                        if (player.JoinWorldNow(world, true, WorldChangeReason.ManualJoin))
                        {
                            wasWorldTP = true;
                            break;
                        }
                        break;

                    case SecurityCheckResult.BlackListed:
                        break;

                    case SecurityCheckResult.RankTooLow:
                        break;
                    }
                    if (wasWorldTP)
                    {
                        player.Message("&H{0}&S is not a command, but it part of a world name, so you have been teleported to {1}&S instead", cmd.RawMessage, world.ClassyName);
                        player.SendToSpectators(cmd.RawMessage + " -> /Join {0}", world.Name);
                        Logger.Log(LogType.UserCommand, "{0}: /Join {1}", player.Name, world.Name);
                        return(true);
                    }
                }
            }
            return(false);
        }