Beispiel #1
0
        public override void Use(Player p, params string[] args)
        {
            // CURRENTLY JUST USING FOR DEBUG

            p.health = 0;
            p.SendHealth();
        }
        public override void Use(Player p, params string[] args)
        {
            if (args.Length < 2)
            {
                Help(p);
                return;
            }

            Player pr = Player.FindPlayer(args[0]);
            Group gr = Group.FindGroup(args[1]);

            if (pr == p)
            {
                p.SendMessage(HelpBot + "You can't change your own rank.");
                return;
            }

            if (!GroupUtils.IsHigherRank(p.group, gr))
            {
                p.SendMessage(HelpBot + "You can't rank someone higher than your own rank.");
                return;
            }
            if (gr != null && pr != null)
            {
                pr.group = gr;
                p.SendMessage("There have a nice day!");
                pr.SendMessage(HelpBot + p.username + " set your rank to " + gr.Name + ". Congratulations!");
            }
        }
        public override void Use(Player p, params string[] args)
        {
            if (args.Length == 0)
            {
                Help(p);
                return;
            }

            Player pr = Player.FindPlayer(args[0]);
            if (pr == null)
            {
                p.SendMessage(HelpBot + "Could not find player.");
                return;
            }
            if (pr == p)
            {
                p.SendMessage(HelpBot + "You can't promote yourself.");
                return;
            }
            if (GroupUtils.PromotePlayer(pr))
            {
                p.SendMessage(HelpBot + "Player promoted.");
                pr.SendMessage(HelpBot + p.username + " promoted you. Congratulations!");
            }
            else
                p.SendMessage(HelpBot + "Could not promote player");
        }
Beispiel #4
0
 public override void Use(Player p, params string[] args)
 {
     if (args.Length != 1) { Help(p); return; }
     int radius;
     try
     {
         radius = Convert.ToInt32(args[0]);
     }
     catch
     {
         p.SendMessage("Invalid radius.");
         return;
     }
     if (radius > 15)
     {
         p.SendMessage("Radius too big");
         return;
     }
     if (radius < 3)
     {
         p.SendMessage("Radius too small");
         return;
     }
     p.viewdistance = radius;
 }
Beispiel #5
0
        /// <summary>
        /// Tries to demote a player based on track, if not, and inheritance has only one entry uses it.
        /// </summary>
        /// <param name="p">
        /// A <see cref="Player"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        public static bool DemotePlayer(Player p)
        {
            for (int i = 0; i < p.group.Tracks.Count; i++)
            {
                if(Group.TracksDictionary.ContainsKey(p.group.Tracks[i]))
                {
                    List<Group> tempList;
                    Group.TracksDictionary.TryGetValue(p.group.Tracks[i], out tempList);

                    if(tempList.Count >= 1)
                    {
                        for(int ind = 0; i < tempList.Count; i++)
                        {
                            if(p.group == tempList[ind])
                            {
                                if(ind > 0)
                                {
                                    p.group = tempList[ind - 1];
                                    return true;
                                }
                            }
                        }
                    }

                }
            }

            if(p.group.InheritanceList.Count == 1)
            {
                p.group = p.group.InheritanceList[0];
                return true;
            }
            return false;
        }
Beispiel #6
0
        public override void Use(Player p, params string[] args)
        {
            if (args.Length == 0)
            {
                Help(p);
                return;
            }

            Player banplayer = Player.FindPlayer(args[0]);

            if (banplayer != null)
            {
                if (args.Length >= 2)
                {
                    banplayer.Kick("You were banned: " + String.Join(" ", args, 1, args.Length - 1));
                    Server.BanList.Add(banplayer.username.ToLower());
                }
                else
                {
                    banplayer.Kick("You were banned by " + p.username);
                    Server.BanList.Add(banplayer.username.ToLower());
                }
                Player.GlobalMessage(Color.Announce + banplayer.username + " has been banned!");

            }
            else
            {
                Server.BanList.Add(args[0]);
                p.SendMessage(HelpBot + args[0] + " has been banned");
            }

            foreach(string s in Server.BanList)
                Server.Log(s);
        }
Beispiel #7
0
        public override void Use(Player p, params string[] args)
        {
            if (args.Length > 0)
            {
                Help(p);
                return;
            }

            StringBuilder sb = new StringBuilder();
            /*lock (Player.GetPlayerLock())
            {
                if (Player.players.Count > 0)
                    for (int i = 0; i < Player.players.Count; i++)
                    {
                        sb.Append(Player.players[i].Username);

                        if (i != Player.players.Count - 1)
                            sb.Append(", ");
                    }
                else
                    p.SendMessage("No body is minecrafting right now.");

            }*/

            p.SendMessage("Currently Online: " + sb.ToString());
        }
Beispiel #8
0
 public override void Use(Player p, params string[] args)
 {
     Server.mode = (Server.mode == 0 ? (byte)1 : (byte)0);
     foreach (Player pl in Player.players)
         pl.SendState(3, Server.mode);
     Player.GlobalMessage("The gamemode has been changed to " + (Server.mode == 0 ? "Survival" : "Creative") + "!");
 }
Beispiel #9
0
 public override void Use(Player p, params string[] args)
 {
     if (args.Length != 0 && args.Length != 1)
     {
         Help(p);
         return;
     }
     if (args.Length == 1)
     {
         int update = IntParseFast(args[0].ToLower());
         if (update > 0 & update < 10000)
         {
             p.FlyingUpdate = update;
             p.SendMessage("Flying update interval set to " + IntParseFast(args[0]));
         }
         else if (update == 61964 || update == 29964) Help(p);
         else p.SendMessage("Cant set interval to " + args[0]);
         return;
     }
     if (p.isFlying)
     {
         p.isFlying = false;
         p.SendMessage("Stopped flying");
         return;
     }
     p.SendMessage("You are now flying. &cJump!");
     p.isFlying = true;
     //Thread flyThread = new Thread(() =>
     //{
         //flyingcode(p);
     //}) { Name = "FlyThread-" + p.username };
     //flyThread.Start();
 }
Beispiel #10
0
        public void rain(bool on, Player p)
        {
            if (on)
               {

                byte[] bytes = new byte[1];
                byte thisin = 1;
                bytes[0] = thisin;
                p.SendRaw(0x46, bytes);
                Israining = true;
               // p.SendMessage("Weather is: " + Israining.ToString());
                return;

            }
            if(!on)
            {
                byte[] bytes = new byte[1];
                bytes[0] = 2;
                p.SendRaw(0x46, bytes);
                Israining = false;
                return;
               // p.SendMessage("Weather is: " + Israining.ToString());
            }
            //
            //{

            //    Israining = false;
            //}
            //else
            //{
            //    Israining = true;
            //}
        }
 public override void Use(Player p, params string[] args)
 {
     World.worlds.ForEach(delegate(World w)
     {
         p.SendMessage(w.name + ": " + w.chunkData.Count);
     });
 }
Beispiel #12
0
        public override void Use(Player p, params string[] args)
        {
            // CURRENTLY JUST USING FOR DEBUG
            if (args.Length == 1)
            {
                string text = args[0];
                Player q = Player.FindPlayer(args[0]);
                if (text[0] == '@')
                {
                    string newtext = text;
                    if (text[0] == '@') newtext = text.Remove(0, 1).Trim();

                    Player d = Player.FindPlayer(newtext);

                    d.health = 0;
                    d.SendHealth();
                }

                q.health = 0;
                q.SendHealth();
                Player.GlobalMessage(q.username + " was destroyed by " + p.username);
                return;
            }
            else if (args.Length == 0)
            {

                p.health = 0;
                p.SendHealth();
                return;
            }
            else
            {

            }
        }
        public override void Use(Player p, params string[] args)
        {
            SpheroidData cd; cd.x = 0; cd.y = 0; cd.z = 0;
            cd.type = -1; cd.vertical = false;

            if (args.Length >= 2)
            {
                try { cd.type = Convert.ToInt16(args[0]); }
                catch { cd.type = FindBlocks.FindBlock(args[0]); }
                if (!FindBlocks.ValidBlock(cd.type)) { p.SendMessage("There is no block \"" + args[0] + "\"."); return; }

                cd.vertical = (args[1].ToLower() == "vertical");
            }
            else if (args.Length >= 1)
            {
                cd.vertical = (args[0].ToLower() == "vertical");

                if (!cd.vertical)
                {
                    try { cd.type = Convert.ToInt16(args[0]); }
                    catch { cd.type = FindBlocks.FindBlock(args[0]); }
                    if (!FindBlocks.ValidBlock(cd.type)) { p.SendMessage("There is no block \"" + args[0] + "\"."); return; }
                }
            }

            p.ClearBlockChange();
            p.BlockChangeObject = cd;
            p.OnBlockChange += Blockchange1;
            p.SendMessage("Place/delete a block at 2 corners for the spheroid.");
        }
Beispiel #14
0
        public override void Use(Player p, params string[] args)
        {
            //TODO: Add in checks so you can't kick people higher ranked than you
            if (args.Length == 0 || args[0].ToLower() == "help")
            {
                Help(p);
                return;
            }

            Player KickPlayer = Player.FindPlayer(args[0]);
            if (KickPlayer != null && KickPlayer != p)
            {
                if (args.Length >= 2)
                {
                    StringBuilder reason = new StringBuilder();
                    for (int i = 1; i < args.Length; i++)
                    {
                        reason.Append(args[i] + " ");
                    }
                    reason.Remove(reason.Length - 1, 1);

                    KickPlayer.Kick(reason.ToString());
                }
                else
                {
                    KickPlayer.Kick("You were kicked by " + p.username);
                }
            }
            else if (KickPlayer == p)
            {
                p.SendMessage(HelpBot + "Why are you trying to kick yourself??");
            }
            else if (KickPlayer == null)
                p.SendMessage(HelpBot + "Cannot find player: " + args[0]);
        }
Beispiel #15
0
        public override void Use(Player p, params string[] args)
        {
            World w = World.Find(p.level.name);

            if (args.Length == 1)
            {

                if (args[0] == "off")
                {
                    foreach (Player q in Player.players)
                    {
                        w.rain(false, q);
                    }
                    p.SendMessage(Color.Red + "Stopping rain..");
                    w.Israining = false;
                   // p.SendMessage("rain is: " + w.isRain().ToString());

                }
                if (args[0] == "on")
                {
                    foreach (Player q in Player.players)
                    {
                        w.SendLightning(1, 1, 100, 2, q);
                        w.rain(true, q);
                    }
                    w.Israining = true;
                  //  p.SendMessage("rain is: " + w.isRain().ToString());

                    p.SendMessage(Color.Green + "Starting rain...");
                }
                if (args[0] == "status") { p.SendMessage(Color.Purple + "Rain is: " + w.Israining); }

            }
            else { Help(p); return; }
        }
Beispiel #16
0
 public ChunkSendQueue(int x, int z, Player player)
 {
     this.x = x;
     this.z = z;
     this.player = player;
     this.time = DateTime.Now;
 }
 public override void Use(Player p, params string[] args)
 {
     if (args.Length == 0) { Help(p); return; }
     else if (args.Length == 1)
     {
         Random rand = new Random();
         int seed = new Random().Next();
         p.SendMessage("Creating world with seed: " + seed);
         double x = 0; double y = 127; double z = 0;
         World temp = new World(x, y, z, args[0], seed);
         //while (Chunk.GetChunk((int)x, (int)z, temp).GetBlock((int)x, (int)(y - 1), (int)z) == 0)
         //	y--;
         temp.SpawnY = y;
         World.worlds.Add(temp);
         p.SendMessage("World " + args[0] + " MADE!");
     }
     else if (args.Length == 2 || args.Length == 3)
     {
         int seed = Convert.ToInt32(args[1]);
         p.SendMessage("Creating world with seed: " + seed);
         double x = 0; double y = 127; double z = 0;
         World temp = new World(x, y, z, args[0], seed);
         if (args.Length == 3)
         {
             int limit = Convert.ToInt32(args[2]);
             if (limit > 2)
                 temp.ChunkLimit = limit;
             else { p.SendMessage("maxchunks cannot be less than 3. creating with maxchunks 3."); temp.ChunkLimit = 3; }
         }
         World.worlds.Add(temp);
         p.SendMessage("World " + args[0] + " MADE!");
     }
 }
Beispiel #18
0
 public override void Use(Player p, params string[] args)
 {
     if (args.Length >= 2)
     {
         Help(p);
         return;
     }
     if (args.Length == 1)
     {
         Player who = Player.FindPlayer(args[0]); // cannot use a using here or players dissapear.
         if (who != null)
         {
             if (!who.IsOnFire)
             {
                 who.SetFire(true);
                 Player.GlobalMessage(String.Format("{0} was set on fire by {1}", who.username, p.username));
             }
             else
             {
                 who.SetFire(false);
                 Player.GlobalMessage(String.Format("{0} was extinguished by {1}", who.username, p.username));
             }
             return;
         }
         Help(p);
     }
     if (args.Length == 0)
     {
         p.SetFire(!p.IsOnFire ? true : false);
         p.SendMessage("You are on fire = " + p.IsOnFire);
         return;
     }
 }
Beispiel #19
0
        //public void Add(Player p, byte level) { Add(p, (short)(((short)level) * 20)); }
        /// <summary>
        /// Adds a number to players experience
        /// </summary>
        /// <param name="p">Player, duh!</param>
        /// <param name="exp">The ammount of experience to add</param>
        public void Add(Player p, short exp)
        {
            byte oldlevel = _Level;
            for (int i = 0; i < exp; i++)
            {
                _TotalExp++;
                if (_TotalExp > 780) { _Experience = 0; _Level = 12; continue; }
                _Experience++;
                if (_Experience == ((_Level + 1) * 10)) { _Experience = 0; _Level++; }
            }
            if (oldlevel < _Level) { p.SendMessage("Congratulations! You are now level " + _Level); /*RewardItem(p);*/ } // The reward is annoying as hell!
            //if (_Experience > 127) { _Experience = 127; }

            /*switch (_TotalExp)
            {
                case 10: p.inventory.Add(277, 1, 0); break;
                case 30: p.inventory.Add(278, 1, 0); break;
                case 60: p.inventory.Add(345, 1, 0); break;
                case 100: p.inventory.Add(347, 1, 0); break;
                case 210: p.inventory.Add(358, 1, 0); break;
            }*/
            //_TotalExp += exp;
            //_Level = (byte)(_TotalExp / 10);
            //_Experience = (byte)(_TotalExp - (_Level * 10));

            //Server.Log(_Experience + " " + _Level + " " + _TotalExp);
            //Player.GlobalMessage("Bar= " + _Experience + " level = " + _Level + " totalexp = " + _TotalExp);
            SendExperience(p, _Experience, _Level, _TotalExp);
        }
Beispiel #20
0
 public override void Use(Player p, params string[] args)
 {
     p.ClearBlockChange();
     p.BlockChangeObject = args.Length > 0 ? byte.Parse(args[0]) : (byte)0;
     p.OnBlockChange += Blockchange1;
     p.SendMessage("Place/delete a block where you want the tree.");
     //p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
 }
Beispiel #21
0
 /// <summary>
 /// Updates the players experience bar
 /// </summary>
 /// <param name="expbarval">Value of the experience bar (0-19)</param>
 /// <param name="level">Ecperience level of player</param>
 /// <param name="totalexp">Players total experience</param>
 public static void SendExperience(Player p, byte expbarval, byte level, short totalexp)
 {
     byte[] bytes = new byte[4];
     bytes[0] = expbarval;
     bytes[1] = level;
     util.EndianBitConverter.Big.GetBytes(totalexp).CopyTo(bytes, 2);
     p.SendRaw(0x2B, bytes);
 }
Beispiel #22
0
 public Crafting(Player p, short size)
 {
     this.p = p;
     this.size = size;
     recipes = new List<TableData>();
     Table = new TableData(size);
     loadRecipies("LOL");
 }
Beispiel #23
0
        void Blockchange1(Player p, int x, int y, int z, short type)
        {
            p.ClearBlockChange();
            p.SendBlockChange(x, (byte)y, z, p.level.GetBlock(x, y, z), p.level.GetMeta(x, y, z));

            p.SendMessage("Position: " + x + "," + y + "," + z);
            p.SendMessage("Type: " + p.level.GetBlock(x, y, z));
            p.SendMessage("Meta: " + p.level.GetMeta(x, y, z));
        }
Beispiel #24
0
        public Entity(Player pl, World l)
            : this(l)
        {
            p = pl;
            isPlayer = true;

            UpdateChunks(false, false);

            Entities.Add(id, this);
        }
Beispiel #25
0
        public override void Use(Player p, params string[] args)
        {
            if (args.Length == 0 || (args.Length == 1 && args[0] == "help"))
            {
                Help(p);
                return;
            }

            Player.GlobalMessage(MakeString(args, 0, args.Length), WrapMethod.Chat);
        }
Beispiel #26
0
        public override void Use(Player p, params string[] args)
        {
            if (args.Length == 0 || (args.Length == 1 && args[0] == "help"))
            {
                Help(p);
                return;
            }

            Player.GlobalMessage(String.Join(" ", args));
        }
Beispiel #27
0
        public override void Use(Player p, params string[] args)
        {
            if (args.Length == 0 || args[0].ToLower() == "help")
            {
                Help(p);
                return;
            }

            Player.GlobalMessage(p.username + " " + String.Join(" ", args));
        }
Beispiel #28
0
 public override void Use(Player p, params string[] args)
 {
     World.worlds.ForEach(delegate(World w)
     {
         p.SendMessage(w.name);
         p.SendMessage("Chunks: " + w.chunkData.Count);
         p.SendMessage("Physics: " + w.physics.CheckCount);
         p.SendMessage("Updates: " + w.physics.UpdateCount);
     });
 }
Beispiel #29
0
 //public Weather()
 //    :base(0, 127, 0, "main", new Random().Next())
 //{
 //}
 public void SendLightning(int x, int y, int z, int EntityId, Player p)
 {
     byte[] bytes = new byte[17];
     util.EndianBitConverter.Big.GetBytes(EntityId).CopyTo(bytes, 0);
     util.EndianBitConverter.Big.GetBytes(true).CopyTo(bytes, 4);
     util.EndianBitConverter.Big.GetBytes(x).CopyTo(bytes, 5);
     util.EndianBitConverter.Big.GetBytes(y).CopyTo(bytes, 9);
     util.EndianBitConverter.Big.GetBytes(z).CopyTo(bytes, 13);
     p.SendRaw(0x47, bytes);
 }
Beispiel #30
0
        public Player p; //Only set if this entity is a player, and it referances the player it is

        #endregion Fields

        #region Constructors

        public Entity(Player pl, World l)
        {
            p = pl;
            id = FreeId();
            isPlayer = true;
            level = l;

            UpdateChunks(false, false);

            Entities.Add(id, this);
        }