예제 #1
0
 // Code to run when used by a player
 public override void Use(Player p, string message)
 {
     if (message != "")
     {
         if (Player.ValidName(message))
         {
             if (Server.banned.Contains(message))
             {
                 Player target = Player.Find(message);
                 if (target == null)
                 {
                     Player.GlobalMessage(message + " &8(banned)&e is now " + Group.standard.Color + Group.standard.Name + "&e!");
                 }
                 else
                 {
                     target.group = Group.standard;
                     Player.GlobalChat(target, target.color + target.name + "&e is now " + Group.standard.Color + Group.standard.Name + "&e!", false);
                     Player.GlobalDie(target, false);
                     Player.GlobalSpawn(target, target.pos[0], target.pos[1], target.pos[2], target.rot[0], target.rot[1], false);
                 }
                 Server.banned.Remove(message);
                 Logger.Log("UNBANNED: " + message.ToLower());
             }
             else
             {
                 p.SendMessage(message + " isn't banned.");
             }
         }
         else
         {
             p.SendMessage("Invalid name \"" + message + "\".");
         }
     }
     else
     {
         Help(p);
     }
 }
예제 #2
0
        // Code to run when used by a player
        public override void Use(Player p, string message)
        {
            if (message != "")
            {
                string strBackupLevel  = "levels/backups/" + p.level.name + "/" + message + "/" + p.level.name + ".lvl";
                string strCurrentLevel = "levels/" + p.level.name + ".lvl";
                Logger.Log(strBackupLevel, LogType.Debug);
                if (File.Exists(strBackupLevel))
                {
                    try
                    {
                        File.Copy(strBackupLevel, strCurrentLevel, true);
                        Map temp = Map.Load(p.level.name);
                        if (temp != null)
                        {
                            p.level.spawnx = temp.spawnx;
                            p.level.spawny = temp.spawny;
                            p.level.spawnz = temp.spawnz;

                            p.level.height = temp.height;
                            p.level.width  = temp.width;
                            p.level.depth  = temp.depth;

                            p.level.blocks = temp.blocks;

                            // Disable physics before restoring
                            p.level.Physics = Physics.Off;
                            p.level.ClearPhysics();

                            ushort x, y, z;

                            foreach (var pl in Player.players)
                            {
                                if (pl.level == p.level)
                                {
                                    pl.Loading = true;

                                    //Kills current player list for player
                                    foreach (Player pl2 in Player.players)
                                    {
                                        if (pl.level == pl2.level && pl != pl2)
                                        {
                                            pl.SendDie(pl2.id);
                                        }
                                    }



                                    pl.ClearBlockchange();
                                    pl.BlockAction = 0;
                                    pl.painting    = false;
                                    Player.GlobalDie(pl, true);
                                    pl.SendMotd();
                                    pl.SendMap();
                                    x = (ushort)((0.5 + pl.level.spawnx) * 32);
                                    y = (ushort)((1 + pl.level.spawny) * 32);
                                    z = (ushort)((0.5 + pl.level.spawnz) * 32);
                                    if (!pl.hidden)
                                    {
                                        Player.GlobalSpawn(pl, x, y, z, pl.level.rotx, pl.level.roty, true);
                                    }
                                    else
                                    {
                                        unchecked
                                        {
                                            pl.SendPos((byte)-1, x, y, z, pl.level.rotx, pl.level.roty);
                                        }
                                    }
                                    foreach (Player pl2 in Player.players)
                                    {
                                        if (pl2.level == pl.level && pl != pl2 && !pl2.hidden)
                                        {
                                            pl.SendSpawn(pl2.id, pl2.color + pl2.name, pl2.pos[0], pl2.pos[1], pl2.pos[2], pl2.rot[0], pl2.rot[1]);
                                        }
                                    }

                                    pl.Loading = false;
                                }
                                GC.Collect();
                                GC.WaitForPendingFinalizers();
                            }
                        }
                        else
                        {
                            Logger.Log("Restore didn't work, attempting last backup", LogType.Debug);
                            File.Copy(strCurrentLevel + ".backup", strCurrentLevel, true);
                        }
                    }
                    catch
                    {
                        Logger.Log("Restore fail", LogType.Error);
                    }
                }
                else
                {
                    p.SendMessage("Backup " + message + " does not exist.");
                }
            }
            else
            {
                if (Directory.Exists("levels/backups/" + p.level.name))
                {
                    int backupNumber = Directory.GetDirectories("levels/backups/" + p.level.name).Length;
                    p.SendMessage(p.level.name + " has " + backupNumber.ToString() + " backups .");
                }
                else
                {
                    p.SendMessage(p.level.name + " has no backups yet.");
                }
            }
        }
예제 #3
0
        // Code to run when used by a player
        public override void Use(Player p, string message)
        {
            //p.SendMessage("Sorry this command is temporarily disabled");

            if (message != "" && message.Split(' ').Length <= 2)
            {
                int pos = message.IndexOf(' ');
                if (pos != -1)
                {
                    Player target = Player.Find(message.Substring(0, pos));
                    if (target == null)
                    {
                        p.SendMessage("There is no player \"" + message.Substring(0, pos) + "\"!");
                    }
                    else
                    {
                        string color = ChatColor.Parse(message.Substring(pos + 1));
                        if (color == "")
                        {
                            p.SendMessage("There is no color \"" + message + "\".");
                        }
                        else if (color == target.color)
                        {
                            p.SendMessage(target.name + " already has that color.");
                        }
                        else
                        {
                            Player.GlobalChat(target, target.color + "*" + FormatName(target.name) + " color changed to " + color + ChatColor.Name(color) + "&e.", false);
                            target.color = color;

                            Player.GlobalDie(target, false);
                            Player.GlobalSpawn(target, target.pos[0], target.pos[1], target.pos[2], target.rot[0], target.rot[1], false);
                        }
                    }
                }
                else
                {
                    string color = ChatColor.Parse(message);
                    if (color == "")
                    {
                        p.SendMessage("There is no color \"" + message + "\".");
                    }
                    else if (color == p.color)
                    {
                        p.SendMessage("You already have that color.");
                    }
                    else
                    {
                        Player.GlobalChat(p, p.color + "*" + FormatName(p.name) +
                                          " color changed to " + color +
                                          ChatColor.Name(color) + "&e.", 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);
                    }
                }
            }
            else
            {
                Help(p);
            }
        }