Example #1
0
 public void Write(NetworkClient client)
 {
     client.WSock.WriteByte(Id);
         client.WSock.WriteByte(EntityId);
         client.WSock.WriteString(ModelName);
         client.WSock.Purge();
 }
Example #2
0
        static void BoxHandler(NetworkClient client, HypercubeMap map, Vector3S location, byte mode, Block block)
        {
            if (mode != 1)
                return;

            switch (client.CS.MyEntity.BuildState) {
                case 0:
                    client.CS.MyEntity.ClientState.SetCoord(location, 0);
                    client.CS.MyEntity.BuildState = 1;
                    break;
                case 1:
                    var coord1 = client.CS.MyEntity.ClientState.GetCoord(0);
                    var blocks = Math.Abs(location.X - coord1.X)*Math.Abs(location.Y - coord1.Y)*
                                 Math.Abs(location.Z - coord1.Z);
                    var replaceBlock = client.CS.MyEntity.ClientState.GetString(0);

                    if (blocks < 50000) {
                        map.BuildBox(client, coord1.X, coord1.Y, coord1.Z, location.X, location.Y, location.Z, block,
                            String.IsNullOrEmpty(replaceBlock)
                                ? ServerCore.Blockholder.UnknownBlock
                                : ServerCore.Blockholder.GetBlock(replaceBlock), false, 1, true, false);

                        Chat.SendClientChat(client, "§SBox created.");
                    }
                    else
                        Chat.SendClientChat(client, "§EBox too large.");

                    client.CS.MyEntity.SetBuildmode("");
                    break;
            }
        }
Example #3
0
        /// <summary>
        /// Sends all server supported extensions to the client.
        /// </summary>
        /// <param name="client"></param>
        public static void CPEHandshake(NetworkClient client)
        {
            var cExtInfo = new ExtInfo {AppName = "Hypercube Server", ExtensionCount = SupportedExtensions};
            client.SendQueue.Enqueue(cExtInfo);

            var cExtEntry = new ExtEntry {ExtName = "CustomBlocks", Version = CustomBlocksVersion};
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "EmoteFix";
            cExtEntry.Version = EmoteFixVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "HeldBlock";
            cExtEntry.Version = HeldBlockVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "ClickDistance";
            cExtEntry.Version = ClickDistanceVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "ChangeModel";
            cExtEntry.Version = ChangeModelVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "ExtPlayerList";
            cExtEntry.Version = ExtPlayerListVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "EnvWeatherType";
            cExtEntry.Version = EnvWeatherTypeVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "EnvMapAppearance";
            cExtEntry.Version = EnvMapAppearanceVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "MessageTypes";
            cExtEntry.Version = MessageTypesVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "BlockPermissions";
            cExtEntry.Version = BlockPermissionsVersion;
            client.SendQueue.Enqueue(cExtEntry);

            //CExtEntry.ExtName = "TextHotKey";
            //CExtEntry.Version = TextHotKeyVersion;
            //CExtEntry.Write(Client);

            //CExtEntry.ExtName = "HackControl";
            //CExtEntry.Version = HackControlVersion;
            //CExtEntry.Write(Client);

            cExtEntry.ExtName = "SelectionCuboid";
            cExtEntry.Version = SelectionCuboidVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "EnvColors";
            cExtEntry.Version = EnvColorsVersion;
            client.SendQueue.Enqueue(cExtEntry);
        }
Example #4
0
        public void Call(NetworkClient client, string[] args, string text1, string text2)
        {
            if (!CanBeCalled(client)) {
                Chat.SendClientChat(client, "§EYou do not have permission to use this command.");
                return;
            }

            if (!string.IsNullOrEmpty(Plugin))
                ServerCore.Luahandler.RunFunction(Plugin, client, args, text1, text2); // -- Run lua plugin for this command.
            else
                Handler(client, args, text1, text2);
        }
Example #5
0
        static void CreateTPHandler(NetworkClient client, HypercubeMap map, Vector3S location, byte mode, Block block)
        {
            if (mode != 1)
                return;

            var state = client.CS.MyEntity.BuildState;

            switch (state) {
                case 0:
                    client.CS.MyEntity.ClientState.SetCoord(location.X, location.Y, location.Z, 1);
                    client.CS.MyEntity.BuildState = 1;
                    return;
                case 1:
                    var destCoord = client.CS.MyEntity.ClientState.GetCoord(0);
                    var destRot = client.CS.MyEntity.ClientState.GetInt(0);
                    var destLook = client.CS.MyEntity.ClientState.GetInt(1);
                    var startCoord = client.CS.MyEntity.ClientState.GetCoord(1);
                    var endCoord = new Vector3S { X = location.X, Y = location.Y, Z = location.Z };
                    var teleName = client.CS.MyEntity.ClientState.GetString(0);
                    var destMap = HypercubeMap.GetMap(client.CS.MyEntity.ClientState.GetString(1));

                    // -- Move things around so the smaller is the start, the larger being the end.
                    if (startCoord.X > location.X) {
                        endCoord.X = startCoord.X;
                        startCoord.X = location.X;
                    }

                    if (startCoord.Y > location.Y) {
                        endCoord.Y = startCoord.Y;
                        startCoord.Y = location.Y;
                    }

                    if (startCoord.Z > location.Z) {
                        endCoord.Z = startCoord.Z;
                        startCoord.Z = location.Z;
                    }

                    client.CS.CurrentMap.Teleporters.CreateTeleporter(teleName, startCoord, endCoord, destCoord, (byte)destLook, (byte)destRot, destMap);
                    Chat.SendClientChat(client, "§STeleporter created.");
                    client.CS.MyEntity.SetBuildmode("");
                    break;
            }
        }
Example #6
0
        /// <summary>
        /// Handles a client that is disconnecting
        /// </summary>
        /// <param name="client">The client that has disconnected.</param>
        public void HandleDisconnect(NetworkClient client)
        {
            lock (ClientLock) {
                Clients.Remove(client);
            }

            try {
                client.BaseSocket.Close();
            } catch (IOException) {
            }

            if (!client.CS.LoggedIn)
                return;

            client.CS.LoggedIn = false;

            lock (client.CS.CurrentMap.ClientLock) {
                client.CS.CurrentMap.Clients.Remove(client.CS.Id);
                client.CS.CurrentMap.CreateClientList();
            }

            if (client.CS.MyEntity != null) {
                client.CS.CurrentMap.DeleteEntity(ref client.CS.MyEntity);
                ServerCore.FreeEids.Push((short)client.CS.MyEntity.Id);
            }

            ServerCore.OnlinePlayers -= 1;
            ServerCore.FreeIds.Push(client.CS.NameId);
            LoggedClients.Remove(client.CS.LoginName);
            IntLoggedClients.Remove(client.CS.Id);
            CreateLists();

            var remove = new ExtRemovePlayerName {NameId = client.CS.NameId};

            foreach (var c in ClientList) {
                if (c.CS.CPEExtensions.ContainsKey("ExtPlayerList"))
                    c.SendQueue.Enqueue(remove);
            }

            ServerCore.Logger.Log("Network", "Player " + client.CS.LoginName + " has disconnected.", LogType.Info); // -- Notify of their disconnection.
            ServerCore.Luahandler.RunFunction("E_PlayerDisconnect", client.CS.LoginName);
            Chat.SendGlobalChat(ServerCore.TextFormats.SystemMessage + "Player " + client.CS.FormattedName + ServerCore.TextFormats.SystemMessage + " left.");
        }
Example #7
0
        static void RulesHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            Chat.SendClientChat(client, "&6Server Rules:");

            for (var i = 0; i < ServerCore.Rules.Count; i++)
                Chat.SendClientChat(client, "&6" + (i + 1) + ": " + ServerCore.Rules[i]);
        }
Example #8
0
        static void PlayersHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            var onlineString = "§SOnline Players: " + ServerCore.Nh.Clients.Count + "<br>";

            foreach (var hm in ServerCore.Maps.Values) {
                onlineString += "§S" + hm.CWMap.MapName + "&f: ";

                foreach(var c in hm.ClientsList)
                    onlineString += c.CS.FormattedName + " §D ";

                onlineString += "<br>";
            }

            Chat.SendClientChat(client, onlineString);
        }
Example #9
0
        static void MapsHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            var mapString = "§SMaps:<br>";

            foreach (var m in ServerCore.Maps.Values) {
                if (client.HasAllPermissions(m.Showperms.Values.ToList()))
                    mapString += "§S" + m.CWMap.MapName + " §D ";
            }

            Chat.SendClientChat(client, mapString);
        }
Example #10
0
 static void InfoHandler(NetworkClient client, string[] args, string text1, string text2)
 {
     Chat.SendClientChat(client, "§SServer Info:");
     Chat.SendClientChat(client, "§SThis server runs the &8Hypercube §SSoftware, by Umby24.");
     Chat.SendClientChat(client, "§SServer Version: " + Assembly.GetExecutingAssembly().GetName().Version + " on .NET " + Environment.Version + " (" + Environment.OSVersion + ")");
     Chat.SendClientChat(client, "§SUptime: " + (DateTime.UtcNow - ServerCore.Uptime).ToString("hh"));
 }
Example #11
0
        static void Getrankhandler(NetworkClient client, string[] args, string text1, string text2)
        {
            if (args.Length != 1) {
                Chat.SendClientChat(client, "§EIncorrect usage. See /cmdhelp getrank.");
                return;
            }

            args[0] = ServerCore.DB.GetPlayerName(args[0]);

            if (args[0] == "") {
                Chat.SendClientChat(client, "§ECould not find the player.");
                return;
            }

            var playerRanks = RankContainer.SplitRanks(ServerCore.DB.GetDatabaseString(args[0], "PlayerDB", "Rank"));
            var playerSteps = RankContainer.SplitSteps(ServerCore.DB.GetDatabaseString(args[0], "PlayerDB", "RankStep"));
            var playerInfo = "§SRank(s) for " + args[0] + ": ";

            foreach (var r in playerRanks)
                playerInfo += r.Prefix + r.Name + r.Suffix + "(" + playerSteps[playerRanks.IndexOf(r)] + "), ";

            playerInfo = playerInfo.Substring(0, playerInfo.Length - 1); // -- Remove the final comma.
            playerInfo += "<br>";

            Chat.SendClientChat(client, playerInfo);
        }
Example #12
0
        static void CmdhelpHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            if (args.Length == 0) {
                Chat.SendClientChat(client, "§E&fUsage of this command: /cmdhelp [command].");
                return;
            }

            if (ServerCore.Commandholder.CommandDict.ContainsKey("/" + args[0].ToLower()) == false) {
                Chat.SendClientChat(client, "§E&fCommand not found.");
                return;
            }

            if (!ServerCore.Commandholder.CommandDict["/" + args[0]].CanBeSeen(client)) {
                Chat.SendClientChat(client, "§E&fCommand not found.");
                return;
            }

            var thisCommand = ServerCore.Commandholder.CommandDict["/" + args[0].ToLower()];
            Chat.SendClientChat(client, "§S/" + args[0]);
            Chat.SendClientChat(client, thisCommand.Help);
        }
Example #13
0
        /// <summary>
        /// Updates a client on everyone's ExtPlayerList (Ex. Client changed maps.)
        /// </summary>
        /// <param name="client">Client that has moved maps.</param>
        public static void UpdateExtPlayerList(NetworkClient client)
        {
            var toUpdate = new ExtAddPlayerName
            {
                NameId = client.CS.NameId,
                ListName = client.CS.FormattedName,
                PlayerName = client.CS.LoginName,
                GroupName = ServerCore.TextFormats.ExtPlayerList + client.CS.CurrentMap.CWMap.MapName,
                GroupRank = 0
            };

            lock (ServerCore.Nh.ClientLock) {
                foreach (var c in ServerCore.Nh.Clients) {
                    if (c.CS.CPEExtensions.ContainsKey("ExtPlayerList"))
                        c.SendQueue.Enqueue(toUpdate);
                }
            }
        }
Example #14
0
        /// <summary>
        /// Does initial setup of ExtPlayerList for a player that is logging in.
        /// </summary>
        /// <param name="client">Client logging in</param>
        public static void SetupExtPlayerList(NetworkClient client)
        {
            var extPlayerListPacket = new ExtAddPlayerName {GroupRank = 0};

            lock (ServerCore.Nh.ClientLock) {
                foreach (var c in ServerCore.Nh.Clients) {
                    if (c != client) {
                        if (c.CS.CPEExtensions.ContainsKey("ExtPlayerList")) {
                            extPlayerListPacket.NameId = client.CS.NameId;
                            extPlayerListPacket.ListName = client.CS.FormattedName;
                            extPlayerListPacket.PlayerName = client.CS.LoginName;
                            extPlayerListPacket.GroupName = ServerCore.TextFormats.ExtPlayerList +
                                                            client.CS.CurrentMap.CWMap.MapName;

                            c.SendQueue.Enqueue(extPlayerListPacket);
                        }

                        if (!client.CS.CPEExtensions.ContainsKey("ExtPlayerList"))
                            continue;

                        extPlayerListPacket.NameId = c.CS.NameId;
                        extPlayerListPacket.ListName = c.CS.FormattedName;
                        extPlayerListPacket.PlayerName = c.CS.LoginName;
                        extPlayerListPacket.GroupName = ServerCore.TextFormats.ExtPlayerList + c.CS.CurrentMap.CWMap.MapName;
                        client.SendQueue.Enqueue(extPlayerListPacket);
                    } else {
                        if (!client.CS.CPEExtensions.ContainsKey("ExtPlayerList"))
                            continue;

                        extPlayerListPacket.NameId = client.CS.NameId;
                        extPlayerListPacket.ListName = client.CS.FormattedName;
                        extPlayerListPacket.PlayerName = client.CS.LoginName;
                        extPlayerListPacket.GroupName = ServerCore.TextFormats.ExtPlayerList +
                                                        client.CS.CurrentMap.CWMap.MapName;
                        client.SendQueue.Enqueue(extPlayerListPacket);
                    }
                }
            }
        }
Example #15
0
        /// <summary>
        /// Sends additional packets to clients after sending the map to the client.
        /// </summary>
        /// <param name="client"></param>
        public static void PostMapActions(NetworkClient client)
        {
            int mapAppearance, blockPerms, weatherVer, colorVer;

            // -- EnvMapAppearance
            if (client.CS.CPEExtensions.TryGetValue("EnvMapAppearance", out mapAppearance) &&
                mapAppearance == EnvMapAppearanceVersion) {

                var cpeData = client.CS.CurrentMap.CPESettings;

                var mapApprPacket = new EnvSetMapAppearance {
                    EdgeBlock = cpeData.EdgeBlock,
                    SideBlock = cpeData.SideBlock,
                    SideLevel = cpeData.SideLevel,
                    TextureUrl = cpeData.TextureUrl
                };

                // -- Customblocks compatibility check
                if (mapApprPacket.EdgeBlock > 49) {
                    var mBlock = ServerCore.Blockholder.GetBlock(mapApprPacket.EdgeBlock);

                    if (mBlock.CPELevel > client.CS.CustomBlocksLevel)
                        mapApprPacket.EdgeBlock = (byte)mBlock.CPEReplace;
                }

                if (mapApprPacket.SideBlock > 49) {
                    var mBlock = ServerCore.Blockholder.GetBlock(mapApprPacket.SideBlock);

                    if (mBlock.CPELevel > client.CS.CustomBlocksLevel)
                        mapApprPacket.SideBlock = (byte)mBlock.CPEReplace;
                }

                client.SendQueue.Enqueue(mapApprPacket);
            }

            // -- BlockPermissions

            if (client.CS.CPEExtensions.TryGetValue("BlockPermissions", out blockPerms) &&
                blockPerms == BlockPermissionsVersion) {

                foreach (var block in ServerCore.Blockholder.NumberList) { // -- For every block
                    if (block.CPELevel > client.CS.CustomBlocksLevel) // -- If its within this player's CustomBlock support
                        continue;

                    if (block.Name == "Unknown") // -- If its not an unknown block
                        continue;

                    if (block.Special) // -- If it's not a custom block.
                        continue;

                    var disallowPlace = new SetBlockPermissions { // -- THen set the permissions for the block
                        AllowDeletion = 1,
                        AllowPlacement = 1,
                        BlockType = block.OnClient,
                    };

                    if (!client.HasAllPermissions(block.PlacePermissions)) {
                        disallowPlace.AllowPlacement = 0;
                    }

                    if (!client.HasAllPermissions(block.DeletePermissions))
                        disallowPlace.AllowDeletion = 0;

                    if (disallowPlace.AllowDeletion != 1 || disallowPlace.AllowPlacement != 1) // -- Only send if we're changing permissions though
                        client.SendQueue.Enqueue(disallowPlace);
                }
            }

            // -- EnvWeatherType
            if (client.CS.CPEExtensions.TryGetValue("EnvWeatherType", out weatherVer) &&
                weatherVer == EnvWeatherTypeVersion) {

                var weather = new EnvSetWeatherType {
                    WeatherType = client.CS.CurrentMap.CPESettings.Weather,
                };

                client.SendQueue.Enqueue(weather);
            }

            // -- EnvColors
            if (client.CS.CPEExtensions.TryGetValue("EnvColors", out colorVer) &&
                colorVer == EnvColorsVersion) {

                // -- if envcolors is enabled on the map
                if (client.CS.CurrentMap.CPESettings.EnvColorsVersion > 0) {
                    var skyColor = new EnvSetColor {
                        ColorType = (byte) EnvSetColor.ColorTypes.SkyColor,
                        Red = client.CS.CurrentMap.CPESettings.SkyColor[0],
                        Green = client.CS.CurrentMap.CPESettings.SkyColor[1],
                        Blue = client.CS.CurrentMap.CPESettings.SkyColor[2],
                    };

                    var cloudColor = new EnvSetColor {
                        ColorType = (byte)EnvSetColor.ColorTypes.CloudColor,
                        Red = client.CS.CurrentMap.CPESettings.CloudColor[0],
                        Green = client.CS.CurrentMap.CPESettings.CloudColor[1],
                        Blue = client.CS.CurrentMap.CPESettings.CloudColor[2],
                    };

                    var fogColor = new EnvSetColor {
                        ColorType = (byte)EnvSetColor.ColorTypes.FogColor,
                        Red = client.CS.CurrentMap.CPESettings.FogColor[0],
                        Green = client.CS.CurrentMap.CPESettings.FogColor[1],
                        Blue = client.CS.CurrentMap.CPESettings.FogColor[2],
                    };

                    var ambeintColor = new EnvSetColor {
                        ColorType = (byte)EnvSetColor.ColorTypes.AmbientColor,
                        Red = client.CS.CurrentMap.CPESettings.AmbientColor[0],
                        Green = client.CS.CurrentMap.CPESettings.AmbientColor[1],
                        Blue = client.CS.CurrentMap.CPESettings.AmbientColor[2],
                    };

                    var sunlightColor = new EnvSetColor {
                        ColorType = (byte)EnvSetColor.ColorTypes.SunlightColor,
                        Red = client.CS.CurrentMap.CPESettings.SunlightColor[0],
                        Green = client.CS.CurrentMap.CPESettings.SunlightColor[1],
                        Blue = client.CS.CurrentMap.CPESettings.SunlightColor[2],
                    };

                    client.SendQueue.Enqueue(skyColor);
                    client.SendQueue.Enqueue(cloudColor);
                    client.SendQueue.Enqueue(fogColor);
                    client.SendQueue.Enqueue(ambeintColor);
                    client.SendQueue.Enqueue(sunlightColor);
                }
            }
        }
Example #16
0
        /// <summary>
        /// Verifys the authenticity of someone logging in.
        /// </summary>
        /// <param name="client">The client to verify</param>
        /// <returns>true if verified, false if not.</returns>
        public bool VerifyClientName(NetworkClient client)
        {
            if (client.CS.Ip == "127.0.0.1" || client.CS.Ip.Substring(0, 7) == "192.168" || ServerCore.Nh.VerifyNames == false)
                return true;

            var md5Creator = MD5.Create();
            var correct = BitConverter.ToString(md5Creator.ComputeHash(Encoding.ASCII.GetBytes(Salt + client.CS.LoginName))).Replace("-", "");

            if (correct.Trim().ToLower() == client.CS.MpPass.Trim().ToLower())
                return true;

            ServerCore.Logger.Log("Heartbeat", correct.Trim() + " != " + client.CS.MpPass.Trim(), LogType.Warning);
            return false;
        }
Example #17
0
 static void AboutHandler(NetworkClient client, string[] args, string text1, string text2)
 {
     Chat.SendClientChat(client, "§SServer Software:&f ServerCore");
     Chat.SendClientChat(client, "§SServer Developer:&f Umby24");
     Chat.SendClientChat(client, "§SServer Version:&f 0.0 ALPHA");
     Chat.SendClientChat(client, "§SThis server is written from scratch in C#<br>§Sand supports Lua scripting!");
 }
Example #18
0
        static void BindHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            switch (args.Length) {
                case 0:
                    Chat.SendClientChat(client, "§SYour currently bound block is &f" + client.CS.MyEntity.Boundblock.Name + "§S.");
                    Chat.SendClientChat(client, "§SLooking for fCraft style bind? See /cmdhelp bind and /cmdhelp material.");
                    break;
                case 1:
                    // -- Change the Bound block only.
                    var newBlock = ServerCore.Blockholder.GetBlock(text1);

                    if (newBlock == null) {
                        Chat.SendClientChat(client, "§ECouldn't find a block called '" + text1 + "'.");
                        return;
                    }

                    client.CS.MyEntity.Boundblock = newBlock;
                    ServerCore.DB.SetDatabase(client.CS.LoginName, "PlayerDB", "BoundBlock", newBlock.Id);
                    Chat.SendClientChat(client, "§SYour bound block is now " + newBlock.Name);
                    break;
                case 2:
                    var newBlocka = ServerCore.Blockholder.GetBlock(args[0]);

                    if (newBlocka == null) {
                        Chat.SendClientChat(client, "§ECouldn't find a block called '" + args[0] + "'.");
                        return;
                    }

                    var materialBlock = ServerCore.Blockholder.GetBlock(text2);

                    if (materialBlock == null) {
                        Chat.SendClientChat(client, "§ECouldn't find a block called '" + args[1] + "'.");
                        return;
                    }

                    client.CS.MyEntity.Boundblock = newBlocka;
                    ServerCore.DB.SetDatabase(client.CS.LoginName, "PlayerDB", "BoundBlock", newBlocka.Id);
                    Chat.SendClientChat(client, "§SYour bound block is now " + newBlocka.Name);

                    client.CS.MyEntity.BuildMaterial = materialBlock;
                    Chat.SendClientChat(client, "§SYour build material is now " + materialBlock.Name);
                    break;
                default:
                    Chat.SendClientChat(client, "§EWrong number of arguments supplied. See /cmdhelp bind");
                    break;
            }
        }
Example #19
0
        static void CommandsHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            if (args.Length == 0) { // -- List command groups
                Chat.SendClientChat(client, "§SCommand groups:");
                Chat.SendClientChat(client, "&a    All");

                foreach (var a in ServerCore.Commandholder.Groups.Keys)
                    Chat.SendClientChat(client, "&a    " + a);

            } else if (args.Length == 1) { // -- list a group.
                if (!ServerCore.Commandholder.Groups.ContainsKey(args[0]) && args[0].ToLower() != "all") {
                    Chat.SendClientChat(client, "§EGroup '" + args[0] + "' not found.");
                    return;
                }

                var commandString = "§D&f ";
                var currentLen = 5;

                if (args[0].ToLower() == "all") {
                    foreach (var b in ServerCore.Commandholder.CommandDict.Keys) {
                        if (!ServerCore.Commandholder.CommandDict[b].CanBeSeen(client))
                            continue;

                        if ((b.Substring(1, b.Length - 1) + " §D&f ").Length + currentLen >= 59) {
                            commandString += "<br>§D&f " + b.Substring(1, b.Length - 1) + " §D&f ";
                            currentLen = ("§D&f " + b.Substring(1, b.Length - 1) + " §D&f ").Length;
                        } else {
                            commandString += b.Substring(1, b.Length - 1) + " §D&f ";
                            currentLen += (b.Substring(1, b.Length - 1) + " §D&f ").Length;
                        }
                    }

                    Chat.SendClientChat(client, "&aAll Commands:<br>" + commandString);
                    return;
                }

                foreach (var b in ServerCore.Commandholder.Groups[args[0]]) {
                    if (!ServerCore.Commandholder.CommandDict["/" + b].CanBeSeen(client))
                        continue;

                    if ((b.Substring(1, b.Length - 1) + " §D&f ").Length + currentLen >= 59) {
                        commandString += "<br>§D&f " + b + " §D&f ";
                        currentLen = ("§D&f " + b + " §D&f ").Length;
                    } else {
                        commandString += b + " §D&f ";
                        currentLen += (b + " §D&f ").Length;
                    }
                }

                Chat.SendClientChat(client, "&aGroup " + args[0]);
                Chat.SendClientChat(client, commandString);
            } else {
                Chat.SendClientChat(client, "§EWrong number of arguments supplied. See /cmdhelp commands");
            }
        }
Example #20
0
        private static void BoxHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            if (!String.IsNullOrEmpty(text1)) {
                var block = ServerCore.Blockholder.GetBlock(text1);

                if (block == ServerCore.Blockholder.UnknownBlock) {
                    Chat.SendClientChat(client, "§ECould not find a block called '" + text1 + "'.");
                    return;
                }

                client.CS.MyEntity.SetBuildmode("Box");
                client.CS.MyEntity.ClientState.SetString(text1, 0);
                Chat.SendClientChat(client, "§SBuildmode: Box started. Place two blocks to build a box.");
                Chat.SendClientChat(client, "§Replacing: " + block.Name);

                client.CS.MyEntity.BuildState = 0;
                return;
            }

            Chat.SendClientChat(client, "§SBuildmode: Box started. Place two blocks to build a box.");
            client.CS.MyEntity.SetBuildmode("Box");
            client.CS.MyEntity.BuildState = 0;
        }
Example #21
0
 static void GlobalHandler(NetworkClient client, string[] args, string text1, string text2)
 {
     if (args.Length == 0) {
         // -- Toggle.
         if (ServerCore.DB.GetDatabaseInt(client.CS.LoginName, "PlayerDB", "Global") == 1) {
             client.CS.Global = false;
             Chat.SendClientChat(client, "§SGlobal chat is now off by default.");
             ServerCore.DB.SetDatabase(client.CS.LoginName, "PlayerDB", "Global", "0");
         } else {
             client.CS.Global = true;
             Chat.SendClientChat(client, "§SGlobal chat is now on by default.");
             ServerCore.DB.SetDatabase(client.CS.LoginName, "PlayerDB", "Global", "1");
         }
     } else if (args.Length == 1) {
         if (args[0].ToLower() == "on" || args[0].ToLower() == "true") {
             client.CS.Global = true;
             Chat.SendClientChat(client, "§SGlobal chat is now on by default.");
             ServerCore.DB.SetDatabase(client.CS.LoginName, "PlayerDB", "Global", "1");
         } else if (args[0].ToLower() == "off" || args[0].ToLower() == "false") {
             client.CS.Global = false;
             Chat.SendClientChat(client, "§SGlobal chat is now off by default.");
             ServerCore.DB.SetDatabase(client.CS.LoginName, "PlayerDB", "Global", "0");
         }
     } else
         Chat.SendClientChat(client, "§EIncorrect number of arguments, see /cmdhelp global.");
 }
Example #22
0
 static void CancelHandler(NetworkClient client, string[] args, string text1, string text2)
 {
     client.CS.MyEntity.SetBuildmode("");
     Chat.SendClientChat(client, "§SBuildmodes canceled.");
 }
Example #23
0
        static void MapHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            if (args.Length == 0) {
                Chat.SendClientChat(client, "§EInvalid number of arguments. See /cmdhelp map");
                return;
            }

            HypercubeMap m;
            ServerCore.Maps.TryGetValue(args[0], out m);

            if (m != null)
                client.ChangeMap(m);
             else
                Chat.SendClientChat(client, "§EMap '" + args[0] + "' not found.");
        }
Example #24
0
        static void MaterialHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            if (args.Length == 0) {
                Chat.SendClientChat(client, "§SYour build material has been reset.");
                client.CS.MyEntity.BuildMaterial = ServerCore.Blockholder.GetBlock("");
                return;
            }

            var newBlock = ServerCore.Blockholder.GetBlock(text1);

            if (newBlock == null || newBlock.Name == "Unknown") {
                Chat.SendClientChat(client, "§ECouldn't find a block called '" + text1 + "'.");
                return;
            }

            client.CS.MyEntity.BuildMaterial = newBlock;
            Chat.SendClientChat(client, "§SYour build material is now " + newBlock.Name);
        }
Example #25
0
        private static void ModelHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            if (args.Length > 1) {
                Chat.SendClientChat(client, "§EInvalid number of arguments. See /cmdhelp model");
                return;
            }

            if (args.Length == 0) {
                client.CS.MyEntity.Model = "default";
                Chat.SendClientChat(client, "§SYour model has been reset.");
                return;
            }

            int block;

            if (int.TryParse(args[0], out block)) {
                if (block > 66 || block < 1) {
                    Chat.SendClientChat(client, "§EInvalid block number. Must be from 1-66.");
                    return;
                }

                client.CS.MyEntity.Model = block.ToString();
                Chat.SendClientChat(client, "§SModel changed.");
                return;
            }

            switch (args[0].ToLower()) {
                case "croc":
                case "skele":
                    args[0] = "skele";
                    goto case "skeleton";
                case "skeleton":
                case "spider":
                case "crocodile":
                    args[0] = "croc";
                    goto case "pig";
                case "pig":
                case "printer":
                case "chicken":
                case "creeper":
                case "sheep":
                case "zombie":
                    client.CS.MyEntity.Model = args[0].ToLower();
                    break;
                default:
                    client.CS.MyEntity.Model = "default";
                    break;
            }
            Chat.SendClientChat(client, "§SModel changed.");
        }
Example #26
0
        static void MaterialsHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            if (args.Length > 0)
                Chat.SendClientChat(client, "§SWarning: This command does not accept arguments.");

            var list = "";

            foreach (var b in ServerCore.Blockholder.NameList.Values) {
                if (b.Special)
                    list += b.Name + " §D&f ";
            }

            Chat.SendClientChat(client, "§SMaterials:");
            Chat.SendClientChat(client, list);
        }
Example #27
0
        static void RanksHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            Chat.SendClientChat(client, "§SGroups&f:");
            var groupDict = new Dictionary<string, string>();

            foreach (var r in ServerCore.Rankholder.NameList.Values) {
                if (groupDict.Keys.Contains(r.Group))
                    groupDict[r.Group] += "§S| " + r.Prefix + r.Name + r.Suffix + " ";
                else
                    groupDict.Add(r.Group, "§S" + r.Group + "&f: " + r.Prefix + r.Name + r.Suffix + " ");
            }

            foreach (var b in groupDict.Keys)
                Chat.SendClientChat(client, groupDict[b]);
        }
Example #28
0
        static void PlaceHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            var myLoc = client.CS.MyEntity.GetBlockLocation();

            if (args.Length == 0) {
                client.CS.CurrentMap.ClientChangeBlock(client, myLoc.X, myLoc.Y, (short)(myLoc.Z - 2), 1, client.CS.MyEntity.Lastmaterial);
                Chat.SendClientChat(client, "§SBlock placed.");
            } else if (args.Length == 1) {
                var newBlock = ServerCore.Blockholder.GetBlock(text1);

                if (newBlock == null) {
                    Chat.SendClientChat(client, "§ECouldn't find a block called '" + text1 + "'.");
                    return;
                }

                client.CS.MyEntity.Lastmaterial = newBlock;
                client.CS.CurrentMap.ClientChangeBlock(client, myLoc.X, myLoc.Y, (short)(myLoc.Z - 2), 1, client.CS.MyEntity.Lastmaterial);
                Chat.SendClientChat(client, "§SBlock placed.");
            }
        }
Example #29
0
        private static void TPHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            if (args.Length == 0 || args.Length > 1) {
                Chat.SendClientChat(client, "§EIncorrect number of arguments. See /cmdhelp tp");
                return;
            }

            NetworkClient tpClient;
            if (!ServerCore.Nh.LoggedClients.TryGetValue(args[0], out tpClient)) {
                Chat.SendClientChat(client, "§ECould not find a player called '" + args[0] + "'.");
                return;
            }

            if (tpClient.CS.CurrentMap != client.CS.CurrentMap)
                client.ChangeMap(tpClient.CS.CurrentMap);

            if (client.CS.CurrentMap != tpClient.CS.CurrentMap)
                return;

            client.CS.MyEntity.Location = tpClient.CS.MyEntity.Location;
            client.CS.MyEntity.Rot = tpClient.CS.MyEntity.Rot;
            client.CS.MyEntity.Look = tpClient.CS.MyEntity.Look;
            client.CS.MyEntity.SendOwn = true;
            Chat.SendClientChat(client, "§STeleported.");
        }
Example #30
0
        static void UndoHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            if (args.Length == 0) {
                client.Undo(30000);
                Chat.SendClientChat(client, "§SDone.");
                return;
            }

            int myInt;
            int.TryParse(args[0], out myInt);

            client.Undo(myInt);
            Chat.SendClientChat(client, "§SDone.");
        }