Ejemplo n.º 1
0
        public override void Use(Player p, string message)
        {
            try
            {
                if (message == "")
                {
                    Help(p); return;
                }

                bool stealth = false; bool totalBan = false;
                if (message[0] == '#')
                {
                    message = message.Remove(0, 1).Trim();
                    stealth = true;
                    Server.s.Log("Stealth Ban Attempted");
                }
                else if (message[0] == '@')
                {
                    totalBan = true;
                    message  = message.Remove(0, 1).Trim();
                }

                Player who = Player.Find(message);

                if (who == null)
                {
                    if (!Player.ValidName(message))
                    {
                        Player.SendMessage(p, "Invalid name \"" + message + "\".");
                        return;
                    }

                    Group foundGroup = Group.findPlayerGroup(message);

                    if (foundGroup.Permission >= LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "You can't ban a " + foundGroup.name + "!");
                        return;
                    }
                    if (foundGroup.Permission == LevelPermission.Banned)
                    {
                        Player.SendMessage(p, message + " is already banned.");
                        return;
                    }

                    foundGroup.playerList.Remove(message);
                    foundGroup.playerList.Save();

                    Player.GlobalMessage(message + " &f(offline)" + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + "!");
                    Group.findPerm(LevelPermission.Banned).playerList.Add(message);
                }
                else
                {
                    if (!Player.ValidName(who.name))
                    {
                        Player.SendMessage(p, "Invalid name \"" + who.name + "\".");
                        return;
                    }

                    if (who.group.Permission >= LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "You can't ban a " + who.group.name + "!");
                        return;
                    }
                    if (who.group.Permission == LevelPermission.Banned)
                    {
                        Player.SendMessage(p, message + " is already banned.");
                        return;
                    }

                    who.group.playerList.Remove(message);
                    who.group.playerList.Save();

                    if (stealth)
                    {
                        Player.GlobalMessageOps(who.color + who.name + Server.DefaultColor + " is now STEALTH &8banned" + Server.DefaultColor + "!");
                    }
                    else
                    {
                        Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + "!", false);
                    }

                    who.group = Group.findPerm(LevelPermission.Banned);
                    who.color = who.group.color;
                    Player.GlobalDie(who, false);
                    Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
                    Group.findPerm(LevelPermission.Banned).playerList.Add(who.name);
                }
                Group.findPerm(LevelPermission.Banned).playerList.Save();

                IRCBot.Say(message + " was banned.");
                Server.s.Log("BANNED: " + message.ToLower());

                if (totalBan == true)
                {
                    Command.all.Find("undo").Use(p, message + " 0");
                    Command.all.Find("banip").Use(p, "@ " + message);
                }
            }
            catch (Exception e) { Server.ErrorLog(e); }
        }
Ejemplo n.º 2
0
        public override void Use(Player p, string message)
        {
            switch (message)
            {
            case "":
            case "p":
            case "player":
                if (p == null)
                {
                    if (!Server.console)
                    {
                        MCSong.Gui.Window.thisWindow.txtLog.Clear();
                        MCSong.Gui.Window.clearChatBuffer();
                    }
                    else
                    {
                        Console.Clear();
                    }
                }
                else
                {
                    for (int i = 0; i < 100; i++)
                    {
                        Clear(p);
                    }
                }
                Player.SendMessage(p, "Your chat has been cleared.");
                break;

            case "s":
            case "server":
                if (p != null && p.group.Permission < Server.opchatperm)
                {
                    Help(p); return;
                }
                foreach (Player pl in Player.players)
                {
                    for (int i = 0; i < 100; i++)
                    {
                        Clear(pl);
                    }
                }
                if (p == null)
                {
                    if (!Server.console)
                    {
                        MCSong.Gui.Window.thisWindow.txtLog.Clear();
                        MCSong.Gui.Window.clearChatBuffer();
                    }
                    else
                    {
                        Console.Clear();
                    }
                }
                Server.s.Log("Server chat has been cleared by " + ((p == null) ? "Console" : p.color + p.name));
                Player.GlobalMessage("Server chat has been cleared by " + ((p == null) ? "Console" : p.color + p.name));
                break;

            default:
                Help(p);
                return;
            }
        }
Ejemplo n.º 3
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }
            if (message[0] == '@')
            {
                message = message.Remove(0, 1).Trim();
                Player who = Player.Find(message);
                if (who == null)
                {
                    /*DataTable ip;
                     * int tryCounter = 0;
                     * rerun:  try
                     * {
                     *  ip = MySQL.fillData("SELECT IP FROM Players WHERE Name = '" + message + "'");
                     * }
                     * catch (Exception e)
                     * {
                     *  tryCounter++;
                     *  if (tryCounter < 10)
                     *      goto rerun;
                     *  else
                     *  {
                     *      Server.ErrorLog(e);
                     *      return;
                     *  }
                     * }
                     * if (ip.Rows.Count > 0)
                     *  message = ip.Rows[0]["IP"].ToString();
                     * else
                     * {
                     *  Player.SendMessage(p, "Unable to find an IP address for that user.");
                     *  return;
                     * }
                     * ip.Dispose();
                     * if (OfflinePlayer.Find(message) != null)
                     *  message = OfflinePlayer.Find(message).ip;
                     * else
                     * {
                     *  Player.SendMessage(p, "Unable to find an IP address for that user.");
                     *  return;
                     * }*/
                    try
                    {
                        message = Server.s.database.GetTable("Players").GetValue(Server.s.database.GetTable("Players").Rows.IndexOf(Server.s.database.GetTable("Players").GetRow(new string[] { "Name" }, new string[] { message })), "IP");
                    }
                    catch
                    {
                        Player.SendMessage(p, "Unable to find an IP address for that user.");
                        return;
                    }
                }
                else
                {
                    message = who.ip;
                }
            }
            else
            {
                Player who = Player.Find(message);
                if (who != null)
                {
                    message = who.ip;
                }
            }

            if (message.Equals("127.0.0.1"))
            {
                Player.SendMessage(p, "You can't ip-ban the server!"); return;
            }
            if (message.IndexOf('.') == -1)
            {
                Player.SendMessage(p, "Invalid IP!"); return;
            }
            if (message.Split('.').Length != 4)
            {
                Player.SendMessage(p, "Invalid IP!"); return;
            }
            if (p != null)
            {
                if (p.ip == message)
                {
                    Player.SendMessage(p, "You can't ip-ban yourself!"); return;
                }
            }
            if (Server.bannedIP.Contains(message))
            {
                Player.SendMessage(p, message + " is already ip-banned."); return;
            }
            Player.GlobalMessage(message + " got &8ip-banned!");
            if (p != null)
            {
                IRCBot.Say("IP-BANNED: " + message.ToLower() + " by " + p.name);
            }
            else
            {
                IRCBot.Say("IP-BANNED: " + message.ToLower() + " by console");
            }
            Server.bannedIP.Add(message);
            Server.bannedIP.Save("banned-ip.txt", false);
            Server.s.Log("IP-BANNED: " + message.ToLower());

            /*
             * foreach (Player pl in Player.players) {
             *  if (message == pl.ip) { pl.Kick("Kicked by ipban"); }
             * }*/
        }
Ejemplo n.º 4
0
        public override void Use(Player p, string message)
        {
            byte b; Int64 seconds; Player who; Player.UndoPos Pos; int CurrentPos = 0;

            if (p != null)
            {
                p.RedoBuffer.Clear();
            }

            if (message == "")
            {
                message = p.name + " 30";
            }

            if (message.Split(' ').Length == 2)
            {
                if (message.Split(' ')[1].ToLower() == "all" && p.group.Permission > LevelPermission.Operator)
                {
                    seconds = 500000;
                }
                else
                {
                    try
                    {
                        seconds = Int64.Parse(message.Split(' ')[1]);
                    }
                    catch
                    {
                        Player.SendMessage(p, "Invalid seconds.");
                        return;
                    }
                }
            }
            else
            {
                try
                {
                    seconds = int.Parse(message);
                    if (p != null)
                    {
                        message = p.name + " " + message;
                    }
                }
                catch
                {
                    seconds = 30;
                    message = message + " 30";
                }
            }

            //if (message.Split(' ').Length == 1) if (char.IsDigit(message, 0)) { message = p.name + " " + message; } else { message = message + " 30"; }

            //try { seconds = Convert.ToInt16(message.Split(' ')[1]); } catch { seconds = 2; }
            if (seconds == 0)
            {
                seconds = 5400;
            }

            who = Player.Find(message.Split(' ')[0]);
            if (who != null)
            {
                if (p != null)
                {
                    if (who.group.Permission > p.group.Permission && who != p)
                    {
                        Player.SendMessage(p, "Cannot undo a user of higher or equal rank"); return;
                    }
                    if (who != p && p.group.Permission < LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "Only an OP+ may undo other people's actions"); return;
                    }

                    if (p.group.Permission < LevelPermission.Builder && seconds > 120)
                    {
                        Player.SendMessage(p, "Guests may only undo 2 minutes."); return;
                    }
                    else if (p.group.Permission < LevelPermission.AdvBuilder && seconds > 300)
                    {
                        Player.SendMessage(p, "Builders may only undo 300 seconds."); return;
                    }
                    else if (p.group.Permission < LevelPermission.Operator && seconds > 1200)
                    {
                        Player.SendMessage(p, "AdvBuilders may only undo 600 seconds."); return;
                    }
                    else if (p.group.Permission == LevelPermission.Operator && seconds > 5400)
                    {
                        Player.SendMessage(p, "Operators may only undo 5400 seconds."); return;
                    }
                }

                for (CurrentPos = who.UndoBuffer.Count - 1; CurrentPos >= 0; --CurrentPos)
                {
                    try
                    {
                        Pos = who.UndoBuffer[CurrentPos];
                        Level foundLevel = Level.FindExact(Pos.mapName);
                        b = foundLevel.GetTile(Pos.x, Pos.y, Pos.z);
                        if (Pos.timePlaced.AddSeconds(seconds) >= DateTime.Now)
                        {
                            if (b == Pos.newtype || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava)
                            {
                                foundLevel.Blockchange(Pos.x, Pos.y, Pos.z, Pos.type, true);

                                Pos.newtype = Pos.type; Pos.type = b;
                                if (p != null)
                                {
                                    p.RedoBuffer.Add(Pos);
                                }
                                who.UndoBuffer.RemoveAt(CurrentPos);
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    catch { }
                }

                if (p != who)
                {
                    Player.GlobalChat(p, who.color + who.name + Server.DefaultColor + "'s actions for the past &b" + seconds + " seconds were undone.", false);
                }
                else
                {
                    Player.SendMessage(p, "Undid your actions for the past &b" + seconds + Server.DefaultColor + " seconds.");
                }
                return;
            }
            else if (message.Split(' ')[0].ToLower() == "physics")
            {
                if (p.group.Permission < LevelPermission.AdvBuilder)
                {
                    Player.SendMessage(p, "Reserved for Adv+"); return;
                }
                else if (p.group.Permission < LevelPermission.Operator && seconds > 1200)
                {
                    Player.SendMessage(p, "AdvBuilders may only undo 1200 seconds."); return;
                }
                else if (p.group.Permission == LevelPermission.Operator && seconds > 5400)
                {
                    Player.SendMessage(p, "Operators may only undo 5400 seconds."); return;
                }

                Command.all.Find("pause").Use(p, "120");
                Level.UndoPos uP;
                ushort        x, y, z;

                if (p.level.UndoBuffer.Count != Server.physUndo)
                {
                    for (CurrentPos = p.level.currentUndo; CurrentPos >= 0; CurrentPos--)
                    {
                        try
                        {
                            uP = p.level.UndoBuffer[CurrentPos];
                            b  = p.level.GetTile(uP.location);
                            if (uP.timePerformed.AddSeconds(seconds) >= DateTime.Now)
                            {
                                if (b == uP.newType || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava)
                                {
                                    p.level.IntToPos(uP.location, out x, out y, out z);
                                    p.level.Blockchange(p, x, y, z, uP.oldType, true);
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        catch { }
                    }
                }
                else
                {
                    for (CurrentPos = p.level.currentUndo; CurrentPos != p.level.currentUndo + 1; CurrentPos--)
                    {
                        try
                        {
                            if (CurrentPos < 0)
                            {
                                CurrentPos = p.level.UndoBuffer.Count - 1;
                            }
                            uP = p.level.UndoBuffer[CurrentPos];
                            b  = p.level.GetTile(uP.location);
                            if (uP.timePerformed.AddSeconds(seconds) >= DateTime.Now)
                            {
                                if (b == uP.newType || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava)
                                {
                                    p.level.IntToPos(uP.location, out x, out y, out z);
                                    p.level.Blockchange(p, x, y, z, uP.oldType, true);
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        catch { }
                    }
                }

                Command.all.Find("pause").Use(p, "");
                Player.GlobalMessage("Physics were undone &b" + seconds + Server.DefaultColor + " seconds");
            }
            else
            {
                if (p != null)
                {
                    if (p.group.Permission < LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "Reserved for OP+"); return;
                    }
                    if (seconds > 5400 && p.group.Permission == LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "Only SuperOPs may undo more than 90 minutes."); return;
                    }
                }

                bool FoundUser = false;

                try
                {
                    DirectoryInfo di;
                    string[]      fileContent;

                    p.RedoBuffer.Clear();

                    if (Directory.Exists("extra/undo/" + message.Split(' ')[0]))
                    {
                        di = new DirectoryInfo("extra/undo/" + message.Split(' ')[0]);

                        for (int i = di.GetFiles("*.undo").Length - 1; i >= 0; i--)
                        {
                            fileContent = File.ReadAllText("extra/undo/" + message.Split(' ')[0] + "/" + i + ".undo").Split(' ');
                            if (!undoBlah(fileContent, seconds, p))
                            {
                                break;
                            }
                        }
                        FoundUser = true;
                    }

                    if (Directory.Exists("extra/undoPrevious/" + message.Split(' ')[0]))
                    {
                        di = new DirectoryInfo("extra/undoPrevious/" + message.Split(' ')[0]);

                        for (int i = di.GetFiles("*.undo").Length - 1; i >= 0; i--)
                        {
                            fileContent = File.ReadAllText("extra/undoPrevious/" + message.Split(' ')[0] + "/" + i + ".undo").Split(' ');
                            if (!undoBlah(fileContent, seconds, p))
                            {
                                break;
                            }
                        }
                        FoundUser = true;
                    }

                    if (FoundUser)
                    {
                        Player.GlobalChat(p, Server.FindColor(message.Split(' ')[0]) + message.Split(' ')[0] + Server.DefaultColor + "'s actions for the past &b" + seconds + Server.DefaultColor + " seconds were undone.", false);
                    }
                    else
                    {
                        Player.SendMessage(p, "Could not find player specified.");
                    }
                }
                catch (Exception e)
                {
                    Server.ErrorLog(e);
                }
            }
        }
Ejemplo n.º 5
0
        public override void Use(Player p, string message)
        {
            try
            {
                if (message == "")
                {
                    Help(p); return;
                }
                if (message.Split(' ').Length > 2)
                {
                    Help(p); return;
                }
                int    pos  = message.IndexOf(' ');
                string phys = "0";
                if (pos != -1)
                {
                    phys    = message.Substring(pos + 1);
                    message = message.Substring(0, pos).ToLower();
                }
                else
                {
                    message = message.ToLower();
                }

                foreach (Level l in Server.levels)
                {
                    if (l.name == message)
                    {
                        Player.SendMessage(p, message + " is already loaded!"); return;
                    }
                }

                if (Server.levels.Count == Server.levels.Capacity)
                {
                    if (Server.levels.Capacity == 1)
                    {
                        Player.SendMessage(p, "You can't load any levels!");
                    }
                    else
                    {
                        Command.all.Find("unload").Use(p, "empty");
                        if (Server.levels.Capacity == 1)
                        {
                            Player.SendMessage(p, "No maps are empty to unload. Cannot load map.");
                            return;
                        }
                    }
                }

                if (!File.Exists("levels/" + message + ".lvl"))
                {
                    Player.SendMessage(p, "Level \"" + message + "\" doesn't exist!"); return;
                }

                Level level = Level.Load(message);

                if (level == null)
                {
                    if (File.Exists("levels/" + message + ".lvl.backup"))
                    {
                        Server.s.Log("Attempting to load backup.");
                        File.Copy("levels/" + message + ".lvl.backup", "levels/" + message + ".lvl", true);
                        level = Level.Load(message);
                        if (level == null)
                        {
                            Player.SendMessage(p, "Backup of " + message + " failed.");
                            return;
                        }
                    }
                    else
                    {
                        Player.SendMessage(p, "Backup of " + message + " does not exist.");
                        return;
                    }
                }

                if (p != null)
                {
                    if (level.permissionvisit > p.group.Permission)
                    {
                        Player.SendMessage(p, "This map is for " + Level.PermissionToName(level.permissionvisit) + " only!");
                        GC.Collect();
                        GC.WaitForPendingFinalizers();
                        return;
                    }
                }

                foreach (Level l in Server.levels)
                {
                    if (l.name == message)
                    {
                        Player.SendMessage(p, message + " is already loaded!");
                        GC.Collect();
                        GC.WaitForPendingFinalizers();
                        return;
                    }
                }

                lock (Server.levels) {
                    Server.addLevel(level);
                }

                level.physThread.Start();
                Player.GlobalMessage("Level \"" + level.name + "\" loaded.");
                try
                {
                    int temp = int.Parse(phys);
                    if (temp >= 1 && temp <= 4)
                    {
                        level.setPhysics(temp);
                    }
                }
                catch
                {
                    Player.SendMessage(p, "Physics variable invalid");
                }
            }
            catch (Exception e)
            {
                Player.GlobalMessage("An error occured with /load");
                Server.ErrorLog(e);
            }
            finally
            {
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
Ejemplo n.º 6
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }

            string[] parameters = message.Split(' '); // Grab the parameters from the player's message
            if (parameters.Length == 5)               // make sure there are 5 params
            {
                switch (parameters[4])
                {
                case "flat":
                case "pixel":
                case "island":
                case "mountains":
                case "ocean":
                case "forest":
                case "desert":
                    break;

                default:
                    Player.SendMessage(p, "Valid types: island, mountains, forest, ocean, flat, pixel, desert"); return;
                }

                string name = parameters[0].ToLower();
                ushort x = 1, y = 1, z = 1;
                try
                {
                    x = Convert.ToUInt16(parameters[1]);
                    y = Convert.ToUInt16(parameters[2]);
                    z = Convert.ToUInt16(parameters[3]);
                }
                catch { Player.SendMessage(p, "Invalid dimensions."); return; }
                if (!isGood(x))
                {
                    Player.SendMessage(p, x + " is not a good dimension! Use a power of 2 next time.");
                }
                if (!isGood(y))
                {
                    Player.SendMessage(p, y + " is not a good dimension! Use a power of 2 next time.");
                }
                if (!isGood(z))
                {
                    Player.SendMessage(p, z + " is not a good dimension! Use a power of 2 next time.");
                }

                if (!Player.ValidName(name))
                {
                    Player.SendMessage(p, "Invalid name!"); return;
                }

                try
                {
                    if (p != null)
                    {
                        if (p.group.Permission < LevelPermission.Admin)
                        {
                            if (x * y * z > 30000000)
                            {
                                Player.SendMessage(p, "Cannot create a map with over 30million blocks"); return;
                            }
                        }
                        else
                        {
                            if (x * y * z > 225000000)
                            {
                                Player.SendMessage(p, "You cannot make a map with over 225million blocks"); return;
                            }
                        }
                    }
                }
                catch
                {
                    Player.SendMessage(p, "An error occured");
                }

                // create a new level...
                try
                {
                    Level lvl = new Level(name, x, y, z, parameters[4]);
                    lvl.Save(true); //... and save it.
                }
                finally
                {
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                Player.GlobalMessage("Level " + name + " created"); // The player needs some form of confirmation.
            }
            else
            {
                Help(p);
            }
        }
Ejemplo n.º 7
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }
            Level foundLevel = Level.Find(message);

            if (foundLevel != null)
            {
                foundLevel.Unload();
            }

            if (foundLevel == Server.mainLevel)
            {
                Player.SendMessage(p, "Cannot delete the main level."); return;
            }

            try
            {
                if (!Directory.Exists("levels/deleted"))
                {
                    Directory.CreateDirectory("levels/deleted");
                }

                if (File.Exists("levels/" + message + ".lvl"))
                {
                    if (File.Exists("levels/deleted/" + message + ".lvl"))
                    {
                        int currentNum = 0;
                        while (File.Exists("levels/deleted/" + message + currentNum + ".lvl"))
                        {
                            currentNum++;
                        }

                        File.Move("levels/" + message + ".lvl", "levels/deleted/" + message + currentNum + ".lvl");
                    }
                    else
                    {
                        File.Move("levels/" + message + ".lvl", "levels/deleted/" + message + ".lvl");
                    }
                    Player.SendMessage(p, "Created backup.");

                    try { File.Delete("levels/level properties/" + message + ".properties"); }
                    catch { }
                    try { File.Delete("levels/level properties/" + message); }
                    catch { }

                    //MySQL.executeQuery("DROP TABLE `Block" + message + "`, `Portals" + message + "`, `Messages" + message + "`, `Zone" + message + "`");

                    Server.s.database.GetTable("Blocks" + message).Delete();
                    Server.s.database.GetTable("Portals" + message).Delete();
                    Server.s.database.GetTable("Messages" + message).Delete();
                    Server.s.database.GetTable("Zones" + message).Delete();

                    Player.GlobalMessage("Level " + message + " was deleted.");
                }
                else
                {
                    Player.SendMessage(p, "Could not find specified level.");
                }
            }
            catch (Exception e) { Player.SendMessage(p, "Error when deleting."); Server.ErrorLog(e); }
        }
Ejemplo n.º 8
0
        public override void Use(Player p, string message)
        {
            if (message.Split(' ').Length < 2)
            {
                Help(p); return;
            }
            Player who     = Player.Find(message.Split(' ')[0]);
            Group  newRank = Group.Find(message.Split(' ')[1]);
            string msgGave;

            if (message.Split(' ').Length > 2)
            {
                msgGave = message.Substring(message.IndexOf(' ', message.IndexOf(' ') + 1));
            }
            else
            {
                msgGave = "Congratulations!";
            }
            if (newRank == null)
            {
                Player.SendMessage(p, "Could not find specified rank."); return;
            }

            Group bannedGroup = Group.findPerm(LevelPermission.Banned);

            if (who == null)
            {
                string foundName = message.Split(' ')[0];
                if (Group.findPlayerGroup(foundName) == bannedGroup || newRank == bannedGroup)
                {
                    Player.SendMessage(p, "Cannot change the rank to or from \"" + bannedGroup.name + "\".");
                    return;
                }

                if (p != null)
                {
                    if (Group.findPlayerGroup(foundName).Permission >= p.group.Permission || newRank.Permission >= p.group.Permission)
                    {
                        Player.SendMessage(p, "Cannot change the rank of someone equal or higher than you"); return;
                    }
                }

                Group oldGroup = Group.findPlayerGroup(foundName);
                oldGroup.playerList.Remove(foundName);
                oldGroup.playerList.Save();

                newRank.playerList.Add(foundName);
                newRank.playerList.Save();

                Player.GlobalMessage(foundName + " &f(offline)" + Server.DefaultColor + "'s rank was set to " + newRank.color + newRank.name);
            }
            else if (who == p)
            {
                Player.SendMessage(p, "Cannot change your own rank."); return;
            }
            else
            {
                if (p != null)
                {
                    if (who.group == bannedGroup || newRank == bannedGroup)
                    {
                        Player.SendMessage(p, "Cannot change the rank to or from \"" + bannedGroup.name + "\".");
                        return;
                    }

                    if (who.group.Permission >= p.group.Permission || newRank.Permission >= p.group.Permission)
                    {
                        Player.SendMessage(p, "Cannot change the rank of someone equal or higher to yourself."); return;
                    }
                }

                who.group.playerList.Remove(who.name);
                who.group.playerList.Save();

                newRank.playerList.Add(who.name);
                newRank.playerList.Save();

                Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + "'s rank was set to " + newRank.color + newRank.name, false);
                Player.GlobalChat(null, "&6" + msgGave, false);
                who.group = newRank;
                who.color = who.group.color;
                Player.GlobalDie(who, false);
                who.SendMessage("You are now ranked " + newRank.color + newRank.name + Server.DefaultColor + ", type /help for your new set of commands.");
                Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
            }
        }
Ejemplo n.º 9
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                foreach (Level l in Server.levels)
                {
                    if (l.physics > 0)
                    {
                        Player.SendMessage(p, "&5" + l.name + Server.DefaultColor + " has physics at &b" + l.physics + Server.DefaultColor + ". &cChecks: " + l.lastCheck + "; Updates: " + l.lastUpdate);
                    }
                }
                return;
            }
            try
            {
                int temp = 0; Level level = null;
                if (message.Split(' ').Length == 1)
                {
                    temp = int.Parse(message);
                    if (p != null)
                    {
                        level = p.level;
                    }
                    else
                    {
                        level = Server.mainLevel;
                    }
                }
                else
                {
                    temp = System.Convert.ToInt16(message.Split(' ')[1]);
                    string nameStore = message.Split(' ')[0];
                    level = Level.Find(nameStore);
                }
                if (temp >= 0 && temp <= 5)
                {
                    level.setPhysics(temp);
                    switch (temp)
                    {
                    case 0:
                        level.ClearPhysics();
                        Player.GlobalMessage("Physics are now &cOFF" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now OFF on " + level.name + ".");
                        IRCBot.Say("Physics are now OFF on " + level.name + ".");
                        break;

                    case 1:
                        Player.GlobalMessage("Physics are now &aNormal" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now ON on " + level.name + ".");
                        IRCBot.Say("Physics are now ON on " + level.name + ".");
                        break;

                    case 2:
                        Player.GlobalMessage("Physics are now &aAdvanced" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now ADVANCED on " + level.name + ".");
                        IRCBot.Say("Physics are now ADVANCED on " + level.name + ".");
                        break;

                    case 3:
                        Player.GlobalMessage("Physics are now &aHardcore" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now HARDCORE on " + level.name + ".");
                        IRCBot.Say("Physics are now HARDCORE on " + level.name + ".");
                        break;

                    case 4:
                        Player.GlobalMessage("Physics are now &aInstant" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now INSTANT on " + level.name + ".");
                        IRCBot.Say("Physics are now INSTANT on " + level.name + ".");
                        break;

                    case 5:
                        Player.GlobalMessage("Physics are now &aDoors-Only" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now DOORS-ONLY on " + level.name + ".");
                        IRCBot.Say("Physics are now DOORS-ONLY on " + level.name + ".");
                        break;
                    }

                    level.changed = true;
                }
                else
                {
                    Player.SendMessage(p, "Not a valid setting");
                }
            }
            catch
            {
                Player.SendMessage(p, "INVALID INPUT");
            }
        }
Ejemplo n.º 10
0
 void OnAction(object sender, ActionEventArgs e)
 {
     Player.GlobalMessage("* " + e.Data.Nick + " " + e.ActionMessage);
 }
Ejemplo n.º 11
0
        void OnPrivMsg(object sender, IrcEventArgs e)
        {
            Server.s.Log("IRC RECEIVING MESSAGE");
            if (Server.ircControllers.Contains(e.Data.Nick))
            {
                string cmd;
                string msg;
                int    len = e.Data.Message.Split(' ').Length;
                cmd = e.Data.Message.Split(' ')[0];
                if (len > 1)
                {
                    msg = e.Data.Message.Substring(e.Data.Message.IndexOf(' ')).Trim();
                }
                else
                {
                    msg = "";
                }

                if (msg != "" || cmd == "restart" || cmd == "update")
                {
                    Server.s.Log(cmd + " : " + msg);
                    switch (cmd)
                    {
                    case "kick":
                        if (Player.Find(msg.Split()[0]) != null)
                        {
                            Command.all.Find("kick").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Player not found.");
                        }
                        break;

                    case "ban":
                        if (Player.Find(msg) != null)
                        {
                            Command.all.Find("ban").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Player not found.");
                        }
                        break;

                    case "banip":
                        if (Player.Find(msg) != null)
                        {
                            Command.all.Find("banip").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Player not found.");
                        }
                        break;

                    case "say":
                        irc.SendMessage(SendType.Message, channel, msg); break;

                    case "setrank":
                        if (Player.Find(msg.Split(' ')[0]) != null)
                        {
                            Command.all.Find("setrank").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Player not found.");
                        }
                        break;

                    case "mute":
                        if (Player.Find(msg) != null)
                        {
                            Command.all.Find("mute").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Player not found.");
                        }
                        break;

                    case "joker":
                        if (Player.Find(msg) != null)
                        {
                            Command.all.Find("joker").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Player not found.");
                        }
                        break;

                    case "physics":
                        if (Level.Find(msg.Split(' ')[0]) != null)
                        {
                            Command.all.Find("physics").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Map not found.");
                        }
                        break;

                    case "load":
                        if (Level.Find(msg.Split(' ')[0]) != null)
                        {
                            Command.all.Find("load").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Map not found.");
                        }
                        break;

                    case "unload":
                        if (Level.Find(msg) != null || msg == "empty")
                        {
                            Command.all.Find("unload").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Map not found.");
                        }
                        break;

                    case "save":
                        if (Level.Find(msg) != null)
                        {
                            Command.all.Find("save").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Map not found.");
                        }
                        break;

                    case "map":
                        if (Level.Find(msg.Split(' ')[0]) != null)
                        {
                            Command.all.Find("map").Use(null, msg);
                        }
                        else
                        {
                            irc.SendMessage(SendType.Message, e.Data.Nick, "Map not found.");
                        }
                        break;

                    case "restart":
                        Player.GlobalMessage("Restart initiated by " + e.Data.Nick);
                        IRCBot.Say("Restart initiated by " + e.Data.Nick);
                        Command.all.Find("restart").Use(null, "");
                        break;

                    case "update":
                        Player.GlobalMessage("Update check initiated by " + e.Data.Nick);
                        IRCBot.Say("Update check initiated by " + e.Data.Nick);
                        Command.all.Find("update").Use(null, "");
                        break;

                    default:
                        irc.SendMessage(SendType.Message, e.Data.Nick, "Invalid command."); break;
                    }
                }
                else
                {
                    irc.SendMessage(SendType.Message, e.Data.Nick, "Invalid command format.");
                }
            }
        }
Ejemplo n.º 12
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                if (p != null)
                {
                    message = p.level.name + " 30";
                }
                else
                {
                    message = Server.mainLevel + " 30";
                }
            }
            int foundNum = 0; Level foundLevel;

            if (message.IndexOf(' ') == -1)
            {
                try
                {
                    foundNum = int.Parse(message);
                    if (p != null)
                    {
                        foundLevel = p.level;
                    }
                    else
                    {
                        foundLevel = Server.mainLevel;
                    }
                }
                catch
                {
                    foundNum   = 30;
                    foundLevel = Level.Find(message);
                }
            }
            else
            {
                try
                {
                    foundNum   = int.Parse(message.Split(' ')[1]);
                    foundLevel = Level.Find(message.Split(' ')[0]);
                }
                catch
                {
                    Player.SendMessage(p, "Invalid input");
                    return;
                }
            }

            if (foundLevel == null)
            {
                Player.SendMessage(p, "Could not find entered level.");
                return;
            }

            try
            {
                if (foundLevel.physPause)
                {
                    foundLevel.physThread.Resume();
                    foundLevel.physResume = DateTime.Now;
                    foundLevel.physPause  = false;
                    Player.GlobalMessage("Physics on " + foundLevel.name + " were re-enabled.");
                }
                else
                {
                    foundLevel.physThread.Suspend();
                    foundLevel.physResume = DateTime.Now.AddSeconds(foundNum);
                    foundLevel.physPause  = true;
                    Player.GlobalMessage("Physics on " + foundLevel.name + " were temporarily disabled.");

                    foundLevel.physTimer.Elapsed += delegate
                    {
                        if (DateTime.Now > foundLevel.physResume)
                        {
                            foundLevel.physPause = false;
                            try
                            {
                                foundLevel.physThread.Resume();
                            }
                            catch (Exception e) { Server.ErrorLog(e); }
                            Player.GlobalMessage("Physics on " + foundLevel.name + " were re-enabled.");
                            foundLevel.physTimer.Stop();
                            foundLevel.physTimer.Dispose();
                        }
                    };
                    foundLevel.physTimer.Start();
                }
            }
            catch (Exception e)
            {
                Server.ErrorLog(e);
            }
        }
Ejemplo n.º 13
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }
            bool totalUnban = false;

            if (message[0] == '@')
            {
                totalUnban = true;
                message    = message.Remove(0, 1).Trim();
            }

            Player who = Player.Find(message);

            if (who == null)
            {
                if (Group.findPlayerGroup(message) != Group.findPerm(LevelPermission.Banned))
                {
                    foreach (Server.TempBan tban in Server.tempBans)
                    {
                        if (tban.name.ToLower() == message.ToLower())
                        {
                            Server.tempBans.Remove(tban);
                            Player.GlobalMessage(message + " has had their temporary ban lifted.");
                            return;
                        }
                    }
                    Player.SendMessage(p, "Player is not banned.");
                    return;
                }
                Player.GlobalMessage(message + " &8(banned)" + Server.DefaultColor + " is now " + Group.standard.color + Group.standard.name + Server.DefaultColor + "!");
                Group.findPerm(LevelPermission.Banned).playerList.Remove(message);
            }
            else
            {
                if (Group.findPlayerGroup(message) != Group.findPerm(LevelPermission.Banned))
                {
                    foreach (Server.TempBan tban in Server.tempBans)
                    {
                        if (tban.name == who.name)
                        {
                            Server.tempBans.Remove(tban);
                            Player.GlobalMessage(who.color + who.prefix + who.name + Server.DefaultColor + "has had their temporary ban lifted.");
                            return;
                        }
                    }
                    Player.SendMessage(p, "Player is not banned.");
                    return;
                }
                Player.GlobalChat(who, who.color + who.prefix + who.name + Server.DefaultColor + " is now " + Group.standard.color + Group.standard.name + Server.DefaultColor + "!", false);
                who.group = Group.standard; who.color = who.group.color; Player.GlobalDie(who, false);
                Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
                Group.findPerm(LevelPermission.Banned).playerList.Remove(message);
            }

            Group.findPerm(LevelPermission.Banned).playerList.Save();
            if (totalUnban)
            {
                Command.all.Find("unbanip").Use(p, "@" + message);
            }
        }