コード例 #1
0
ファイル: CmdUnlock.cs プロジェクト: OMARATION/mcforge
 // This is where the magic happens, naturally.
 // p is the player object for the player executing the command.  message is everything after the command invocation itself.
 public override void Use(Player p, string message)
 {
     if (!Directory.Exists("text/lockdown"))
     {
         p.SendMessage("Could not locate the folder creating one now.");
         Directory.CreateDirectory("text/lockdown");
         Directory.CreateDirectory("text/lockdown/map");
         p.SendMessage("Added the settings for the command");
     }
     string[] param = message.Split(' ');
     {
         if (param.Length == 2)
         {
             if (param[0] == "map")
             {
                 if (File.Exists("text/lockdown/map/" + param[1] + ""))
                 {
                     File.Delete("text/lockdown/map/" + param[1] + "");
                     Player.SendMessage(p, "the map " + param[1] + " have been unlocked");
                 }
                 else
                 {
                     Player.SendMessage(p, "the map " + param[1] + " is not locked or does not exist");
                 }
             }
         }
         if (param.Length == 2) // shift number to the next lockdown command
         {
             if (param[0] == "player")
             {
                 Player who = Player.Find(param[1]);
                 {
                     if (who != null)
                     {
                         if (who.jailed)
                         {
                             if (p != null)
                             {
                                 if (who.group.Permission >= p.group.Permission)
                                 {
                                     Player.SendMessage(p, "Cannot lock down someone of equal or greater rank."); return;
                                 }
                             }
                             if (who.level != p.level)
                             {
                                 Command.all.Find("goto").Use(who, p.level.name);
                             }
                             Player.GlobalDie(who, false);
                             who.jailed = false;
                             Player.GlobalChat(p, who.color + who.name + Server.DefaultColor + " have been unlocked!", true);
                             return;
                         }
                         else
                         {
                             Player.SendMessage(p, "the player " + param[1] + " is not locked down");
                         } return;
                     }
                     else
                     {
                         Player.SendMessage(p, "there is no such player online!");
                     } return;
                 }
             }
         }
     }
 }
コード例 #2
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }

            int    pos = message.IndexOf(' ');
            Player who = Player.Find(message.Split(' ')[0]);

            if (who == null)
            {
                Player.SendMessage(p, "Could not find player."); return;
            }
            if (p != null && who.group.Permission > p.group.Permission)
            {
                Player.SendMessage(p, "Cannot change the title of someone of greater rank");
                return;
            }
            string query;
            string newTitle = "";

            if (message.Split(' ').Length > 1)
            {
                newTitle = message.Substring(pos + 1);
            }
            else
            {
                who.title = "";
                who.SetPrefix();
                Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " had their title removed.", false);
                query = "UPDATE Players SET Title = '' WHERE Name = '" + who.name + "'";
                Database.executeQuery(query);
                return;
            }

            if (newTitle != "")
            {
                newTitle = newTitle.ToString().Trim().Replace("[", "");
                newTitle = newTitle.Replace("]", "");

                /* if (newTitle[0].ToString() != "[") newTitle = "[" + newTitle;
                 * if (newTitle.Trim()[newTitle.Trim().Length - 1].ToString() != "]") newTitle = newTitle.Trim() + "]";
                 * if (newTitle[newTitle.Length - 1].ToString() != " ") newTitle = newTitle + " "; */
            }

            if (newTitle.Length > 17)
            {
                Player.SendMessage(p, "Title must be under 17 letters."); return;
            }
            if (p != null && !Server.devs.Contains(p.name))
            {
                if (Server.devs.Contains(who.name) || newTitle.ToLower() == "dev" || (newTitle.ToLower().Contains("dev") && newTitle.ToLower().Contains("%")))
                {
                    Player.SendMessage(p, "Can't let you do that, starfox."); return;
                }
            }

            if (newTitle != "")
            {
                Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " was given the title of &b[" + newTitle + "]", false);
            }
            else
            {
                Player.GlobalChat(who, who.color + who.prefix + who.name + Server.DefaultColor + " had their title removed.", false);
            }

            if (newTitle == "")
            {
                query = "UPDATE Players SET Title = '' WHERE Name = '" + who.name + "'";
            }
            else
            {
                query = "UPDATE Players SET Title = '" + newTitle.Replace("'", "\'") + "' WHERE Name = '" + who.name + "'";
            }
            Database.executeQuery(query);
            who.title = newTitle;
            who.SetPrefix();
        }
コード例 #3
0
 public override void Use(Player p, string message)
 {
     if ((message.ToLower() == "set") && p != null)
     {
         p.level.jailx    = p.pos[0]; p.level.jaily = p.pos[1]; p.level.jailz = p.pos[2];
         p.level.jailrotx = p.rot[0]; p.level.jailroty = p.rot[1];
         Player.SendMessage(p, "Set Jail point.");
     }
     else
     {
         Player who = Player.Find(message);
         if (who != null)
         {
             if (!who.jailed)
             {
                 if (p != null)
                 {
                     if (who.group.Permission >= p.group.Permission)
                     {
                         Player.SendMessage(p, "Cannot jail someone of equal or greater rank."); return;
                     }
                 }
                 Player.GlobalDie(who, false);
                 if (p != null)
                 {
                     Player.GlobalSpawn(who, p.level.jailx, p.level.jaily, p.level.jailz, p.level.jailrotx, p.level.jailroty, true);
                 }
                 else
                 {
                     Player.GlobalSpawn(who, who.level.jailx, who.level.jaily, who.level.jailz, who.level.jailrotx, who.level.jailroty, true);
                 }
                 who.jailed = true;
                 if (p == null)
                 {
                     if (Server.devs.Contains(who.name) || Server.gcmodhasprotection(who.name))
                     {
                         return;
                     }
                     Player.SendMessage(p, who.name + " was jailed.");
                 }
                 Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " was &8jailed", false);
             }
             else
             {
                 if (p == null)
                 {
                     if (Server.devs.Contains(who.name) || Server.gcmodhasprotection(who.name))
                     {
                         return;
                     }
                     Player.SendMessage(p, who.name + " was freed from jail.");
                 }
                 who.jailed = false;
                 Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " was &afreed" + Server.DefaultColor + " from jail", false);
             }
         }
         else
         {
             Player.SendMessage(p, "Could not find specified player.");
         }
     }
 }
コード例 #4
0
ファイル: CmdMuseum.cs プロジェクト: OMARATION/mcforge
        public override void Use(Player p, string message)
        {
            string path;

            if (message.Split(' ').Length == 1)
            {
                path = "levels/" + message + ".lvl";
            }
            else if (message.Split(' ').Length == 2)
            {
                try { path = @Server.backupLocation + "/" + message.Split(' ')[0] + "/" + int.Parse(message.Split(' ')[1]) + "/" + message.Split(' ')[0] + ".lvl"; }
                catch { Help(p); return; }
            }
            else
            {
                Help(p); return;
            }

            if (File.Exists(path))
            {
                FileStream fs = File.OpenRead(path);
                try
                {
                    GZipStream gs  = new GZipStream(fs, CompressionMode.Decompress);
                    byte[]     ver = new byte[2];
                    gs.Read(ver, 0, ver.Length);
                    ushort version = BitConverter.ToUInt16(ver, 0);
                    Level  level;
                    if (version == 1874)
                    {
                        byte[] header = new byte[16]; gs.Read(header, 0, header.Length);
                        ushort width  = BitConverter.ToUInt16(header, 0);
                        ushort height = BitConverter.ToUInt16(header, 2);
                        ushort depth  = BitConverter.ToUInt16(header, 4);
                        level        = new Level(name, width, depth, height, "empty");
                        level.spawnx = BitConverter.ToUInt16(header, 6);
                        level.spawnz = BitConverter.ToUInt16(header, 8);
                        level.spawny = BitConverter.ToUInt16(header, 10);
                        level.rotx   = header[12]; level.roty = header[13];
                    }
                    else
                    {
                        byte[] header = new byte[12]; gs.Read(header, 0, header.Length);
                        ushort width  = version;
                        ushort height = BitConverter.ToUInt16(header, 0);
                        ushort depth  = BitConverter.ToUInt16(header, 2);
                        level        = new Level(name, width, depth, height, "grass");
                        level.spawnx = BitConverter.ToUInt16(header, 4);
                        level.spawnz = BitConverter.ToUInt16(header, 6);
                        level.spawny = BitConverter.ToUInt16(header, 8);
                        level.rotx   = header[10]; level.roty = header[11];
                    }

                    level.setPhysics(0);

                    byte[] blocks = new byte[level.width * level.height * level.depth];
                    gs.Read(blocks, 0, blocks.Length);
                    level.blocks = blocks;
                    gs.Close();

                    level.backedup        = true;
                    level.permissionbuild = LevelPermission.Admin;

                    level.jailx    = (ushort)(level.spawnx * 32); level.jaily = (ushort)(level.spawny * 32); level.jailz = (ushort)(level.spawnz * 32);
                    level.jailrotx = level.rotx; level.jailroty = level.roty;

                    p.Loading = true;
                    foreach (Player pl in Player.players)
                    {
                        if (p.level == pl.level && p != pl)
                        {
                            p.SendDie(pl.id);
                        }
                    }
                    foreach (PlayerBot b in PlayerBot.playerbots)
                    {
                        if (p.level == b.level)
                        {
                            p.SendDie(b.id);
                        }
                    }

                    Player.GlobalDie(p, true);

                    p.level = level;
                    p.SendMotd();

                    p.SendRaw(2);
                    byte[] buffer = new byte[level.blocks.Length + 4];
                    BitConverter.GetBytes(IPAddress.HostToNetworkOrder(level.blocks.Length)).CopyTo(buffer, 0);
                    //ushort xx; ushort yy; ushort zz;

                    for (int i = 0; i < level.blocks.Length; ++i)
                    {
                        buffer[4 + i] = Block.Convert(level.blocks[i]);
                    }

                    buffer = buffer.GZip();
                    int number = (int)Math.Ceiling(((double)buffer.Length) / 1024);
                    for (int i = 1; buffer.Length > 0; ++i)
                    {
                        short  length = (short)Math.Min(buffer.Length, 1024);
                        byte[] send   = new byte[1027];
                        Player.HTNO(length).CopyTo(send, 0);
                        Buffer.BlockCopy(buffer, 0, send, 2, length);
                        byte[] tempbuffer = new byte[buffer.Length - length];
                        Buffer.BlockCopy(buffer, length, tempbuffer, 0, buffer.Length - length);
                        buffer     = tempbuffer;
                        send[1026] = (byte)(i * 100 / number);
                        p.SendRaw(3, send);
                        Thread.Sleep(10);
                    }
                    buffer = new byte[6];
                    Player.HTNO((short)level.width).CopyTo(buffer, 0);
                    Player.HTNO((short)level.depth).CopyTo(buffer, 2);
                    Player.HTNO((short)level.height).CopyTo(buffer, 4);
                    p.SendRaw(4, buffer);

                    ushort x = (ushort)((0.5 + level.spawnx) * 32);
                    ushort y = (ushort)((1 + level.spawny) * 32);
                    ushort z = (ushort)((0.5 + level.spawnz) * 32);

                    p.aiming = false;
                    Player.GlobalSpawn(p, x, y, z, level.rotx, level.roty, true);
                    p.ClearBlockchange();
                    p.Loading = false;

                    if (message.IndexOf(' ') == -1)
                    {
                        level.name = "&cMuseum " + Server.DefaultColor + "(" + message.Split(' ')[0] + ")";
                    }
                    else
                    {
                        level.name = "&cMuseum " + Server.DefaultColor + "(" + message.Split(' ')[0] + " " + message.Split(' ')[1] + ")";
                    }

                    if (!p.hidden)
                    {
                        Player.GlobalChat(null, p.color + p.prefix + p.name + Server.DefaultColor + " went to the " + level.name, false);
                    }

                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                catch (Exception ex) { Player.SendMessage(p, "Error loading level."); Server.ErrorLog(ex); return; }
                finally { fs.Close(); }
            }
            else
            {
                Player.SendMessage(p, "Level or backup could not be found."); return;
            }
        }
コード例 #5
0
ファイル: CmdLockdown.cs プロジェクト: OMARATION/mcforge
        // This is where the magic happens, naturally.
        // p is the player object for the player executing the command.  message is everything after the command invocation itself.
        public override void Use(Player p, string message)
        {
            if (!Directory.Exists("text/lockdown"))
            {
                Player.SendMessage(p, "Could not locate the folder creating one now.");
                Directory.CreateDirectory("text/lockdown");
                Directory.CreateDirectory("text/lockdown/map");
                Player.SendMessage(p, "Added the settings for the command");
            }

            string[] param = message.Split(' ');


            if (param.Length == 2 && (param[0] == "map" || param[0] == "player"))
            {
                if (param[0] == "map")
                {
                    if (!Directory.Exists("text/lockdown/map"))
                    {
                        p.SendMessage("Could not locate the map folder, creating one now.");
                        Directory.CreateDirectory("text/lockdown/map");
                        p.SendMessage("Added the map settings Directory within 'text/lockdown'!");
                    }

                    string filepath        = "text/lockdown/map/" + param[1] + "";
                    bool   mapIsLockedDown = File.Exists(filepath);

                    if (!mapIsLockedDown)
                    {
                        File.Create(filepath);
                        Player.GlobalMessage("The map " + param[1] + " has been locked");
                        Player.GlobalMessageOps("Locked by: " + ((p == null) ? "Console" : p.name));
                    }
                    else
                    {
                        File.Delete(filepath);
                        Player.GlobalMessage("The map " + param[1] + " has been unlocked");
                        Player.GlobalMessageOps("Unlocked by: " + ((p == null) ? "Console" : p.name));
                    }
                }

                if (param[0] == "player")
                {
                    Player who = Player.Find(param[1]);

                    if (Server.devs.Contains(who.name))
                    {
                        Player.SendMessage(p, "You can't lockdown a dev!");
                        return;
                    }

                    if (who == null)
                    {
                        Player.SendMessage(p, "There is no player with such name online");
                        return;
                    }


                    if (!who.jailed)
                    {
                        if (p != null)
                        {
                            if (who.group.Permission >= p.group.Permission)
                            {
                                Player.SendMessage(p, "Cannot lock down someone of equal or greater rank.");
                                return;
                            }
                        }
                        if (p != null && who.level != p.level)
                        {
                            Player.SendMessage(p, "Moving player to your map...");
                            Command.all.Find("goto").Use(who, p.level.name);
                            int waits = 0;
                            while (who.Loading)
                            {
                                Thread.Sleep(500);
                                // If they don't load in 10 seconds, eff it.
                                if (waits++ == 20)
                                {
                                    break;
                                }
                            }
                        }
                        Player.GlobalDie(who, false);
                        who.jailed = true;
                        Player.GlobalChat(p, who.color + who.name + Server.DefaultColor + " has been locked down!", true);
                        Player.GlobalMessageOps("Locked by: " + ((p == null) ? "Console" : p.name));
                        return;
                    }
                    else
                    {
                        who.jailed = false;
                        Player.GlobalChat(p, who.color + who.name + Server.DefaultColor + " has been unlocked.", true);
                        Player.GlobalMessageOps("Unlocked by: " + ((p == null) ? "Console" : p.name));
                        return;
                    }
                }
            }
            else
            {
                Help(p);
                return;
            }
        }
コード例 #6
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }

            try
            {
                Level foundLevel = Level.Find(message);
                if (foundLevel != null)
                {
                    Level startLevel = p.level;

                    GC.Collect();

                    if (p.level == foundLevel)
                    {
                        Player.SendMessage(p, "You are already in \"" + foundLevel.name + "\"."); return;
                    }
                    if (!p.ignorePermission)
                    {
                        if (p.group.Permission < foundLevel.permissionvisit)
                        {
                            Player.SendMessage(p, "You're not allowed to go to " + foundLevel.name + "."); return;
                        }
                    }
                    {
                        if (!File.Exists("text/lockdown/map/" + message + ""))
                        {
                            p.Loading = true;
                            foreach (Player pl in Player.players)
                            {
                                if (p.level == pl.level && p != pl)
                                {
                                    p.SendDie(pl.id);
                                }
                            }
                            foreach (PlayerBot b in PlayerBot.playerbots)
                            {
                                if (p.level == b.level)
                                {
                                    p.SendDie(b.id);
                                }
                            }

                            Player.GlobalDie(p, true);
                            p.level = foundLevel; p.SendUserMOTD(); p.SendMap();

                            GC.Collect();

                            ushort x = (ushort)((0.5 + foundLevel.spawnx) * 32);
                            ushort y = (ushort)((1 + foundLevel.spawny) * 32);
                            ushort z = (ushort)((0.5 + foundLevel.spawnz) * 32);

                            if (!p.hidden)
                            {
                                Player.GlobalSpawn(p, x, y, z, foundLevel.rotx, foundLevel.roty, true, "");
                            }
                            else
                            {
                                unchecked { p.SendPos((byte)-1, x, y, z, foundLevel.rotx, foundLevel.roty); }
                            }

                            foreach (Player pl in Player.players)
                            {
                                if (pl.level == p.level && p != pl && !pl.hidden)
                                {
                                    p.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]);
                                }
                            }

                            foreach (PlayerBot b in PlayerBot.playerbots)
                            {
                                if (b.level == p.level)
                                {
                                    p.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
                                }
                            }

                            if (!p.hidden)
                            {
                                Player.GlobalChat(p, p.color + "*" + p.name + Server.DefaultColor + " went to &b" + foundLevel.name, false);
                            }

                            p.Loading = false;

                            bool skipUnload = false;
                            if (startLevel.unload && !startLevel.name.Contains("&cMuseum "))
                            {
                                foreach (Player pl in Player.players)
                                {
                                    if (pl.level == startLevel)
                                    {
                                        skipUnload = true;
                                    }
                                }
                                if (!skipUnload && Server.AutoLoad)
                                {
                                    startLevel.Unload();
                                }
                            }
                        }
                        else
                        {
                            Player.SendMessage(p, "The level " + message + " is locked.");
                        }
                    }
                }
                else if (Server.AutoLoad)
                {
                    Command.all.Find("load").Use(p, message);
                    foundLevel = Level.Find(message);
                    if (foundLevel != null)
                    {
                        Use(p, message);
                    }
                }
                else
                {
                    Player.SendMessage(p, "There is no level \"" + message + "\" loaded.");
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            catch (Exception e) { Server.ErrorLog(e); }
        }
コード例 #7
0
        public override void Use(Player p, string message)
        {
            if (p == null)
            {
                Player.SendMessage(p, "This command can only be used in-game!"); return;
            }
            if (message == "check")
            {
                if (p.hidden)
                {
                    Player.SendMessage(p, "You are currently hidden!");
                    return;
                }
                else
                {
                    Player.SendMessage(p, "You are not currently hidden!");
                    return;
                }
            }
            else
            if (message != "")
            {
                if (p.possess != "")
                {
                    Player.SendMessage(p, "Stop your current possession first.");
                    return;
                }
            }
            Command opchat    = Command.all.Find("opchat");
            Command adminchat = Command.all.Find("adminchat");

            p.hidden = !p.hidden;
            if (p.hidden)
            {
                Player.GlobalDie(p, true);
                Player.GlobalMessageOps("To Ops -" + p.color + p.name + "-" + Server.DefaultColor + " is now &finvisible" + Server.DefaultColor + ".");
                Player.GlobalChat(p, "&c- " + p.color + p.prefix + p.name + Server.DefaultColor + " " + (File.Exists("text/logout/" + p.name + ".txt") ? File.ReadAllText("text/logout/" + p.name + ".txt") : "Disconnected."), false);
                Server.IRC.Say(p.name + " left the game (Disconnected.)");
                if (!p.opchat)
                {
                    opchat.Use(p, message);
                }
                //Player.SendMessage(p, "You're now &finvisible&e.");
            }
            else
            {
                Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
                Player.GlobalMessageOps("To Ops -" + p.color + p.name + "-" + Server.DefaultColor + " is now &8visible" + Server.DefaultColor + ".");
                Player.GlobalChat(p, "&a+ " + p.color + p.prefix + p.name + Server.DefaultColor + " " + (File.Exists("text/login/" + p.name + ".txt") ? File.ReadAllText("text/login/" + p.name + ".txt") : "joined the game."), false);
                Server.IRC.Say(p.name + " joined the game");
                if (p.opchat)
                {
                    opchat.Use(p, message);
                }
                if (p.adminchat)
                {
                    adminchat.Use(p, message);
                }
                //Player.SendMessage(p, "You're now &8visible&e.");
            }
        }
コード例 #8
0
ファイル: CmdColor.cs プロジェクト: OMARATION/mcforge
        public override void Use(Player p, string message)
        {
            if (message == "" || message.Split(' ').Length > 2)
            {
                Help(p); return;
            }
            int pos = message.IndexOf(' ');

            if (pos != -1)
            {
                Player who = Player.Find(message.Substring(0, pos));
                if (who == null)
                {
                    Player.SendMessage(p, "There is no player \"" + message.Substring(0, pos) + "\"!"); return;
                }
                if (message.Substring(pos + 1) == "del")
                {
                    MySQL.executeQuery("UPDATE Players SET color = '' WHERE name = '" + who.name + "'");
                    Player.GlobalChat(who, who.color + "*" + Name(who.name) + " color reverted to " + who.group.color + "their group's default" + Server.DefaultColor + ".", false);
                    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);
                    who.SetPrefix();
                    return;
                }
                string color = c.Parse(message.Substring(pos + 1));
                if (color == "")
                {
                    Player.SendMessage(p, "There is no color \"" + message + "\".");
                }
                else if (color == who.color)
                {
                    Player.SendMessage(p, who.name + " already has that color.");
                }
                else
                {
                    //Player.GlobalChat(who, p.color + "*" + p.name + "&e changed " + who.color + Name(who.name) +
                    //                  " color to " + color +
                    //                  c.Name(color) + "&e.", false);
                    MySQL.executeQuery("UPDATE Players SET color = '" + c.Name(color) + "' WHERE name = '" + who.name + "'");

                    Player.GlobalChat(who, who.color + "*" + Name(who.name) + " color changed to " + color + c.Name(color) + Server.DefaultColor + ".", false);
                    who.color = color;

                    Player.GlobalDie(who, false);
                    Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
                    who.SetPrefix();
                }
            }
            else
            {
                if (message == "del")
                {
                    MySQL.executeQuery("UPDATE Players SET color = '' WHERE name = '" + p.name + "'");

                    Player.GlobalChat(p, p.color + "*" + Name(p.name) + " color reverted to " + p.group.color + "their group's default" + Server.DefaultColor + ".", false);
                    p.color = p.group.color;

                    Player.GlobalDie(p, false);
                    Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
                    p.SetPrefix();
                    return;
                }
                string color = c.Parse(message);
                if (color == "")
                {
                    Player.SendMessage(p, "There is no color \"" + message + "\".");
                }
                else if (color == p.color)
                {
                    Player.SendMessage(p, "You already have that color.");
                }
                else
                {
                    MySQL.executeQuery("UPDATE Players SET color = '" + c.Name(color) + "' WHERE name = '" + p.name + "'");

                    Player.GlobalChat(p, p.color + "*" + Name(p.name) + " color changed to " + color + c.Name(color) + Server.DefaultColor + ".", false);
                    p.color = color;

                    Player.GlobalDie(p, false);
                    Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
                    p.SetPrefix();
                }
            }
        }
コード例 #9
0
ファイル: CmdBan.cs プロジェクト: OMARATION/mcforge
        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;
                    }
                    if (Server.devs.Contains(message.ToLower()))
                    {
                        Player.SendMessage(p, "You can't ban a MCForge Developer!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!");
                        }
                        else
                        {
                            Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!");
                        }
                        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 (Server.devs.Contains(who.name.ToLower()))
                    {
                        Player.SendMessage(p, "You can't ban a MCForge Developer!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!");
                        }
                        else
                        {
                            Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!");
                        }
                        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); }
        }
コード例 #10
0
ファイル: CmdUnban.cs プロジェクト: OMARATION/mcforge
        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);
            }
        }
コード例 #11
0
        int MAX = -1; // This is the value changed to MAX in the Undo list, and used to allow everything undone.

        public override void Use(Player p, string message)
        {
            byte b; long seconds = -2; Player who = null; Player.UndoPos Pos; int CurrentPos = 0; bool undoPhysics = false; string whoName = String.Empty;

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

            if (message == "")
            {
                if (p == null)
                {
                    Player.SendMessage(null, "Console doesn't have an undo buffer.");
                    return;
                }
                else
                {
                    message = p.name.ToLower() + " 30";
                }
            }

            try {
                if (message.Split(' ').Length > 1)
                {
                    whoName     = message.Split(' ')[0];
                    who         = message.Split(' ')[0].ToLower() == "physics" ? null : Player.Find(message.Split(' ')[0]);
                    undoPhysics = message.Split(' ')[0].ToLower() == "physics";
                    message     = message.Split(' ')[1].ToLower();
                }
                else
                {
                    who         = (p == null || message.ToLower() == "physics") ? null : p;
                    undoPhysics = message.ToLower() == "physics";
                }
                //If user is undoing him/herself, then all is go.
                //If user is undoing someone else, then restrictions are used.
                if (p == who)
                {
                    seconds = ((message.ToLower() != "all") ? long.Parse(message) : int.MaxValue);
                }
                else
                {
                    seconds = getAllowed(p, message.ToLower());
                }
            } catch {
                Player.SendMessage(p, "Invalid seconds, or you're unable to use /xundo. Using 30 seconds."); //only run if seconds is an invalid number
                seconds = 30;
            }

            //At this point, we know the number is valid, and allowed for the particular person's group.
            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 && (int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1))
                    {
                        Player.SendMessage(p, "Only an " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 1)).name + "+ may undo other people's actions"); 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.SendMessage(p, "Undid your actions for the past &b" + seconds + Server.DefaultColor + " seconds.");
                }
                else
                {
                    Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + "'s actions for the past &b" + seconds + " seconds were undone.", false);
                    // Also notify console
                    Server.s.Log(who.name + "'s actions for the past " + seconds + " seconds were undone.");
                }
                return;
            }
            else if (undoPhysics)
            {
                if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 2))
                {
                    Player.SendMessage(p, "Reserved for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 2)).name + "+"); return;
                }
                if (!p.group.CanExecute(Command.all.Find("physics")))
                {
                    Player.SendMessage(p, "You can only undo physics if you can use them."); return;
                }

                Command.all.Find("physics").Use(p, "0");
                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 { }
                    }
                }

                Player.GlobalMessage("Physics were undone &b" + seconds + Server.DefaultColor + " seconds");
                // Also notify console
                Player.SendMessage(null, "Physics were undone &b" + seconds + Server.DefaultColor + " seconds");
            }
            else     // Here, who == null, meaning the user specified is offline
            {
                if (p != null)
                {
                    if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1))
                    {
                        Player.SendMessage(p, "Reserved for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 1)).name + "+"); return;
                    }
                    // ^^^ is using the same as the 1st other permission for the this command because the only difference is that this is for offline players so it might aswell be the same!!
                }

                bool FoundUser = false;

                try {
                    DirectoryInfo di;
                    string[]      fileContent;

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

                    if (Directory.Exists("extra/undo/" + whoName.ToLower()))
                    {
                        di = new DirectoryInfo("extra/undo/" + whoName.ToLower());

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

                    if (Directory.Exists("extra/undoPrevious/" + whoName.ToLower()))
                    {
                        di = new DirectoryInfo("extra/undoPrevious/" + whoName.ToLower());

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

                    if (FoundUser)
                    {
                        Player.GlobalMessage(Server.FindColor(whoName) + whoName + Server.DefaultColor + "'s actions for the past &b" + seconds + Server.DefaultColor + " seconds were undone.");
                        // Also notify console
                        Server.s.Log(whoName + "'s actions for the past " + seconds + " seconds were undone.");
                    }
                    else
                    {
                        Player.SendMessage(p, "Could not find player specified.");
                    }
                } catch (Exception e) {
                    Server.ErrorLog(e);
                }
            }
        }
コード例 #12
0
ファイル: CmdSetRank.cs プロジェクト: OMARATION/mcforge
        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);
            }
        }
コード例 #13
0
        public override void Use(Player p, string message)
        {
            if (message == "" || message.IndexOf(' ') == -1)
            {
                Help(p); return;
            }

            bool give = true;

            if (message.Split(' ')[0].ToLower() == "give")
            {
                give    = true;
                message = message.Substring(message.IndexOf(' ') + 1);
            }
            else if (message.Split(' ')[0].ToLower() == "take")
            {
                give    = false;
                message = message.Substring(message.IndexOf(' ') + 1);
            }

            string foundPlayer = message.Split(' ')[0];
            Player who         = Player.Find(message);

            if (who != null)
            {
                foundPlayer = who.name;
            }
            string awardName = message.Substring(message.IndexOf(' ') + 1);

            if (!Awards.awardExists(awardName))
            {
                Player.SendMessage(p, "The award you entered doesn't exist");
                Player.SendMessage(p, "Use /awards for a list of awards");
                return;
            }

            if (give)
            {
                if (Awards.giveAward(foundPlayer, awardName))
                {
                    Player.GlobalChat(p, Server.FindColor(foundPlayer) + foundPlayer + Server.DefaultColor + " was awarded: &b" + Awards.camelCase(awardName), false);
                }
                else
                {
                    Player.SendMessage(p, "The player already has that award!");
                }
            }
            else
            {
                if (Awards.takeAward(foundPlayer, awardName))
                {
                    Player.GlobalChat(p, Server.FindColor(foundPlayer) + foundPlayer + Server.DefaultColor + " had their &b" + Awards.camelCase(awardName) + Server.DefaultColor + " award removed", false);
                }
                else
                {
                    Player.SendMessage(p, "The player didn't have the award you tried to take");
                }
            }

            Awards.Save();
        }
コード例 #14
0
ファイル: CmdUndo.cs プロジェクト: OMARATION/mcforge
        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 == "")
            {
                if (p == null)
                {
                    Player.SendMessage(null, "Console doesn't have an undo buffer.");
                    return;
                }
                else
                {
                    message = p.name + " 30";
                }
            }

            if (message.Split(' ').Length == 2)
            {
                if (message.Split(' ')[1].ToLower() == "all" && p == null)
                {
                    seconds = 500000;
                }
                else 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.SendMessage(p, "Undid your actions for the past &b" + seconds + Server.DefaultColor + " seconds.");
                }
                else
                {
                    Player.GlobalChat(p, who.color + who.name + Server.DefaultColor + "'s actions for the past &b" + seconds + " seconds were undone.", false);
                    // Also notify console
                    Player.SendMessage(null, who.color + who.name + Server.DefaultColor + "'s actions for the past &b" + seconds + " seconds were undone.");
                }
                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("physics").Use(p, "0");
                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 { }
                    }
                }

                Player.GlobalMessage("Physics were undone &b" + seconds + Server.DefaultColor + " seconds");
                // Also notify console
                Player.SendMessage(null, "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;

                    if (p != null)
                    {
                        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);
                        // Also notify console
                        Player.SendMessage(null, Server.FindColor(message.Split(' ')[0]) + message.Split(' ')[0] + Server.DefaultColor + "'s actions for the past &b" + seconds + Server.DefaultColor + " seconds were undone.");
                    }
                    else
                    {
                        Player.SendMessage(p, "Could not find player specified.");
                    }
                }
                catch (Exception e)
                {
                    Server.ErrorLog(e);
                }
            }
        }
コード例 #15
0
        public override void Use(Player p, string message)
        {
            if (message == "" || message.Split(' ').Length > 2)
            {
                Help(p); return;
            }
            Player who = Player.Find(message);

            if (who == null)
            {
                if (Server.devs.Contains(who.name.ToLower()))
                {
                    Player.SendMessage(p, "The player entered is not online, or is a developer.");
                    return;
                }
                if (Server.muted.Contains(message))
                {
                    Server.muted.Remove(message);
                    Player.GlobalMessage(message + Server.DefaultColor + " is not online but is now &bun-muted");
                    Server.muted.Save("muted.txt");
                    return;
                }
            }



            if (who == p)
            {
                if (p.muted)
                {
                    p.muted = false;
                    Player.SendMessage(p, "You &bun-muted" + Server.DefaultColor + " yourself!");
                }
                else
                {
                    Player.SendMessage(p, "You cannot mute yourself!");
                }
                return;
            }
            if (who.muted)
            {
                who.muted = false;
                Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " has been &bun-muted", false);
                Server.muted.Save("muted.txt");
            }
            else
            {
                if (p != null)
                {
                    if (who != p)
                    {
                        if (who.group.Permission >= p.group.Permission)
                        {
                            Player.SendMessage(p, "Cannot mute someone of a higher or equal rank."); return;
                        }
                    }
                }
                if (Server.devs.Contains(who.name.ToLower()))
                {
                    Player.SendMessage(p, "You can't mute a MCForge Developer!");
                    return;
                }
                who.muted = true;
                Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " has been &8muted", false);
                Server.muted.Save("muted.txt");
            }
        }