Esempio n. 1
0
 public override void Use(Player p, params string[] args)
 {
     if (World.Find(args[0]) != null && p.level.name != args[0])
     {
         Player.players.ForEach(delegate(Player p1) { if (p1.level == p.level) p1.SendDespawn(p.id); p.SendDespawn(p1.id); });
         foreach (Chunk c in p.level.chunkData.Values) { p.SendPreChunk(c, 0); }
         p.level = World.Find(args[0]);
         p.Teleport_Player(p.level.SpawnX, p.level.SpawnY, p.level.SpawnZ);
         foreach (Chunk c in p.level.chunkData.Values) { p.SendPreChunk(c, 1); System.Threading.Thread.Sleep(10); p.SendChunk(c); c.RecalculateLight(); }
         p.VisibleChunks.Clear();
         p.UpdateChunks(true, true);
         return;
     }
     p.SendMessage("GOTO FAILED");
 }
Esempio n. 2
0
 public override void Use(Player p, params string[] args)
 {
     if (World.Find(args[0]) != null && p.level.name != args[0])
     {
         Player.players.ForEach(delegate(Player p1) { if (p1.level == p.level) p1.SendDespawn(p.id); p.SendDespawn(p1.id); });
         p.level = World.Find(args[0]);
         p.pos[0] = p.level.SpawnX;
         p.pos[1] = p.level.SpawnY;
         p.pos[2] = p.level.SpawnZ;
         p.VisibleChunks.Clear();
         p.UpdateChunks(true, true);
         p.Teleport_Player(64, 64, 64);
         return;
     }
     p.SendMessage("GOTO FAILED");
 }
Esempio n. 3
0
 public override void Use(Player p, params string[] args)
 {
     if (args.Length != 0)
     {
         Help(p);
         return;
     }
     p.Teleport_Player(p.level.SpawnX, p.level.SpawnY, p.level.SpawnZ);
     /*byte[] bytes = new byte[41];
     util.EndianBitConverter.Big.GetBytes(p.level.SpawnX).CopyTo(bytes, 0);
     util.EndianBitConverter.Big.GetBytes(p.Stance).CopyTo(bytes, 8);
     util.EndianBitConverter.Big.GetBytes(p.level.SpawnY).CopyTo(bytes, 16);
     util.EndianBitConverter.Big.GetBytes(p.level.SpawnZ).CopyTo(bytes, 24);
     util.EndianBitConverter.Big.GetBytes(p.rot[0]).CopyTo(bytes, 32);
     util.EndianBitConverter.Big.GetBytes(p.rot[1]).CopyTo(bytes, 36);
     bytes[40] = p.onground;
     p.SendRaw(0x0D, bytes);*/
 }
Esempio n. 4
0
        public override void Use(Player p, params string[] args)
        {
            switch (args.Length)
            {
                case 0:
                    goto default;
                case 1:
                    if (Player.FindPlayer(args[0]) != null)
                        p.Teleport_Player(Player.FindPlayer(args[0]).pos);
                    else p.SendMessage("Cannot find player");
                    break;
                case 2:
                    if (args[0].ToLower() == "here")
                    {
                        if (Player.FindPlayer(args[1]) != null)
                            Player.FindPlayer(args[1]).Teleport_Player(p.pos);
                        else p.SendMessage("Cannot find player");
                    }
                    break;
                case 3:
                    try
                    {
                        p.pos = new double[3] { int.Parse(args[0]), int.Parse(args[1]), int.Parse(args[2]) };
                        if (p.chunknew != p.chunk) { }
                        p.Teleport_Player((double)(int.Parse(args[0])), (double)(int.Parse(args[1])), (double)(int.Parse(args[2])));
                    }
                    catch { p.SendMessage("Cannot tp to ungenerated chunks."); }
                    break;
                default:
                    Help(p);
                    break;
            }
            #region oldcode
            /*if (args.Length == 0)
            {
                Help(p);
                return;
            }
            if (args.Length == 1)
            {
                Player who = Player.FindPlayer(args[0]); // cannot use a using here or players dissapear.
                if (who != null)
                {
                    p.Teleport_Player(who.pos[0], who.pos[1], who.pos[2]);
                    return;
                }
            }
            if (args.Length == 2)
            {
                if (args[0].ToLower() == "here")
                {
                    Player who = Player.FindPlayer(args[0]); // cannot use a using here or players dissapear.
                    if (who != null)
                    {
                        who.Teleport_Player(p.pos[0], p.pos[1], p.pos[2]);
                        return;
                    }
                }
            }
            if (args.Length == 3)
            {
                try
                {
                    p.pos = new double[3] { int.Parse(args[0]), int.Parse(args[1]), int.Parse(args[2]) };
                    if (p.chunknew != p.chunk) { }
                    p.Teleport_Player((double)(int.Parse(args[0])), (double)(int.Parse(args[1])), (double)(int.Parse(args[2])));
                }
                catch { p.SendMessage("Cannot tp to ungenerated chunks."); return; }
                return;
            }
            Help(p);*/
            /*byte[] bytes = new byte[41]; // some extra code.
            util.EndianBitConverter.Big.GetBytes(p.level.SpawnX).CopyTo(bytes, 0);
            util.EndianBitConverter.Big.GetBytes(p.Stance).CopyTo(bytes, 8);
            util.EndianBitConverter.Big.GetBytes(p.level.SpawnY).CopyTo(bytes, 16);
            util.EndianBitConverter.Big.GetBytes(p.level.SpawnZ).CopyTo(bytes, 24);
            util.EndianBitConverter.Big.GetBytes(p.rot[0]).CopyTo(bytes, 32);
            util.EndianBitConverter.Big.GetBytes(p.rot[1]).CopyTo(bytes, 36);
            bytes[40] = p.onground;
            p.SendRaw(0x0D, bytes);*/

            #endregion
        }
Esempio n. 5
0
        public override void Use(Player p, params string[] args)
        {
            if (args[0].ToLower() == "help")
            {
                Help(p);
                return;
            }

            if (args.Length == 0 || args[0].ToLower() == "list")
            {
                System.Data.DataTable dt = Server.SQLiteDB.GetDataTable("SELECT Name FROM Warp;");

                StringBuilder sb = new StringBuilder();
                string name = "";
                bool allwarps = Group.CheckPermission(p, PermissionNode);

                for(int i = 0; i < dt.Rows.Count; i++)
                {
                    name = dt.Rows[i]["Name"].ToString();
                    if(allwarps)
                    {
                        sb.Append(name + ", ");
                        continue;
                    }
                    if(Group.CheckPermission(p, PermissionNode + "." + name))
                       sb.Append(name + ", ");

                }

                if (sb.Length > 2)
                    sb.Remove(sb.Length - 2, 2);

                p.SendMessage(sb.ToString(), WrapMethod.Chat);
            }
            else if (args.Length == 1)
            {
                double x = 0;
                double y = 0;
                double z = 0;
                World w = World.Find(Server.SQLiteDB.ExecuteScalar("SELECT World FROM Warp WHERE Name = '" + args[0] + "';"));

                if(!double.TryParse(Server.SQLiteDB.ExecuteScalar("SELECT X FROM Warp WHERE Name = '" + args[0] + "';"), out x))
                {
                    p.SendMessage(HelpBot + "There is a problem with that warp point.");
                    return;
                }

                if(!double.TryParse(Server.SQLiteDB.ExecuteScalar("SELECT Y FROM Warp WHERE Name = '"  + args[0] + "';"), out y))
                {
                    p.SendMessage(HelpBot + "There is a problem with that warp point.");
                    return;
                }

                if(!double.TryParse(Server.SQLiteDB.ExecuteScalar("SELECT Z FROM Warp WHERE Name = '" + args[0] + "';"), out z))
                {
                    p.SendMessage(HelpBot + "There is a problem with that warp point.");
                    return;
                }

                if(w == null)
                {
                    p.SendMessage(HelpBot + "World: " + Server.SQLiteDB.ExecuteScalar("SELECT World FROM Warp WHERE Name = '" + args[0] + "';") + " can not be found. Maybe it isn't loaded.");
                    return;
                }

                if (Group.CheckPermission(p, PermissionNode + "." + args[0]))
                {
                    //TODO CHANGE WORLDS
                    p.Teleport_Player(x, y, z);
                }
            }
            else if (args.Length == 2 && args[0].ToLower() == "add" && Group.CheckPermission(p, PermissionNode + ".add"))
            {
                Server.SQLiteDB.ExecuteNonQuery(String.Format("INSERT INTO Warp(Name, X, Y ,Z, World) VALUES('{0}', {1}, {2}, {3}, '{4}');", args[1], p.pos.X, p.pos.Y, p.pos.Z, p.level.name));
                p.SendMessage(HelpBot + "Warp " + args[1] + " created.");
            }
            else if (args.Length == 2 && args[0].ToLower() == "del" && Group.CheckPermission(p, PermissionNode + ".del"))
            {
                Server.SQLiteDB.ExecuteNonQuery("DELETE FROM Warp WHERE Name = '" + args[1] + "';");
                p.SendMessage(HelpBot + "Warp " + args[1] + " deleted.");
            }
        }