Пример #1
0
        internal static World FindWorldMatches(Player player, string name)
        {
            if (name == "-")
            {
                if (player.LastUsedWorldName != null)
                {
                    name = player.LastUsedWorldName;
                }
                else
                {
                    player.Message("Cannot repeat world name: you haven't used any names yet.");
                    return(null);
                }
            }
            player.LastUsedWorldName = name;
            World[] matches = WorldManager.FindWorlds(player, name);

            if (matches.Length == 0)
            {
                player.MessageNoWorld(name);
                return(null);
            }
            else if (matches.Length > 1)
            {
                player.MessageManyMatches("world", matches);
                return(null);
            }
            return(matches[0]);
        }
Пример #2
0
        public static World FindWorldOrPrintMatches([NotNull] Player player, [NotNull] string worldName)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (worldName == null)
            {
                throw new ArgumentNullException("worldName");
            }
            if (worldName == "-")
            {
                if (player.LastUsedWorldName != null)
                {
                    worldName = player.LastUsedWorldName;
                }
                else
                {
                    player.Message("Cannot repeat world name: you haven't used any names yet.");
                    return(null);
                }
            }
            player.LastUsedWorldName = worldName;

            World[] matches = FindWorlds(player, worldName);

            if (matches.Length == 0)
            {
                player.MessageNoWorld(worldName);
                return(null);
            }

            if (matches.Length > 1)
            {
                player.MessageManyMatches("world", matches);
                return(null);
            }
            return(matches[0]);
        }
Пример #3
0
        private static void PortalH(Player player, Command command)
        {
            try
            {
                String option = command.Next();

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

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

                            string blockTypeOrName = command.Next();

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

                            string portalName = command.Next();

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

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

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

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

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

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

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

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

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

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

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

                        player.Message(output.ToString());
                    }
                }
                else if (option.ToLower().Equals("enable"))
                {
                    player.PortalsEnabled = true;
                    player.Message("You enabled the use of portals.");
                }
                else if (option.ToLower().Equals("disable"))
                {
                    player.PortalsEnabled = false;
                    player.Message("You disabled the use of portals, type /portal enable to re-enable portals.");
                }
                else
                {
                    CdPortal.PrintUsage(player);
                }
            }
            catch (PortalException ex)
            {
                player.Message(ex.Message);
                Logger.Log(LogType.Error, "WorldCommands.PortalH: " + ex);
            }
            catch (Exception ex)
            {
                player.Message("Unexpected error: " + ex);
                Logger.Log(LogType.Error, "WorldCommands.PortalH: " + ex);
            }
        }
Пример #4
0
        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);
                }
            }
        }
Пример #5
0
 private static void HaxHandler(Player player, Command cmd)
 {
     string worldName = cmd.Next();
     if (string.IsNullOrEmpty(worldName) || worldName.Length < 1)
     {
         CdHax.PrintUsage(player);
         return;
     }
     World world = WorldManager.FindWorldOrPrintMatches(player, worldName);
     if (world == null)
     {
         player.MessageNoWorld(worldName);
         return;
     }
     string hax = cmd.Next();
     if (string.IsNullOrEmpty(hax) || hax.Length < 1)
     {
         CdHax.PrintUsage(player);
         return;
     }
     if (hax.ToLower() == "on" || hax.ToLower() == "true")
     {
         if (world.Hax == true)
         {
             player.Message("&sHax are already enabled on {0}", world.ClassyName);
             return;
         }
         world.Hax = true;
         Server.Message("&sHax have been enabled on {0}", world.ClassyName);
         foreach (Player p in world.Players)
         {
             p.JoinWorld(player.World, WorldChangeReason.Rejoin);
         }
         return;
     }
     if (hax.ToLower() == "off" || hax.ToLower() == "false")
     {
         if (world.Hax == false)
         {
             player.Message("&sHax are already disabled on {0}", world.ClassyName);
             return;
         }
         world.Hax = false;
         Server.Message("&sHax have been disabled on {0}", world.ClassyName);
         foreach (Player p in world.Players) //make all players rejoin to force changes
         {
             p.JoinWorld(player.World, WorldChangeReason.Rejoin);
         }
         return;
     }
 }
Пример #6
0
        private static void PortalH(Player player, CommandReader cmd) {
            try {
                string option = cmd.Next();
                if (string.IsNullOrEmpty(option)) {
                    CdPortal.PrintUsage(player);
                    return;
                }
                switch (option.ToLower()) {
                    case "create":
                    case "add":
                        if (player.Can(Permission.CreatePortals)) {
                            string addWorld = cmd.Next();
                            if (!string.IsNullOrEmpty(addWorld) && WorldManager.FindWorldExact(addWorld) != null) {
                                DrawOperation operation = new CuboidDrawOperation(player);
                                NormalBrush brush = new NormalBrush(Block.Water, Block.Water);

                                string blockTypeOrName = cmd.Next();
                                Block pblock;
                                if (blockTypeOrName != null && Map.GetBlockByName(blockTypeOrName, false, out pblock)) {
                                    if ((!validPBlocks.Contains(pblock) && pblock <= Block.StoneBrick) || (pblock == Block.Air && player.Info.Rank != RankManager.HighestRank)) {
                                        player.Message("Invalid block, choose a non-solid block");
                                        return;
                                    } else {
                                        brush = new NormalBrush(pblock, pblock);
                                    }
                                }
                                string addPortalName = cmd.Next();
                                if (string.IsNullOrEmpty(addPortalName)) {
                                    player.PortalName = null;
                                } else {
                                    if (!Portal.DoesNameExist(player.World, addPortalName)) {
                                        player.PortalName = addPortalName;
                                    } else {
                                        player.Message("A portal with name {0} already exists in this world.", addPortalName);
                                        return;
                                    }
                                }
                                World tpWorld = WorldManager.FindWorldExact(addWorld);
                                if (cmd.HasNext) {
                                    int x, y, z, rot = player.Position.R, lot = player.Position.L;
                                    if (cmd.NextInt(out x) && cmd.NextInt(out y) && cmd.NextInt(out z)) {
                                        if (cmd.HasNext && cmd.HasNext) {
                                            if (cmd.NextInt(out rot) && cmd.NextInt(out lot)) {
                                                if (rot > 255 || rot < 0) {
                                                    player.Message("R must be inbetween 0 and 255. Set to player R");
                                                    rot = player.Position.R;
                                                }
                                                if (lot > 255 || lot < 0) {
                                                    player.Message("L must be inbetween 0 and 255. Set to player L");
                                                    lot = player.Position.L;
                                                }
                                            }
                                        }
                                        if (x < 1 || x >= 1024 || y < 1 || y >= 1024 || z < 1 || z >= 1024) {
                                            player.Message("Coordinates are outside the valid range!");
                                            return;
                                        } else {
                                            player.PortalTPPos = new Position((short)(x * 32), (short)(y * 32), (short)(z * 32), (byte)rot, (byte)lot);
                                        }
                                    } else {
                                        player.PortalTPPos = tpWorld.map == null ? new Position(0, 0, 0) : tpWorld.map.Spawn;
                                    }
                                } else {
                                    player.PortalTPPos = tpWorld.map == null ? new Position(0, 0, 0) : tpWorld.map.Spawn;
                                }
                                operation.Brush = brush;
                                player.PortalWorld = addWorld;
                                player.SelectionStart(operation.ExpectedMarks, PortalCreateCallback, operation, Permission.CreatePortals);
                                player.Message("Click {0} blocks or use &H/Mark&S to mark the area of the portal.", operation.ExpectedMarks);
                            } else {
                                if (string.IsNullOrEmpty(addWorld)) {
                                    player.Message("No world specified.");
                                } else {
                                    player.MessageNoWorld(addWorld);
                                }
                            }
                        } else {
                            player.MessageNoAccess(Permission.CreatePortals);
                        }
                        break;
                    case "remove":
                    case "delete":
                        if (player.Can(Permission.CreatePortals)) {
                            string remPortalName = cmd.Next();
                            string remWString = cmd.Next();
                            World remWorld = player.World;
                            if (!string.IsNullOrEmpty(remWString)) {
                                remWorld = WorldManager.FindWorldOrPrintMatches(player, remWString);
                            }
                            if (remWorld == null) {
                                return;
                            }
                            if (string.IsNullOrEmpty(remPortalName)) {
                                player.Message("No portal name specified.");
                            } else {
                                if (remWorld.Portals != null && remWorld.Portals.Count > 0) {
                                    bool found = false;
                                    Portal portalFound = null;
                                    lock (remWorld.Portals.SyncRoot) {
                                        foreach (Portal portal in remWorld.Portals) {
                                            if (portal.Name.ToLower().Equals(remPortalName.ToLower())) {
                                                portalFound = portal;
                                                found = true;
                                                break;
                                            }
                                        }
                                        if (!found) {
                                            player.Message("Could not find portal by name {0}.", remPortalName);
                                        } else {
                                            portalFound.Remove(player, remWorld);
                                            player.Message("Portal was removed.");
                                        }
                                    }
                                } else {
                                    player.Message("Could not find portal as this world doesn't contain a portal.");
                                }
                            }
                        } else {
                            player.MessageNoAccess(Permission.CreatePortals);
                        }
                        break;
                    case "info":
                    case "i":
                        string iPortalName = cmd.Next();
                        string iWString = cmd.Next();
                        World iWorld = player.World;
                        if (!string.IsNullOrEmpty(iWString)) {
                            iWorld = WorldManager.FindWorldOrPrintMatches(player, iWString);
                        }
                        if (iWorld == null) {
                            return;
                        }
                        if (string.IsNullOrEmpty(iPortalName)) {
                            player.Message("No portal name specified.");
                        } else {
                            if (iWorld.Portals != null && iWorld.Portals.Count > 0) {
                                bool found = false;

                                lock (iWorld.Portals.SyncRoot) {
                                    foreach (Portal portal in iWorld.Portals) {
                                        if (portal.Name.ToLower().Equals(iPortalName.ToLower())) {
                                            World portalWorld = WorldManager.FindWorldExact(portal.World);
                                            player.Message("Portal {0}&S was created by {1}&S at {2} and teleports to world {3} at {4}&S.",
                                                portal.Name, PlayerDB.FindPlayerInfoExact(portal.Creator).ClassyName, portal.Created, portalWorld.ClassyName, portal.position().ToString());
                                            found = true;
                                        }
                                    }
                                }
                                if (!found) {
                                    player.Message("Could not find portal by name {0}.", iPortalName);
                                }
                            } else {
                                player.Message("Could not find portal as this world doesn't contain a portal.");
                            }
                        }
                        break;
                    case "list":
                    case "l":
                        string lWString = cmd.Next();
                        World lWorld = player.World;
                        if (!string.IsNullOrEmpty(lWString)) {
                            lWorld = WorldManager.FindWorldOrPrintMatches(player, lWString);
                        }
                        if (lWorld == null) {
                            return;
                        }
                        if (lWorld.Portals == null || lWorld.Portals.Count == 0) {
                            player.Message("There are no portals in {0}&S.", lWorld.ClassyName);
                        } else {
                            string[] portalNames = new string[lWorld.Portals.Count];
                            StringBuilder output = new StringBuilder("There are " + lWorld.Portals.Count + " portals in " + lWorld.ClassyName + "&S: ");
                            for (int i = 0; i < lWorld.Portals.Count; i++) {
                                portalNames[i] = ((Portal)lWorld.Portals[i]).Name;
                            }
                            output.Append(portalNames.JoinToString(", "));
                            player.Message(output.ToString());
                        }
                        break;
                    case "enable":
                    case "on":
                        player.PortalsEnabled = true;
                        player.Message("You enabled the use of portals.");
                        break;
                    case "disable":
                    case "off":
                        player.PortalsEnabled = false;
                        player.Message("You disabled the use of portals, type /portal enable to re-enable portals.");
                        break;
                    default:
                        CdPortal.PrintUsage(player);
                        break;
                }
            } catch (PortalException ex) {
                player.Message(ex.Message);
                Logger.Log(LogType.Error, "WorldCommands.PortalH: " + ex);
            } catch (Exception ex) {
                player.Message("Unexpected error: " + ex);
                Logger.Log(LogType.Error, "WorldCommands.PortalH: " + ex);
            }
        }
Пример #7
0
        static void EnvHandler( Player player, Command cmd )
        {
            if ( !ConfigKey.WoMEnableEnvExtensions.Enabled() ) {
                player.Message( "Env command is disabled on this server." );
                return;
            }
            string worldName = cmd.Next();
            World world;
            if ( worldName == null ) {
                player.MessageNoWorld( worldName );
                return;
            } else {
                world = WorldManager.FindWorldOrPrintMatches( player, worldName );
                if ( world == null ) return;
            }

            string variable = cmd.Next();
            string valueText = cmd.Next();
            if ( variable == null ) {
                player.Message( "Environment settings for {0}&S:", world.ClassyName );
                player.Message( "  Cloud: {0}   Fog: {1}   Sky: {2}",
                                world.CloudColor == -1 ? "normal" : '#' + world.CloudColor.ToString( "X6" ),
                                world.FogColor == -1 ? "normal" : '#' + world.FogColor.ToString( "X6" ),
                                world.SkyColor == -1 ? "normal" : '#' + world.SkyColor.ToString( "X6" ) );
                player.Message( "  Edge level: {0}  Edge texture: {1}",
                                world.EdgeLevel == -1 ? "normal" : world.EdgeLevel + " blocks",
                                world.EdgeBlock );
                if ( !player.IsUsingWoM ) {
                    player.Message( "  You need WoM client to see the changes." );
                }
                return;
            }
            #region 800Craft
            //Copyright (C) <2012> <Jon Baker>
            if ( variable.ToLower() == "terrain" ) {
                if ( valueText == null ) {
                    player.Message( "&A/Env [WorldName] terrain [Normal, arbot, cool, deadly, shroom, prometheus, woodpunk, fall, snow, tron, " +
                    "mario, highres, 8bit, simple, indev, messa, portal, dokucraft, doomcraft, hexeretic, zelda " );
                    return;
                }
                switch ( valueText.ToLower() ) {
                    case "normal":
                        world.Terrain = "bc4acee575474f5266105430c3cc628b8b3948a2";
                        break;
                    case "arbot":
                        world.Terrain = "1e3eb03d8efaa862679d36c9044ce47e861ea25e";
                        break;
                    case "cool":
                        world.Terrain = "165917066357092a2e7f6b0ec358c05b36b0efa7";
                        break;
                    case "deadly":
                        world.Terrain = "cb45307db4addbaac1504529fef79d773a6e31f5";
                        break;
                    case "shroom":
                        world.Terrain = "f31b086dbae92cc1741476a3697506192b8f5814";
                        break;
                    case "prometheus":
                        world.Terrain = "f66479f2d6c812806c3e768442d45a08a868ad16";
                        break;
                    case "woodpunk":
                        world.Terrain = "dff99c37e4a792e10c3b775e6bded725f18ed6fe";
                        break;
                    case "simple":
                        world.Terrain = "85f783c3a70c0c9d523eb39e080c2ed95f45bfc2";
                        break;
                    case "highres":
                        world.Terrain = "f3dac271d7bce9954baad46e183a6a910a30d13b";
                        break;
                    case "hexeretic":
                        world.Terrain = "d8e75476281087c8482ac636a8b8e4a59fadd525";
                        break;
                    case "tron":
                        world.Terrain = "ba851c9544ba5e4eed3a8fc9b8b5bf25a4dd45e0";
                        break;
                    case "8bit":
                        world.Terrain = "5a3fb1994e2ae526815ceaaca3a4dac0051aa890";
                        break;
                    case "mario":
                        world.Terrain = "e98a37ddccbc6144306bd08f41248324965c4e5a";
                        break;
                    case "fall":
                        world.Terrain = "b7c6dcb7a858639077f95ef94e8e2d51bedc3307";
                        break;
                    case "dokucraft":
                        world.Terrain = "a101cadafd02019e14d727d3329a923a40ef040b";
                        break;
                    case "indev":
                        world.Terrain = "73d1ef4441725bdcc9ac3616205faa3dff46e12a";
                        break;
                    case "doomcraft":
                        world.Terrain = "8b72beb6fea6ed1e01c1e32e08edf5f784bc919c";
                        break;
                    case "messa":
                        world.Terrain = "db0feeac8702704a3146a71365622db55fb5a4c4";
                        break;
                    case "portal":
                        world.Terrain = "d4b455134394763296994d0c819b0ac0ea338457";
                        break;
                    case "snow":
                        world.Terrain = "0b18fb3b41874ac5fbcb43532d62e6b742adc25e";
                        break;
                    case "zelda":
                        world.Terrain = "b25e3bffe57c4f6a35ae42bb6116fcb21c50fa6f";
                        break;
                    default:
                        player.Message( "&A/Env [WorldName] terrain [Normal, arbot, cool, deadly, shroom, prometheus, woodpunk, fall, snow, tron, " +
                    "mario, highres, 8bit, simple, indev, messa, portal, dokucraft, doomcraft, hexeretic, zelda " );
                        return;
                }
                player.Message( "Terrain Changed for {0}", world.ClassyName );
                WorldManager.UpdateWorldList();
                return;
            }

            if ( variable.ToLower() == "realistic" ) {
                if ( !world.RealisticEnv ) {
                    world.RealisticEnv = true;
                    player.Message( "Realistic Environment has been turned ON for world {0}", world.ClassyName );
                    return;
                } else {
                    world.RealisticEnv = false;
                    player.Message( "Realistic Environment has been turned OFF for world {0}", player.World.ClassyName );
                    return;
                }
            }
            #endregion

            if ( variable.Equals( "normal", StringComparison.OrdinalIgnoreCase ) ) {
                if ( cmd.IsConfirmed ) {
                    world.FogColor = -1;
                    world.CloudColor = -1;
                    world.SkyColor = -1;
                    world.EdgeLevel = -1;
                    world.EdgeBlock = Block.Water;
                    player.Message( "Reset enviroment settings for {0}", world.ClassyName );
                    WorldManager.SaveWorldList();
                } else {
                    player.Confirm( cmd, "Reset enviroment settings for {0}&S?", world.ClassyName );
                }
                return;
            }

            if ( valueText == null ) {
                CdEnv.PrintUsage( player );
                return;
            }

            int value = 0;
            if ( valueText.Equals( "normal", StringComparison.OrdinalIgnoreCase ) ) {
                value = -1;
            }

            switch ( variable.ToLower() ) {
                case "fog":
                    if ( value == -1 ) {
                        player.Message( "Reset fog color for {0}&S to normal", world.ClassyName );
                    } else {
                        try {
                            value = ParseHexColor( valueText );
                        } catch ( FormatException ) {
                            CdEnv.PrintUsage( player );
                            return;
                        }
                        player.Message( "Set fog color for {0}&S to #{1:X6}", world.ClassyName, value );
                    }
                    world.FogColor = value;
                    break;

                case "cloud":
                case "clouds":
                    if ( value == -1 ) {
                        player.Message( "Reset cloud color for {0}&S to normal", world.ClassyName );
                    } else {
                        try {
                            value = ParseHexColor( valueText );
                        } catch ( FormatException ) {
                            CdEnv.PrintUsage( player );
                            return;
                        }
                        player.Message( "Set cloud color for {0}&S to #{1:X6}", world.ClassyName, value );
                    }
                    world.CloudColor = value;
                    break;

                case "sky":
                    if ( value == -1 ) {
                        player.Message( "Reset sky color for {0}&S to normal", world.ClassyName );
                    } else {
                        try {
                            value = ParseHexColor( valueText );
                        } catch ( FormatException ) {
                            CdEnv.PrintUsage( player );
                            return;
                        }
                        player.Message( "Set sky color for {0}&S to #{1:X6}", world.ClassyName, value );
                    }
                    world.SkyColor = value;
                    break;

                case "level":
                    if ( value == -1 ) {
                        player.Message( "Reset edge level for {0}&S to normal", world.ClassyName );
                    } else {
                        try {
                            value = UInt16.Parse( valueText );
                        } catch ( OverflowException ) {
                            CdEnv.PrintUsage( player );
                            return;
                        } catch ( FormatException ) {
                            CdEnv.PrintUsage( player );
                            return;
                        }
                        player.Message( "Set edge level for {0}&S to {1}", world.ClassyName, value );
                    }
                    world.EdgeLevel = value;
                    break;

                case "edge":
                    Block block = Map.GetBlockByName( valueText );
                    if ( block == Block.Undefined ) {
                        CdEnv.PrintUsage( player );
                        return;
                    }
                    if ( block == Block.Water || valueText.Equals( "normal", StringComparison.OrdinalIgnoreCase ) ) {
                        player.Message( "Reset edge block for {0}&S to normal (water)", world.ClassyName );
                        world.EdgeBlock = Block.Water;
                    } else {
                        string textName = Map.GetEdgeTexture( block );
                        if ( textName == null ) {
                            player.Message( "Cannot use {0} for edge textures.", block );
                            return;
                        } else {
                            world.EdgeBlock = block;
                        }
                    }
                    break;

                case "side":
                case "sides":
                    if ( valueText.ToLower() == "on" ) {
                        if ( world.SideBlock != Block.Admincrete ) {
                            world.SideBlock = Block.Admincrete;
                            player.Message( "The sides of the world have been restored" );
                        }
                    } else {
                        if ( valueText.ToLower() == "off" ) {
                            world.SideBlock = Block.Air;
                            player.Message( "The sides of the world have been removed" );
                        }
                    }
                    break;

                default:
                    CdEnv.PrintUsage( player );
                    return;
            }

            WorldManager.SaveWorldList();
            if ( player.World == world ) {
                if ( player.IsUsingWoM ) {
                    player.Message( "Rejoin the world to see the changes." );
                } else {
                    player.Message( "You need WoM client to see the changes." );
                }
            }
        }
Пример #8
0
        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 );
            }
        }